From 0272b3b0bda5affda24f3ef2a53bc234505b75b5 Mon Sep 17 00:00:00 2001 From: chrysle <96722107+chrysle@users.noreply.github.com> Date: Wed, 29 May 2024 17:33:03 +0200 Subject: [PATCH 1/3] Create Git tag before releasing, ideally --- .github/workflows/release.yml | 51 +++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43e222bfd0..e2f6a771ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,20 +12,42 @@ env: default-python: "3.12" jobs: - pypi-publish: - name: Publish pipx to PyPI + create-tag: + name: Create the Git tag if: >- github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release-version') runs-on: ubuntu-latest + outputs: + release-tag: ${{ steps.get-version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Extract version to be released + id: get-version + env: + TITLE: ${{ github.event.pull_request.title }} + run: | + echo "version=${TITLE/: [[:alnum:]]*}" >> "$GITHUB_OUTPUT" + - name: Bump version and push tag + uses: mathieudutour/github-tag-action@v6.2 + with: + custom_tag: "${{ steps.get-version.outputs.version }}" + github_token: ${{ secrets.GITHUB_TOKEN }} + + pypi-publish: + name: Publish pipx to PyPI + needs: create-tag + runs-on: ubuntu-latest environment: name: release url: https://pypi.org/p/pipx permissions: id-token: write steps: - - name: Checkout ${{ github.ref }} + - name: Checkout ${{ needs.create-tag.outputs.release-tag }} uses: actions/checkout@v4 + with: + ref: "${{ needs.create-tag.outputs.release-tag }}" - name: Set up Python ${{ env.default-python }} uses: actions/setup-python@v5 with: @@ -35,31 +57,26 @@ jobs: run: pip install nox - name: Build sdist and wheel run: nox --error-on-missing-interpreters --non-interactive --session build - - name: Publish to PyPi + - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@v1.8.14 create-release: name: Create a release on GitHub's UI - needs: pypi-publish +<<<<<<< HEAD +======= + if: always() +>>>>>>> Create Git tag before releasing, ideally + needs: [pypi-publish, create-tag] runs-on: ubuntu-latest - outputs: - release-tag: ${{ steps.get-version.outputs.version }} permissions: contents: write steps: - uses: actions/checkout@v4 - - name: Extract version to be released - id: get-version - env: - TITLE: ${{ github.event.pull_request.title }} - run: | - echo "version=${TITLE/: [[:alnum:]]*} }" >> "$GITHUB_OUTPUT" - name: Create release - uses: ncipollo/release-action@v1 + uses: softprops/action-gh-release@v2 with: - generateReleaseNotes: true - tag: "${{ steps.get-version.outputs.version }}" - commit: ${{ github.event.pull_request.merge_commit_sha }} + generate_release_notes: true + tag_name: "${{ needs.create-tag.outputs.release-tag }}" upload-zipapp: name: Upload zipapp to GitHub Release From b5a8248a6591c6d9e5499f2518257398c2a6204f Mon Sep 17 00:00:00 2001 From: chrysle <96722107+chrysle@users.noreply.github.com> Date: Thu, 30 May 2024 12:55:05 +0200 Subject: [PATCH 2/3] Fix the permissions --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2f6a771ac..63de302451 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,8 @@ jobs: runs-on: ubuntu-latest outputs: release-tag: ${{ steps.get-version.outputs.version }} + permissions: + contents: write steps: - uses: actions/checkout@v4 - name: Extract version to be released From 5612ee08ede2d10f1eac3ded3e0bf831adb8f798 Mon Sep 17 00:00:00 2001 From: chrysle <96722107+chrysle@users.noreply.github.com> Date: Thu, 30 May 2024 13:01:58 +0200 Subject: [PATCH 3/3] Cleanup --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63de302451..f666d748e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,10 +64,6 @@ jobs: create-release: name: Create a release on GitHub's UI -<<<<<<< HEAD -======= - if: always() ->>>>>>> Create Git tag before releasing, ideally needs: [pypi-publish, create-tag] runs-on: ubuntu-latest permissions: