-
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (63 loc) · 2.44 KB
/
bump-version-by-labels.yml
File metadata and controls
73 lines (63 loc) · 2.44 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
name: Bump Version By Labels
on:
pull_request:
types: [closed]
branches: [master]
jobs:
bump-version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.*"
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Determine version bump
id: detect-bump
run: |
# Check PR labels to determine bump type
LABELS="${{ github.event.pull_request.labels.*.name }}"
if echo "$LABELS" | grep -q "Major"; then
echo "bump_type=major" >> $env:GITHUB_OUTPUT
elif echo "$LABELS" | grep -q "Minor"; then
echo "bump_type=minor" >> $env:GITHUB_OUTPUT
elif echo "$LABELS" | grep -q "Patch"; then
echo "bump_type=patch" >> $env:GITHUB_OUTPUT
else
echo "bump_type=" >> $env:GITHUB_OUTPUT
fi
- name: Bump Version
if: steps.detect-bump.outputs.bump_type != ''
id: bump-version
run: |
uv run bump-my-version bump ${{ steps.detect-bump.outputs.bump_type }}
$NEW_VERSION = uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])"
echo "version-bumped=true" >> $env:GITHUB_OUTPUT
echo "new-version=$NEW_VERSION" >> $env:GITHUB_OUTPUT
- name: Create version bump PR
if: steps.bump-version.outputs.version-bumped == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
$BRANCH_NAME = "bump-version-${{ steps.bump-version.outputs.new-version }}"
git checkout -b "$BRANCH_NAME"
git add pyproject.toml
git commit -m "chore: bump version to ${{ steps.bump-version.outputs.new-version }}"
git push origin "$BRANCH_NAME"
gh pr create \
--title "chore: bump version to ${{ steps.bump-version.outputs.new-version }}" \
--body "Automated version bump to ${{ steps.bump-version.outputs.new-version }}" \
--base master \
--admin
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}