Bump version #43
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: Bump version | |
on: | |
workflow_dispatch: | |
inputs: | |
bump_rule: | |
type: choice | |
description: How to bump the project's version (see https://python-poetry.org/docs/cli/#version) | |
options: | |
- no-pre-release | |
# no micro because we always sit on a pre-release in main, | |
# so we would always use no-pre-release instead of micro | |
# - micro | |
- minor | |
- major | |
- "pre-release --pre alpha" | |
- "pre-release --pre beta" | |
- "pre-release --pre release-candidate" | |
required: true | |
jobs: | |
bump_version: | |
name: "Bump version and create changelog" | |
if: "!startsWith(github.event.head_commit.message, 'bump:')" | |
runs-on: ubuntu-latest | |
env: | |
CI_COMMIT_EMAIL: "ci-runner@input4mips-validation.invalid" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@v4 | |
with: | |
python-version: "3.9" | |
- name: Install pdm-bump | |
run: | | |
pdm self add pdm-bump | |
# Install the package and towncrier with pixi | |
- uses: ./.github/actions/setup | |
with: | |
pixi-environments: "all-dev" | |
- name: Create bump and changelog | |
run: | | |
git config --global user.name "$GITHUB_ACTOR" | |
git config --global user.email "$CI_COMMIT_EMAIL" | |
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml` | |
echo "Bumping from version $BASE_VERSION" | |
# Bump | |
pdm bump ${{ github.event.inputs.bump_rule }} | |
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml` | |
echo "Bumping to version $NEW_VERSION" | |
# Build CHANGELOG | |
pixi run --frozen -e all-dev towncrier build --yes --version v$NEW_VERSION | |
# Commit, tag and push | |
git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION" | |
git tag v$NEW_VERSION | |
git push && git push --tags | |
# Bump to alpha (so that future commits do not have the same | |
# version as the tagged commit) | |
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml` | |
# Bump (need two commands because of a bug in pdm-bump) | |
# See https://github.com/carstencodes/pdm-bump/issues/326 | |
pdm bump micro | |
pdm bump pre-release --pre alpha | |
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml` | |
echo "Bumping version $BASE_VERSION > $NEW_VERSION" | |
# Skip pre-commit to avoid pixi install throwing weird errors | |
# Commit and push | |
git commit -n -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION" | |
git push |