Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6.0: Create Git tag before releasing, ideally #1433

Merged
merged 3 commits into from
Jun 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,44 @@ 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 }}
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: 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:
Expand All @@ -35,31 +59,22 @@ 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
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
Expand Down
Loading