From 437472be8578a66970582bb9741ba7ebc4ea69b8 Mon Sep 17 00:00:00 2001 From: Chaim Date: Mon, 13 Apr 2026 19:15:02 +0000 Subject: [PATCH] Add build number and semver tags to CI images Every push to main tags with latest + build-N (run number). Pushing a git tag like v1.0.0 also tags the image with that version. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitea/workflows/deploy.yaml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 3253878..da8f230 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -3,6 +3,7 @@ name: Build & Deploy on: push: branches: [main] + tags: ["v*"] env: REGISTRY: gitea.nautilus.marcusgroup.org @@ -21,13 +22,34 @@ jobs: docker login ${{ env.REGISTRY }} \ -u "${{ secrets.REGISTRY_USER }}" --password-stdin - - name: Build and push image + - name: Build and tag image run: | - TAG="${{ env.REGISTRY }}/${{ env.IMAGE }}:latest" - SHA_TAG="${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}" - docker build -t "$TAG" -t "$SHA_TAG" . - docker push "$TAG" - docker push "$SHA_TAG" + BASE="${{ env.REGISTRY }}/${{ env.IMAGE }}" + TAGS="-t ${BASE}:latest -t ${BASE}:build-${{ github.run_number }}" + + # If this is a version tag (v*), add the semver tag + REF="${{ github.ref }}" + if [[ "$REF" == refs/tags/v* ]]; then + VERSION="${REF#refs/tags/}" + TAGS="$TAGS -t ${BASE}:${VERSION}" + echo "📦 Release: ${VERSION}" + fi + + echo "🏗️ Building with tags: build-${{ github.run_number }}, latest" + docker build $TAGS . + + - name: Push image + run: | + BASE="${{ env.REGISTRY }}/${{ env.IMAGE }}" + docker push "${BASE}:latest" + docker push "${BASE}:build-${{ github.run_number }}" + + REF="${{ github.ref }}" + if [[ "$REF" == refs/tags/v* ]]; then + VERSION="${REF#refs/tags/}" + docker push "${BASE}:${VERSION}" + echo "✅ Pushed ${VERSION}" + fi - name: Trigger Coolify redeploy run: |