This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
Release #70
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
name: 'Release' | |
on: | |
workflow_dispatch: | |
inputs: | |
bumpVersion: | |
description: 'Whether to bump the version number' | |
required: true | |
type: boolean | |
default: true | |
versionLevel: | |
description: 'Which version level to bump' | |
required: true | |
type: choice | |
default: 'patch' | |
options: | |
- 'patch' # bug fixes | |
- 'minor' # new features, backwards compatible | |
- 'major' # breaking changes | |
- 'prepatch' # bumps the patch and moves to a prerelease (1.0.2 -> 1.0.3a0) | |
- 'preminor' # bumps the minor and moves to a prerelease (1.0.2 -> 1.1.0a0) | |
- 'premajor' # bumps the major and moves to a prerelease (1.0.2 -> 2.0.0a0) | |
- 'prerelease' # bumps the prerelease version (1.0.3a0 -> 1.0.3a1) | |
generateBranch: | |
description: 'Whether to generate a release branch' | |
required: true | |
type: boolean | |
default: false | |
useTestPyPI: | |
description: 'Whether to use the test PyPI repository' | |
required: true | |
type: boolean | |
default: false | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.store-version.outputs.new_version }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.ref }} | |
token: ${{ secrets.VERSION_BUMP_PAT }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 # The lowest we support | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.3.2 | |
- name: Bump version | |
if: ${{ inputs.bumpVersion == true }} | |
run: | | |
poetry version ${{ inputs.versionLevel || 'patch' }} | |
- name: Store version number | |
id: store-version | |
run: | | |
echo "new_version=$(poetry version -s)" >> $GITHUB_OUTPUT | |
- name: Build wheel | |
run: | | |
poetry build | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: ./dist/ | |
test-all-OSes: | |
needs: build | |
uses: ./.github/workflows/pre-release-CI.yml | |
publish: | |
needs: [build, test-all-OSes] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.ref }} | |
token: ${{ secrets.VERSION_BUMP_PAT }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.3.2 | |
- name: download wheels | |
uses: actions/download-artifact@v2 | |
with: | |
name: wheels | |
path: ./dist/ | |
- name: Set version | |
env: | |
NEW_VERSION: ${{ needs.build.outputs.new_version }} | |
run: | | |
echo $NEW_VERSION | |
poetry version $NEW_VERSION | |
- name: Commit version update | |
if: ${{ inputs.bumpVersion == true }} | |
run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "[email protected]" | |
git add pyproject.toml | |
git commit -m "Bump version to $(poetry version -s)" | |
git push | |
- name: Create release branch | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.generateBranch == 'true' }} | |
run: | | |
git checkout -b release/$(poetry version -s) | |
git push origin release/$(poetry version -s) | |
- name: Parse Changelog | |
id: changelog | |
uses: ocavue/changelog-parser-action@v1 | |
- name: Create GH release | |
uses: ncipollo/release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: v${{ needs.build.outputs.new_version }} | |
name: ${{ needs.build.outputs.new_version }} | |
artifacts: "dist/*" | |
body: ${{ steps.changelog.outputs.latestBody }} | |
prerelease: ${{ startsWith(inputs.versionLevel, 'pre') }} | |
- name: Publish to test pypi | |
if: ${{ inputs.useTestPyPI == true }} | |
run: | | |
poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }} | |
poetry publish -r testpypi | |
- name: Publish to pypi | |
if: ${{ inputs.useTestPyPI == false }} | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | |
poetry publish | |
publish-image: | |
needs: [build, publish] | |
uses: ./.github/workflows/build-push-image.yml | |
with: | |
version: ${{ needs.build.outputs.new_version }} |