Skip to content

Bump version

Bump version #31

Workflow file for this run

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: Check out 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"
# Freeze the environment again
# x-ref: https://github.com/climate-resource/input4mips_validation/issues/35
pixi install
pdm lock --strategy=inherit_metadata --dev --group :all
# Commit and push
git commit -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION"
git push