Skip to content

Commit

Permalink
Extract bump-changelog action into separate workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysle committed Mar 10, 2024
1 parent 0cfcdc1 commit 411ec66
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 38 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/bump-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Bump changelog before release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to be released'
required: true
type: string

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 "Bump changelog for $RELEASE_VERSION"
git push origin $PR_BRANCH
- name: Create pull request
run: |
git fetch origin
gh pr create --base main --fill
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 0 additions & 37 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,40 +122,3 @@ jobs:
uses: softprops/action-gh-release@v1
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 }}
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ 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. Then, simply create a "published" release on GitHub. This will trigger GitHub workflows that publish:
- the pipx version to PyPI,
- the documentation to readthedocs,
Expand Down

0 comments on commit 411ec66

Please sign in to comment.