Skip to content

Commit 473fe75

Browse files
ymodlinclaude
andcommitted
Add auto-tag daily version bump workflow
Runs daily at 14:00 UTC (~17:00 Tel Aviv) and on manual dispatch. Bumps the MODULE_VERSION build number in d4xx.c and creates an annotated tag when meaningful changes exist on dev since the last tag. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e0d0043 commit 473fe75

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

.github/workflows/auto-tag.yml

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

0 commit comments

Comments
 (0)