Repository navigation
92 lines (75 loc) · 2.8 KB
/
Copy pathversion.yaml
File metadata and controls
92 lines (75 loc) · 2.8 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
name: Version Bump
on:
workflow_dispatch:
inputs:
bump_type:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
bump-version:
name: Bump Version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_SUBMODULE_ACCESS_TOKEN }}
- name: Bump version
id: version
run: |
python3 - "${{ inputs.bump_type }}" <<'PYEOF'
import re, sys
bump = sys.argv[1]
with open("pyproject.toml", "r") as f:
content = f.read()
match = re.search(r'version\s*=\s*"(\d+)\.(\d+)\.(\d+)"', content)
if not match:
print("ERROR: Could not find version in pyproject.toml")
sys.exit(1)
major, minor, patch = int(match.group(1)), int(match.group(2)), int(match.group(3))
old_version = f"{major}.{minor}.{patch}"
if bump == "patch":
patch += 1
elif bump == "minor":
minor += 1
patch = 0
elif bump == "major":
major += 1
minor = 0
patch = 0
new_version = f"{major}.{minor}.{patch}"
content = content.replace(f'version = "{old_version}"', f'version = "{new_version}"', 1)
with open("pyproject.toml", "w") as f:
f.write(content)
print(f"Bumped version: {old_version} -> {new_version}")
with open("$GITHUB_OUTPUT", "a") as f:
f.write(f"old_version={old_version}\n")
f.write(f"new_version={new_version}\n")
PYEOF
- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
git tag "v${{ steps.version.outputs.new_version }}"
git push origin master --tags
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GH_SUBMODULE_ACCESS_TOKEN }}
run: |
gh release create "v${{ steps.version.outputs.new_version }}" \
--title "v${{ steps.version.outputs.new_version }}" \
--generate-notes
- name: Summary
run: |
echo "Version bumped: ${{ steps.version.outputs.old_version }} → ${{ steps.version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
echo "Tag: v${{ steps.version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
echo "Release created — production build will trigger automatically." >> $GITHUB_STEP_SUMMARY