@@ -16,10 +16,35 @@ jobs:
1616 uses : ./.github/workflows/test-build.yml
1717 secrets : inherit
1818
19+ # Detect if this is a version release commit (e.g., "v0.5.24: ...")
20+ detect-version :
21+ name : Detect Version
22+ runs-on : blacksmith-4vcpu-ubuntu-2404
23+ if : github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
24+ outputs :
25+ version : ${{ steps.extract.outputs.version }}
26+ is_release : ${{ steps.extract.outputs.is_release }}
27+ steps :
28+ - name : Extract version from commit message
29+ id : extract
30+ run : |
31+ COMMIT_MSG="${{ github.event.head_commit.message }}"
32+ # Only tag versions on main branch
33+ if [ "${{ github.ref }}" = "refs/heads/main" ] && [[ "$COMMIT_MSG" =~ ^(v[0-9]+\.[0-9]+\.[0-9]+): ]]; then
34+ VERSION="${BASH_REMATCH[1]}"
35+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
36+ echo "is_release=true" >> $GITHUB_OUTPUT
37+ echo "✅ Detected release commit: ${VERSION}"
38+ else
39+ echo "version=" >> $GITHUB_OUTPUT
40+ echo "is_release=false" >> $GITHUB_OUTPUT
41+ echo "ℹ️ Not a release commit"
42+ fi
43+
1944 # Build AMD64 images and push to ECR immediately (+ GHCR for main)
2045 build-amd64 :
2146 name : Build AMD64
22- needs : test-build
47+ needs : [ test-build, detect-version]
2348 if : github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
2449 runs-on : blacksmith-8vcpu-ubuntu-2404
2550 permissions :
@@ -93,6 +118,14 @@ jobs:
93118 GHCR_AMD64="${GHCR_IMAGE}:latest-amd64"
94119 GHCR_SHA="${GHCR_IMAGE}:${{ github.sha }}-amd64"
95120 TAGS="${TAGS},$GHCR_AMD64,$GHCR_SHA"
121+
122+ # Add version tag if this is a release commit
123+ if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
124+ VERSION="${{ needs.detect-version.outputs.version }}"
125+ GHCR_VERSION="${GHCR_IMAGE}:${VERSION}-amd64"
126+ TAGS="${TAGS},$GHCR_VERSION"
127+ echo "📦 Adding version tag: ${VERSION}-amd64"
128+ fi
96129 fi
97130
98131 echo "tags=${TAGS}" >> $GITHUB_OUTPUT
@@ -111,7 +144,7 @@ jobs:
111144 # Build ARM64 images for GHCR (main branch only, runs in parallel)
112145 build-ghcr-arm64 :
113146 name : Build ARM64 (GHCR Only)
114- needs : test-build
147+ needs : [ test-build, detect-version]
115148 runs-on : blacksmith-8vcpu-ubuntu-2404-arm
116149 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
117150 permissions :
@@ -146,7 +179,16 @@ jobs:
146179 id : meta
147180 run : |
148181 IMAGE="${{ matrix.image }}"
149- echo "tags=${IMAGE}:latest-arm64,${IMAGE}:${{ github.sha }}-arm64" >> $GITHUB_OUTPUT
182+ TAGS="${IMAGE}:latest-arm64,${IMAGE}:${{ github.sha }}-arm64"
183+
184+ # Add version tag if this is a release commit
185+ if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
186+ VERSION="${{ needs.detect-version.outputs.version }}"
187+ TAGS="${TAGS},${IMAGE}:${VERSION}-arm64"
188+ echo "📦 Adding version tag: ${VERSION}-arm64"
189+ fi
190+
191+ echo "tags=${TAGS}" >> $GITHUB_OUTPUT
150192
151193 - name : Build and push ARM64 to GHCR
152194 uses : useblacksmith/build-push-action@v2
@@ -162,8 +204,8 @@ jobs:
162204 # Create GHCR multi-arch manifests (only for main, after both builds)
163205 create-ghcr-manifests :
164206 name : Create GHCR Manifests
165- runs-on : blacksmith-8vcpu -ubuntu-2404
166- needs : [build-amd64, build-ghcr-arm64]
207+ runs-on : blacksmith-2vcpu -ubuntu-2404
208+ needs : [build-amd64, build-ghcr-arm64, detect-version ]
167209 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
168210 permissions :
169211 packages : write
@@ -198,6 +240,16 @@ jobs:
198240 "${IMAGE_BASE}:${{ github.sha }}-arm64"
199241 docker manifest push "${IMAGE_BASE}:${{ github.sha }}"
200242
243+ # Create version manifest if this is a release commit
244+ if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
245+ VERSION="${{ needs.detect-version.outputs.version }}"
246+ echo "📦 Creating version manifest: ${VERSION}"
247+ docker manifest create "${IMAGE_BASE}:${VERSION}" \
248+ "${IMAGE_BASE}:${VERSION}-amd64" \
249+ "${IMAGE_BASE}:${VERSION}-arm64"
250+ docker manifest push "${IMAGE_BASE}:${VERSION}"
251+ fi
252+
201253 # Check if docs changed
202254 check-docs-changes :
203255 name : Check Docs Changes
0 commit comments