-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (44 loc) · 1.57 KB
/
version-bump.yml
File metadata and controls
55 lines (44 loc) · 1.57 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
# Automatically bump patch version on merge to main
name: Version Bump
permissions:
contents: write
on:
push:
branches:
- main
jobs:
bump-version:
runs-on: ubuntu-latest
# Skip if the commit message contains [skip ci] to avoid infinite loops
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump patch version
run: |
VERSION_FILE="docker/VERSION"
# Read current version
CURRENT_VERSION=$(cat "$VERSION_FILE" | tr -d '[:space:]')
echo "Current version: $CURRENT_VERSION"
# Split into components
IFS='.' read -ra PARTS <<< "$CURRENT_VERSION"
MAJOR="${PARTS[0]:-0}"
MINOR="${PARTS[1]:-0}"
PATCH="${PARTS[2]:-0}"
# Increment patch
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
echo "New version: $NEW_VERSION"
# Write new version
echo "$NEW_VERSION" > "$VERSION_FILE"
# Export for next step
echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
- name: Commit and push version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docker/VERSION
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
git push