-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor release process in order to include changelog in release fil…
…es (#1246) * Extract `bump-changelog` action into separate workflow * Create `create-release` job in `tests.yml` * Bump changelog for 1.0.0 (#2) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Specify pull request types that trigger CI * Remove requirement for job * Try to fix label detection * Try out `pull_request_target` event * Fix environment variable access syntax * Try splitting out in separate workflow * Use concurrency * Create `create-release` job in `tests.yml` * Specify pull request types that trigger CI * Remove requirement for job * Try to fix label detection * Try out `pull_request_target` event * Fix environment variable access syntax * Try moving related jobs into release workflow * Specify Python version in release workflow * Amend for testing * Retrieve artifact from previous workflow run * Create release before uploading asset (makes sense) * Specify tag name * Don't run in parallel *yawn* * Get that blasted tag * Permissions * Cleanup, docs * Extract `bump-changelog` action into separate workflow * Create `create-release` job in `tests.yml` * Bump changelog for 1.0.0 (#2) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Specify pull request types that trigger CI * Remove requirement for job * Try to fix label detection * Try out `pull_request_target` event * Fix environment variable access syntax * Try splitting out in separate workflow * Use concurrency * Create `create-release` job in `tests.yml` * Specify pull request types that trigger CI * Remove requirement for job * Try to fix label detection * Try out `pull_request_target` event * Fix environment variable access syntax * Try moving related jobs into release workflow * Specify Python version in release workflow * Amend for testing * Retrieve artifact from previous workflow run * Create release before uploading asset (makes sense) * Specify tag name * Don't run in parallel *yawn* * Get that blasted tag * Permissions * Cleanup, docs * Better sentence structure Co-authored-by: Robert <[email protected]> * Use concurrency in `bump-changelog.yml` And fix concurrency group definition in `release.yml`. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Robert <[email protected]>
- Loading branch information
1 parent
ffba90c
commit 2970397
Showing
4 changed files
with
143 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters