ci: fix tag versioning by fetching all tags in workflows

This commit is contained in:
2026-06-03 22:37:46 +02:00
parent e39f930cf9
commit 905f53c74e
2 changed files with 58 additions and 56 deletions
+29 -28
View File
@@ -33,34 +33,35 @@ jobs:
# 2. Tell buildx to create and use a builder with this rule # 2. Tell buildx to create and use a builder with this rule
docker buildx create --use --name local-http-builder --config buildkitd.toml docker buildx create --use --name local-http-builder --config buildkitd.toml
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
# Tells the action to use the local 'git' binary we just installed # Tells the action to use the local 'git' binary we just installed
set-safe-directory: 'true' set-safe-directory: 'true'
fetch-depth: 0
- name: Determine Version - name: Determine Version
run: | run: |
LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1) LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1)
if [ -z "$LATEST_TAG" ]; then if [ -z "$LATEST_TAG" ]; then
VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0" VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0"
else else
# Strip the 'v' if present and get the patch version # Strip the 'v' if present and get the patch version
PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3) PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3)
NEW_PATCH=$((PATCH + 1)) NEW_PATCH=$((PATCH + 1))
VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH" VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH"
fi fi
echo "VERSION=$VERSION" >> $GITHUB_ENV echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build Docker image - name: Build Docker image
run: | run: |
docker buildx build \ docker buildx build \
--platform linux/arm64 \ --platform linux/arm64 \
-t gitea.lan/jacobh2/babymonitor-backend:${{ env.VERSION }} \ -t gitea.lan/jacobh2/babymonitor-backend:${{ env.VERSION }} \
./backend \ ./backend \
--push --push
- name: Tag and Push Version - name: Tag and Push Version
run: | run: |
git tag $VERSION git tag $VERSION
git push origin $VERSION git push origin $VERSION
+29 -28
View File
@@ -33,34 +33,35 @@ jobs:
# 2. Tell buildx to create and use a builder with this rule # 2. Tell buildx to create and use a builder with this rule
docker buildx create --use --name local-http-builder --config buildkitd.toml docker buildx create --use --name local-http-builder --config buildkitd.toml
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
# Tells the action to use the local 'git' binary we just installed # Tells the action to use the local 'git' binary we just installed
set-safe-directory: 'true' set-safe-directory: 'true'
fetch-depth: 0
- name: Determine Version - name: Determine Version
run: | run: |
LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1) LATEST_TAG=$(git tag -l "v${{ env.MAJOR }}.${{ env.MINOR }}.*" | sort -V | tail -n 1)
if [ -z "$LATEST_TAG" ]; then if [ -z "$LATEST_TAG" ]; then
VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0" VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.0"
else else
# Strip the 'v' if present and get the patch version # Strip the 'v' if present and get the patch version
PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3) PATCH=$(echo "$LATEST_TAG" | sed 's/v//' | cut -d'.' -f3)
NEW_PATCH=$((PATCH + 1)) NEW_PATCH=$((PATCH + 1))
VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH" VERSION="v${{ env.MAJOR }}.${{ env.MINOR }}.$NEW_PATCH"
fi fi
echo "VERSION=$VERSION" >> $GITHUB_ENV echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build Docker image - name: Build Docker image
run: | run: |
docker buildx build \ docker buildx build \
--platform linux/arm64 \ --platform linux/arm64 \
-t gitea.lan/jacobh2/babymonitor-frontend:${{ env.VERSION }} \ -t gitea.lan/jacobh2/babymonitor-frontend:${{ env.VERSION }} \
./frontend \ ./frontend \
--push --push
- name: Tag and Push Version - name: Tag and Push Version
run: | run: |
git tag $VERSION git tag $VERSION
git push origin $VERSION git push origin $VERSION