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

Refactor release process in order to include changelog in release files #1246

Merged
merged 55 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b5ed112
Extract `bump-changelog` action into separate workflow
chrysle Feb 6, 2024
17247a3
Create `create-release` job in `tests.yml`
chrysle Apr 9, 2024
3fbaa57
Bump changelog for 1.0.0 (#2)
github-actions[bot] Apr 13, 2024
24d0428
Specify pull request types that trigger CI
chrysle Apr 13, 2024
bcb9e15
Remove requirement for job
chrysle Apr 13, 2024
0b7329f
Try to fix label detection
chrysle Apr 13, 2024
789fd08
Try out `pull_request_target` event
chrysle Apr 14, 2024
4784691
Fix environment variable access syntax
chrysle Apr 14, 2024
b8a6d3d
Try splitting out in separate workflow
chrysle Apr 14, 2024
7162ae2
Use concurrency
chrysle Apr 15, 2024
4618518
Create `create-release` job in `tests.yml`
chrysle Apr 9, 2024
88b5679
Specify pull request types that trigger CI
chrysle Apr 13, 2024
5b8f71d
Remove requirement for job
chrysle Apr 13, 2024
72c7d6c
Try to fix label detection
chrysle Apr 13, 2024
8af9b56
Try out `pull_request_target` event
chrysle Apr 14, 2024
33c7255
Fix environment variable access syntax
chrysle Apr 14, 2024
b116c2b
Try moving related jobs into release workflow
chrysle May 14, 2024
5ec28b6
Specify Python version in release workflow
chrysle May 14, 2024
bbc1bec
Amend for testing
chrysle May 14, 2024
1c97b0c
Retrieve artifact from previous workflow run
chrysle May 14, 2024
f590cb0
Create release before uploading asset (makes sense)
chrysle May 14, 2024
abe0228
Specify tag name
chrysle May 14, 2024
bb56f99
Don't run in parallel *yawn*
chrysle May 14, 2024
63dfd8a
Get that blasted tag
chrysle May 14, 2024
e5c9c94
Permissions
chrysle May 14, 2024
09f0ac0
Cleanup, docs
chrysle May 15, 2024
22c7ef0
Extract `bump-changelog` action into separate workflow
chrysle Feb 6, 2024
cb3bc70
Create `create-release` job in `tests.yml`
chrysle Apr 9, 2024
ecc2a13
Bump changelog for 1.0.0 (#2)
github-actions[bot] Apr 13, 2024
0acecbb
Specify pull request types that trigger CI
chrysle Apr 13, 2024
aa3b1e1
Remove requirement for job
chrysle Apr 13, 2024
ef1c9d2
Try to fix label detection
chrysle Apr 13, 2024
6d2f27e
Try out `pull_request_target` event
chrysle Apr 14, 2024
fc40ed4
Fix environment variable access syntax
chrysle Apr 14, 2024
eb9bee1
Try splitting out in separate workflow
chrysle Apr 14, 2024
35fb55d
Use concurrency
chrysle Apr 15, 2024
dc124f5
Create `create-release` job in `tests.yml`
chrysle Apr 9, 2024
74e9383
Specify pull request types that trigger CI
chrysle Apr 13, 2024
92a26b2
Remove requirement for job
chrysle Apr 13, 2024
7795882
Try to fix label detection
chrysle Apr 13, 2024
5e3e23e
Try out `pull_request_target` event
chrysle Apr 14, 2024
2118c32
Fix environment variable access syntax
chrysle Apr 14, 2024
fdf8055
Try moving related jobs into release workflow
chrysle May 14, 2024
8401019
Specify Python version in release workflow
chrysle May 14, 2024
5d006fb
Amend for testing
chrysle May 14, 2024
5b5bf24
Retrieve artifact from previous workflow run
chrysle May 14, 2024
5572513
Create release before uploading asset (makes sense)
chrysle May 14, 2024
14c9526
Specify tag name
chrysle May 14, 2024
fe1dba9
Don't run in parallel *yawn*
chrysle May 14, 2024
02baf8b
Get that blasted tag
chrysle May 14, 2024
a880669
Permissions
chrysle May 14, 2024
a48b1fc
Cleanup, docs
chrysle May 15, 2024
aee2f52
Better sentence structure
chrysle May 16, 2024
4338952
Merge branch 'stable-tagging' of github.com:chrysle/pipx into stable-…
chrysle May 17, 2024
99bc753
Use concurrency in `bump-changelog.yml`
chrysle May 17, 2024
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
55 changes: 55 additions & 0 deletions .github/workflows/bump-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Bump changelog before release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to be released'
required: true
type: string
chrysle marked this conversation as resolved.
Show resolved Hide resolved
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
default-python: "3.12"
minimum-supported-python: "3.8"

jobs:
bump-changelog:
name: Bump changelog
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Get release version and construct PR branch
run: |
echo "RELEASE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
echo "PR_BRANCH=bump-changelog-for-${{ inputs.version }}" >> $GITHUB_ENV
- name: Create pull request branch
run: git switch -c $PR_BRANCH
- name: Install nox
run: python -m pip install nox
- name: Update changelog
run: nox --error-on-missing-interpreters --non-interactive --session build_changelog -- $RELEASE_VERSION
- name: Commit and push change
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -am "$RELEASE_VERSION: Bump changelog"
git fetch origin
git push origin $PR_BRANCH
- name: Create pull request
run: |
git fetch origin
gh pr create --base main --fill --label release-version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Release

on:
pull_request_target:
types:
- closed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
default-python: "3.12"

jobs:
pypi-publish:
name: Publish pipx to PyPI
if: >-
github.event.pull_request.merged == true
&& contains(github.event.pull_request.labels.*.name, 'release-version')
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/pipx
permissions:
id-token: write
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Install nox
run: pip install nox
- name: Build sdist and wheel
run: nox --error-on-missing-interpreters --non-interactive --session build
- name: Publish to PyPi
uses: pypa/[email protected]

create-release:
name: Create a release on GitHub's UI
needs: pypi-publish
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
with:
generateReleaseNotes: true
tag: "${{ steps.get-version.outputs.version }}"
commit: ${{ github.event.pull_request.merge_commit_sha }}

upload-zipapp:
name: Upload zipapp to GitHub Release
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: dawidd6/action-download-artifact@v3
with:
name: pipx.pyz
workflow: tests.yml
workflow_conclusion: success
pr: ${{ github.event.pull_request.number }}
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
files: pipx.pyz
tag_name: "${{ needs.create-release.outputs.release-tag }}"
76 changes: 0 additions & 76 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,79 +85,3 @@ jobs:
name: pipx.pyz
path: pipx.pyz
retention-days: 3

pypi-publish:
name: Publish pipx to PyPI on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [tests, man, zipapp]
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/pipx
permissions:
id-token: write
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Install nox
run: pip install nox
- name: Build sdist and wheel
run: nox --error-on-missing-interpreters --non-interactive --session build
- name: Publish to PyPi
uses: pypa/[email protected]

upload-zipapp:
name: Upload zipapp to GitHub Release on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [tests, man, zipapp]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: pipx.pyz
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: pipx.pyz

bump-changelog:
name: Bump changelog on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [pypi-publish, upload-zipapp]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Extract release tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Create pull request branch
run: git switch -c "bump-changelog-for-${RELEASE_VERSION}"
- name: Install nox
run: python -m pip install nox
- name: Update changelog
run: nox --error-on-missing-interpreters --non-interactive --session build_changelog -- $RELEASE_VERSION
- name: Commit and push change
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -am "Bump changelog for $RELEASE_VERSION"
git push origin "bump-changelog-for-${RELEASE_VERSION}"
- name: Create pull request
run: |
git fetch origin
gh pr create --base main --fill
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,15 @@ nox -s watch_docs

## Releasing New `pipx` Versions

To publish to PyPI simply create a "published" release on GitHub. This will trigger GitHub workflows that publishes:
To release a new version, manually run the `bump-changelog` action under the *"Actions"* tab, passing it the version to be released. This will create a pull request updating the changelog for the upcoming version, with the `release-version` label. Merging this PR will automatically trigger the release workflows.

Attaching this label to any pull request of which the title follows the format `<Version>: Description` and merging it will trigger the release workflows as well.

The release workflow consists of publishing:

- the pipx version to PyPI,
- the documentation to readthedocs,
- the documentation to ReadTheDocs,
- a GitHub release,
- the `zipapp` to the GitHub release created.

No need for any other pre or post publish steps.