Skip to content

Commit 71dfa59

Browse files
ymodlinclaude
andauthored
Add auto-tag daily version bump workflow (#374)
Runs daily at 14:00 UTC (~17:00 Tel Aviv). Bumps MODULE_VERSION build number in d4xx.c and creates annotated tag when meaningful changes exist on dev since the last tag. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 882da75 commit 71dfa59

1 file changed

Lines changed: 144 additions & 0 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Auto-Tag Daily Version Bump
2+
3+
on:
4+
schedule:
5+
- cron: '0 14 * * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
bump-version:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout dev
17+
uses: actions/checkout@v4
18+
with:
19+
ref: dev
20+
fetch-depth: 0
21+
token: ${{ secrets.PAT_TOKEN }}
22+
23+
- name: Branch guard
24+
run: |
25+
branch=$(git rev-parse --abbrev-ref HEAD)
26+
if [ "$branch" != "dev" ]; then
27+
echo "::error::Expected branch 'dev', got '$branch'"
28+
exit 1
29+
fi
30+
31+
- name: Find latest tag
32+
id: latest_tag
33+
run: |
34+
tag=$(git tag --merged HEAD --sort=-v:refname | grep -E '^v[0-9]+\.' | head -1)
35+
if [ -z "$tag" ]; then
36+
echo "::error::No version tags found on dev. Create an initial tag manually (e.g., git tag -a v1.0.2.10 -m 'Initial tag')."
37+
exit 1
38+
fi
39+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
40+
echo "Found latest tag: $tag"
41+
42+
- name: Check for meaningful changes
43+
id: changes
44+
run: |
45+
tag="${{ steps.latest_tag.outputs.tag }}"
46+
changed=$(git diff --name-only "$tag"..HEAD)
47+
48+
if [ -z "$changed" ]; then
49+
echo "No changes since $tag"
50+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
51+
exit 0
52+
fi
53+
54+
# Filter out ignored paths
55+
meaningful=$(echo "$changed" | grep -v -E '^(\.claude/|\.github/|test/|docs/|scripts/|CLAUDE\.md$|\.gitignore$)' || true)
56+
57+
if [ -z "$meaningful" ]; then
58+
echo "Only ignored-folder changes since $tag:"
59+
echo "$changed"
60+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
61+
else
62+
echo "Meaningful changes since $tag:"
63+
echo "$meaningful"
64+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
65+
fi
66+
67+
- name: Parse current version
68+
if: steps.changes.outputs.has_changes == 'true'
69+
id: version
70+
run: |
71+
current=$(grep -oP 'MODULE_VERSION\("\K[^"]+' kernel/realsense/d4xx.c)
72+
if [ -z "$current" ]; then
73+
echo "::error::Could not parse MODULE_VERSION from d4xx.c"
74+
exit 1
75+
fi
76+
echo "current=$current" >> "$GITHUB_OUTPUT"
77+
echo "Current version: $current"
78+
79+
- name: Increment build number
80+
if: steps.changes.outputs.has_changes == 'true'
81+
id: bump
82+
run: |
83+
current="${{ steps.version.outputs.current }}"
84+
IFS='.' read -r major minor patch build <<< "$current"
85+
new_build=$((build + 1))
86+
new_version="${major}.${minor}.${patch}.${new_build}"
87+
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
88+
echo "new_tag=v${new_version}" >> "$GITHUB_OUTPUT"
89+
echo "Bumping: $current -> $new_version"
90+
91+
- name: Update d4xx.c
92+
if: steps.changes.outputs.has_changes == 'true'
93+
run: |
94+
current="${{ steps.version.outputs.current }}"
95+
new_version="${{ steps.bump.outputs.new_version }}"
96+
sed -i "s/MODULE_VERSION(\"${current}\")/MODULE_VERSION(\"${new_version}\")/" kernel/realsense/d4xx.c
97+
98+
# Verify the update
99+
updated=$(grep -oP 'MODULE_VERSION\("\K[^"]+' kernel/realsense/d4xx.c)
100+
if [ "$updated" != "$new_version" ]; then
101+
echo "::error::VERSION update failed. Expected '$new_version', got '$updated'"
102+
exit 1
103+
fi
104+
echo "d4xx.c updated to $new_version"
105+
106+
- name: Commit and tag
107+
if: steps.changes.outputs.has_changes == 'true'
108+
run: |
109+
new_version="${{ steps.bump.outputs.new_version }}"
110+
new_tag="${{ steps.bump.outputs.new_tag }}"
111+
112+
git config user.email "builder@example.com"
113+
git config user.name "builder"
114+
git add kernel/realsense/d4xx.c
115+
git commit -m "Bump version to ${new_version}"
116+
git tag -a "$new_tag" -m "Version ${new_version}"
117+
118+
- name: Push commit
119+
if: steps.changes.outputs.has_changes == 'true'
120+
run: git push origin dev
121+
122+
- name: Push tag
123+
if: steps.changes.outputs.has_changes == 'true'
124+
run: git push origin "${{ steps.bump.outputs.new_tag }}"
125+
126+
- name: Summary
127+
run: |
128+
if [ "${{ steps.changes.outputs.has_changes }}" == "true" ]; then
129+
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
130+
## Version Bump Completed
131+
132+
| | |
133+
|---|---|
134+
| **Previous tag** | \`${{ steps.latest_tag.outputs.tag }}\` |
135+
| **New version** | \`${{ steps.bump.outputs.new_version }}\` |
136+
| **New tag** | \`${{ steps.bump.outputs.new_tag }}\` |
137+
EOF
138+
else
139+
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
140+
## No Version Bump Needed
141+
142+
No meaningful changes since \`${{ steps.latest_tag.outputs.tag }}\`. Skipped.
143+
EOF
144+
fi

0 commit comments

Comments
 (0)