@@ -79,10 +79,10 @@ jobs:
7979 python3 scripts/test_localpibox.py
8080
8181 # ──────────────────────────────────────────────────────
82- # Phase 2: Bump version + create tags
82+ # Phase 2: Bump version (before build, so build uses correct number)
8383 # ──────────────────────────────────────────────────────
8484 bump-version :
85- name : Bump version & create tags
85+ name : Bump version
8686 runs-on : ubuntu-latest
8787 needs : [test-lpb]
8888 if : ${{ github.event_name != 'pull_request' }}
@@ -94,17 +94,10 @@ jobs:
9494 with :
9595 fetch-depth : 0
9696
97- - name : Set version for build jobs
98- id : set-version
99- run : |
100- VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0-lpb")
101- echo "version=$VERSION" >> "$GITHUB_OUTPUT"
102-
10397 - name : Bump patch version
10498 id : bump
10599 run : |
106100 set -e
107- # Read current VERSION from repo (set by previous CI bump)
108101 VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0-lpb")
109102 PATCH=$(echo "$VERSION" | sed 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/')
110103 NEW_PATCH=$((PATCH + 1))
@@ -120,52 +113,16 @@ jobs:
120113 echo "Bumping $VERSION → $NEW_VERSION"
121114 echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
122115
123- # Persist bumped version back to repo (VERSION/lpb.stack.env excluded
124- # from CI paths filter, so this won't trigger a new CI run)
116+ # Persist bumped version (excluded from CI paths, won't re-trigger)
125117 echo "$NEW_VERSION" > VERSION
126118 sed -i "s/^LPB_PI_REF=.*/LPB_PI_REF=$NEW_VERSION/" lpb.stack.env
127119 git config user.name "ci-localpibox"
128120 git config user.email "ci@localpibox.dev"
129121 git add VERSION lpb.stack.env
130122 git commit -m "chore: bump VERSION $NEW_VERSION" || echo "Nothing to commit"
123+ git commit -m "chore: bump VERSION $NEW_VERSION" || echo "Nothing to commit"
131124 git push origin dev --force-with-lease || echo "Push failed (already up-to-date)"
132125
133- - name : Create tags on all repos
134- env :
135- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
136- VERSION : ${{ steps.bump.outputs.version }}
137- GH_TOKEN : ${{ secrets.LOCALPIBOX_PAT }}
138- run : |
139- set -e
140- # repo -> default branch mapping
141- declare -A REPO_BRANCHS=(
142- ["localpibox/pi"]="lpb-dev"
143- ["localpibox/pi-subagents"]="lpb-dev"
144- ["localpibox/lemonade-pi-plugin"]="lpb-dev"
145- ["localpibox/config"]="dev"
146- ["localpibox/lpb-memory"]="dev"
147- )
148- for repo in "${!REPO_BRANCHS[@]}"; do
149- branch="${REPO_BRANCHS[$repo]}"
150- echo "Tagging $repo@$VERSION (from $branch)"
151- sha=$(git ls-remote "https://github.com/$repo.git" "refs/heads/$branch" | awk '{print $1}')
152- if [ -n "$sha" ]; then
153- # POST to /git/refs with {ref, sha} body (NOT /git/refs/tags/{tagname})
154- status=$(curl -s -o /dev/null -w '%{http_code}' \
155- -X POST "https://api.github.com/repos/$repo/git/refs" \
156- -H "Authorization: token $GH_TOKEN" \
157- -H "Accept: application/vnd.github+json" \
158- -d "{\"ref\": \"refs/tags/$VERSION\", \"sha\": \"$sha\"}")
159- if [ "$status" = "201" ] || [ "$status" = "422" ]; then
160- echo " ✅ $repo@$VERSION"
161- else
162- echo " ⚠️ $repo tag creation failed (HTTP $status)"
163- fi
164- else
165- echo " ⚠️ $repo:$branch not found, skipping tag"
166- fi
167- done
168-
169126 # ──────────────────────────────────────────────────────
170127 # Phase 3: Build & publish images
171128 # ──────────────────────────────────────────────────────
@@ -320,6 +277,51 @@ jobs:
320277 provenance : false
321278 platforms : linux/amd64
322279
280+ # ──────────────────────────────────────────────────────
281+ # Phase 4: Tag repos on success (only after build passes)
282+ # ──────────────────────────────────────────────────────
283+ tag-repos :
284+ name : Tag all repos
285+ runs-on : ubuntu-latest
286+ needs : [build-cli, build-web]
287+ if : ${{ github.event_name != 'pull_request' && needs.build-cli.result == 'success' && needs.build-web.result == 'success' }}
288+ steps :
289+ - name : Create tags on all repos
290+ env :
291+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
292+ VERSION : ${{ needs.bump-version.outputs.version }}
293+ GH_TOKEN : ${{ secrets.LOCALPIBOX_PAT }}
294+ run : |
295+ set -e
296+ # repo -> default branch mapping
297+ declare -A REPO_BRANCHS=(
298+ ["localpibox/pi"]="lpb-dev"
299+ ["localpibox/pi-subagents"]="lpb-dev"
300+ ["localpibox/lemonade-pi-plugin"]="lpb-dev"
301+ ["localpibox/config"]="dev"
302+ ["localpibox/lpb-memory"]="dev"
303+ )
304+ for repo in "${!REPO_BRANCHS[@]}"; do
305+ branch="${REPO_BRANCHS[$repo]}"
306+ echo "Tagging $repo@$VERSION (from $branch)"
307+ sha=$(git ls-remote "https://github.com/$repo.git" "refs/heads/$branch" | awk '{print $1}')
308+ if [ -n "$sha" ]; then
309+ # POST to /git/refs with {ref, sha} body (NOT /git/refs/tags/{tagname})
310+ status=$(curl -s -o /dev/null -w '%{http_code}' \
311+ -X POST "https://api.github.com/repos/$repo/git/refs" \
312+ -H "Authorization: token $GH_TOKEN" \
313+ -H "Accept: application/vnd.github+json" \
314+ -d "{\"ref\": \"refs/tags/$VERSION\", \"sha\": \"$sha\"}")
315+ if [ "$status" = "201" ] || [ "$status" = "422" ]; then
316+ echo " ✅ $repo@$VERSION"
317+ else
318+ echo " ⚠️ $repo tag creation failed (HTTP $status)"
319+ fi
320+ else
321+ echo " ⚠️ $repo:$branch not found, skipping tag"
322+ fi
323+ done
324+
323325 status :
324326 name : Build status
325327 needs : [build-cli, build-web]
0 commit comments