|
| 1 | +name: Bump version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump_rule: |
| 7 | + type: choice |
| 8 | + description: How to bump the project's version (see https://docs.astral.sh/uv/reference/cli/#uv-version) |
| 9 | + options: |
| 10 | + - patch |
| 11 | + - minor |
| 12 | + - major |
| 13 | + - stable |
| 14 | + - alpha |
| 15 | + - beta |
| 16 | + - rc |
| 17 | + - post |
| 18 | + - dev |
| 19 | + required: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + bump_version: |
| 23 | + name: "Bump version and create changelog" |
| 24 | + if: "!startsWith(github.event.head_commit.message, 'bump:')" |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + os: [ "ubuntu-latest" ] |
| 28 | + python-version: [ "3.11" ] |
| 29 | + runs-on: "${{ matrix.os }}" |
| 30 | + env: |
| 31 | + CI_COMMIT_EMAIL: "[email protected]" |
| 32 | + steps: |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" |
| 38 | + |
| 39 | + - uses: ./.github/actions/setup |
| 40 | + with: |
| 41 | + python-version: ${{ matrix.python-version }} |
| 42 | + uv-dependency-install-flags: "--all-extras --group dev" |
| 43 | + |
| 44 | + - name: Create bump and changelog |
| 45 | + run: | |
| 46 | + git config --global user.name "$GITHUB_ACTOR" |
| 47 | + git config --global user.email "$CI_COMMIT_EMAIL" |
| 48 | +
|
| 49 | + BASE_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml` |
| 50 | + echo "Bumping from version $BASE_VERSION" |
| 51 | +
|
| 52 | + # Bump |
| 53 | + uv version --bump ${{ github.event.inputs.bump_rule }} |
| 54 | +
|
| 55 | + NEW_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml` |
| 56 | + echo "Bumping to version $NEW_VERSION" |
| 57 | +
|
| 58 | + # Build CHANGELOG |
| 59 | + uv run towncrier build --yes --version v$NEW_VERSION |
| 60 | +
|
| 61 | + # Commit, tag and push |
| 62 | + git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION" |
| 63 | + git tag v$NEW_VERSION |
| 64 | + git push && git push --tags |
| 65 | +
|
| 66 | + # Bump to alpha (so that future commits do not have the same |
| 67 | + # version as the tagged commit) |
| 68 | + BASE_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml` |
| 69 | +
|
| 70 | + # Bump to pre-release of next version |
| 71 | + uv version --bump post |
| 72 | +
|
| 73 | + NEW_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml` |
| 74 | + echo "Bumping version $BASE_VERSION > $NEW_VERSION" |
| 75 | +
|
| 76 | + # Commit and push |
| 77 | + git commit -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION" |
| 78 | + git push |
0 commit comments