From 905f53c74e572552e61c2490b95988d9dced0c1c Mon Sep 17 00:00:00 2001 From: Jacob Hagstedt Date: Wed, 3 Jun 2026 22:37:46 +0200 Subject: [PATCH] ci: fix tag versioning by fetching all tags in workflows --- .gitea/workflows/backend.yml | 57 ++++++++++++++++++----------------- .gitea/workflows/frontend.yml | 57 ++++++++++++++++++----------------- 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/.gitea/workflows/backend.yml b/.gitea/workflows/backend.yml index cd22c40..6261641 100644 --- a/.gitea/workflows/backend.yml +++ b/.gitea/workflows/backend.yml @@ -33,34 +33,35 @@ jobs: # 2. Tell buildx to create and use a builder with this rule docker buildx create --use --name local-http-builder --config buildkitd.toml - - name: Checkout - uses: actions/checkout@v3 - with: - # Tells the action to use the local 'git' binary we just installed - set-safe-directory: 'true' + - name: Checkout + uses: actions/checkout@v3 + with: + # Tells the action to use the local 'git' binary we just installed + set-safe-directory: 'true' + fetch-depth: 0 - - name: Determine Version - run: | - LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1) - if [ -z "$LATEST_TAG" ]; then - VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0" - else - # Strip the 'v' if present and get the patch version - PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3) - NEW_PATCH=$((PATCH + 1)) - VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH" - fi - echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Determine Version + run: | + LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1) + if [ -z "$LATEST_TAG" ]; then + VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0" + else + # Strip the 'v' if present and get the patch version + PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3) + NEW_PATCH=$((PATCH + 1)) + VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH" + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV - - name: Build Docker image - run: | - docker buildx build \ - --platform linux/arm64 \ - -t gitea.lan/jacobh2/babymonitor-backend:${{ env.VERSION }} \ - ./backend \ - --push + - name: Build Docker image + run: | + docker buildx build \ + --platform linux/arm64 \ + -t gitea.lan/jacobh2/babymonitor-backend:${{ env.VERSION }} \ + ./backend \ + --push - - name: Tag and Push Version - run: | - git tag $VERSION - git push origin $VERSION + - name: Tag and Push Version + run: | +git tag $VERSION +git push origin $VERSION diff --git a/.gitea/workflows/frontend.yml b/.gitea/workflows/frontend.yml index 0403a35..dc4fb0a 100644 --- a/.gitea/workflows/frontend.yml +++ b/.gitea/workflows/frontend.yml @@ -33,34 +33,35 @@ jobs: # 2. Tell buildx to create and use a builder with this rule docker buildx create --use --name local-http-builder --config buildkitd.toml - - name: Checkout - uses: actions/checkout@v3 - with: - # Tells the action to use the local 'git' binary we just installed - set-safe-directory: 'true' + - name: Checkout + uses: actions/checkout@v3 + with: + # Tells the action to use the local 'git' binary we just installed + set-safe-directory: 'true' + fetch-depth: 0 - - name: Determine Version - run: | - LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1) - if [ -z "$LATEST_TAG" ]; then - VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0" - else - # Strip the 'v' if present and get the patch version - PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3) - NEW_PATCH=$((PATCH + 1)) - VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH" - fi - echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Determine Version + run: | + LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1) + if [ -z "$LATEST_TAG" ]; then + VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0" + else + # Strip the 'v' if present and get the patch version + PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3) + NEW_PATCH=$((PATCH + 1)) + VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH" + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV - - name: Build Docker image - run: | - docker buildx build \ - --platform linux/arm64 \ - -t gitea.lan/jacobh2/babymonitor-frontend:${{ env.VERSION }} \ - ./frontend \ - --push + - name: Build Docker image + run: | + docker buildx build \ + --platform linux/arm64 \ + -t gitea.lan/jacobh2/babymonitor-frontend:${{ env.VERSION }} \ + ./frontend \ + --push - - name: Tag and Push Version - run: | - git tag $VERSION - git push origin $VERSION + - name: Tag and Push Version + run: | +git tag $VERSION +git push origin $VERSION