-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (81 loc) · 3.28 KB
/
bump.yaml
File metadata and controls
95 lines (81 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Bump version
on:
workflow_dispatch:
inputs:
bump_rule:
type: choice
description: How to bump the project's version (see https://docs.astral.sh/uv/reference/cli/#uv-version)
options:
- patch
- minor
- major
- stable
- alpha
- beta
- rc
- post
- dev
required: true
jobs:
bump_version:
name: "Bump version and create changelog"
if: "!startsWith(github.event.head_commit.message, 'bump:')"
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
env:
CI_COMMIT_EMAIL: "ci-runner@example-fgen-basic.invalid"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
uv-dependency-install-flags: "--all-extras --group 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\.post]*\)"/\1/p' pyproject.toml`
echo "Bumping from version $BASE_VERSION"
# Bump
uv version --no-sync --bump ${{ github.event.inputs.bump_rule }}
# Create a copy of pyproject.toml which we can use for restoring
cp pyproject.toml pyproject-dev.toml
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml`
echo "Bumping to version $NEW_VERSION"
# Build CHANGELOG
uv run --no-sync towncrier build --yes --version v$NEW_VERSION
# Add locked targets to pyproject.toml
uv run --no-sync python scripts/add-locked-targets-to-pyproject-toml.py
# Propogate new version to meson.build
uv run --no-sync python scripts/propogate-pyproject-metadata.py
# Update all the lock files
git add .
uv sync --no-editable --all-extras --group all-dev
uv run --no-sync pre-commit run --all-files || git add .
# Make sure that we're now in a 'good' state
uv run --no-sync pre-commit run --all-files
# 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\.]*\)"/\1/p' pyproject.toml`
# Put pyproject.toml back
mv pyproject-dev.toml pyproject.toml
# Bump to pre-release of next version
uv version --no-sync --bump post
# Propogate dev version back to meson.build
uv run --no-sync python scripts/propogate-pyproject-metadata.py
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml`
echo "Bumping version $BASE_VERSION > $NEW_VERSION"
# Commit and push
git commit -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION"
git push