diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml deleted file mode 100644 index 7243a71..0000000 --- a/.github/workflows/pypi.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: Publish to PyPI - -on: workflow_dispatch - -permissions: - actions: write - -jobs: - build: - name: Build Package - runs-on: ubuntu-latest - - steps: - - name: Checkout project - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Install Poetry - uses: abatilo/actions-poetry@v4 - with: - poetry-version: "1.8.5" - - - name: Setup a local virtual environment - run: | - poetry config virtualenvs.create true --local - poetry config virtualenvs.in-project true --local - - - name: Define a cache for the virtual environment based on the dependencies lock file - uses: actions/cache@v4 - with: - path: ./.venv - key: venv-${{ hashFiles('poetry.lock') }} - - - name: Build - run: poetry build - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: csaps-packages - path: dist/* - overwrite: true - - upload: - name: Upload Package to PyPI - needs: [ build ] - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/project/csaps - permissions: - id-token: write - - steps: - - uses: actions/download-artifact@v4 - with: - name: csaps-packages - path: dist - - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..bbfa439 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,115 @@ +name: Create Release + +on: + workflow_dispatch: + inputs: + release_notes: + description: 'Release notes' + type: string + required: false + default: '' + upload_to_pypi: + description: 'Upload the release to PyPI' + type: boolean + required: false + default: true + +permissions: + actions: write + contents: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get-version.outputs.VERSION }} + + steps: + - name: Checkout project + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Poetry + uses: abatilo/actions-poetry@v4 + with: + poetry-version: "1.8.5" + + - name: Setup a local virtual environment + run: | + poetry config virtualenvs.create true --local + poetry config virtualenvs.in-project true --local + + - name: Define a cache for the virtual environment based on the dependencies lock file + uses: actions/cache@v4 + with: + path: ./.venv + key: venv-${{ hashFiles('poetry.lock') }} + + - name: Build + run: | + poetry install + poetry build + + - name: Get package version to create a new tag and release + id: get-version + run: echo "VERSION=$(poetry version --short)" >> $GITHUB_OUTPUT + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: csaps-packages + path: dist/* + overwrite: true + + publish: + name: Publish + needs: [ build ] + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/project/csaps + permissions: + id-token: write + env: + TAG_NAME: v${{ needs.build.outputs.version }} + + steps: + - uses: actions/download-artifact@v4 + with: + name: csaps-packages + path: dist + + - name: Check tag ${{ TAG_NAME }} + uses: mukunku/tag-exists-action@v1.6.0 + id: check-tag + with: + tag: ${{ TAG_NAME }} + + - name: Create tag ${{ TAG_NAME }} + if: ${{ steps.check-tag.outputs.exists == 'false' }} + uses: actions/github-script@v7 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ TAG_NAME }}', + sha: context.sha + }) + + - name: Create release ${{ TAG_NAME }} + uses: softprops/action-gh-release@v2 + with: + name: ${{ TAG_NAME }} + tag_name: ${{ TAG_NAME }} + files: dist/* + body: inputs.release_notes + + - name: Upload to PyPI + if: ${{ inputs.upload_to_pypi }} + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index 62814e9..ec9b03a 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ Use pip for installing: pip install -U csaps ``` +or Poetry: + +``` +poetry add csaps +``` + The module depends only on NumPy and SciPy. Python 3.9 or above is supported. ## Simple Examples @@ -96,9 +102,10 @@ More examples of usage and the full documentation can be found at https://csaps. We use pytest for testing. ``` -cd /path/to/csaps/project/directory -pip install -e .[tests] -pytest +git clone https://github.com/espdev/csaps.git +cd csaps +poetry install +poetry run poe test ``` ## Algorithm and Implementation