diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..62ffdef --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,56 @@ +name: Releases + +on: + pull_request: + push: + branches: + - "release-*" + release: + types: + - created + +jobs: + publish: + name: Publish assets + runs-on: "ubuntu-latest" + permissions: + id-token: write + steps: + - uses: actions/checkout@master + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install poetry + uses: abatilo/actions-poetry@v3 + with: + poetry-version: "1.8.3" + + # Setting the proper version + - name: Get previous Tag + if: contains(github.ref, 'refs/heads/release-') + id: previous_tag + uses: WyriHaximus/github-action-get-previous-tag@v1 + with: + fallback: 0.1.0 + - name: Set Build version + if: contains(github.ref, 'refs/heads/release-') + run: poetry version "${{ steps.previous_tag.outputs.tag }}.dev${{ github.run_number }}" + - name: Set Release version + if: github.event_name == 'release' && github.event.action == 'created' + run: poetry version ${{ github.ref_name }} + + # Build package + - name: Build poetry package + run: poetry build + + # Publishing the package + - name: Publish distribution 📦 to Test PyPI + if: contains(github.ref, 'refs/heads/release-') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + verbose: true + - name: Publish distribution 📦 to PyPI + if: github.event_name == 'release' && github.event.action == 'created' + uses: pypa/gh-action-pypi-publish@release/v1