-
Notifications
You must be signed in to change notification settings - Fork 94
52 lines (45 loc) · 1.62 KB
/
release-version-bump.yml
File metadata and controls
52 lines (45 loc) · 1.62 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
# When a branch named release/X.Y.Z is pushed, set version = "X.Y.Z" in setup.py and commit.
# Branch name must match release/X.Y.Z (e.g. release/3.14.7). Creates one commit if version changed.
name: Release version bump
on:
push:
branches:
- "release/*"
jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write # push commit to release branch
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Get version from branch name
id: version
run: |
BRANCH="${{ github.ref_name }}"
if [[ "$BRANCH" =~ ^release/(.+)$ ]]; then
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
else
echo "Branch name must be release/X.Y.Z"
exit 1
fi
- name: Update version in setup.py
run: |
VERSION="${{ steps.version.outputs.version }}"
sed -i 's/^version = ".*"/version = "'"$VERSION"'"/' setup.py
grep -q '^version = "'"$VERSION"'"' setup.py || (echo "Failed to update setup.py"; exit 1)
- name: Commit and push if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet setup.py; then
echo "Version already set, nothing to commit"
exit 0
fi
git add setup.py
git commit -m "chore: set version to ${{ steps.version.outputs.version }} [skip ci]"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}