From 7af602e91723f8a1bb98126cf40ebb03cbe2efa6 Mon Sep 17 00:00:00 2001 From: Christian Roessner Date: Mon, 16 Sep 2024 10:32:05 +0200 Subject: [PATCH] Fix: Add version tag extraction to workflow Extracts major, minor, and patch versions from git tags and sets them as environment variables. Updates the Docker build and push step to tag images using these version components, ensuring better version management. Signed-off-by: Christian Roessner --- .github/workflows/docker-stable.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/docker-stable.yaml b/.github/workflows/docker-stable.yaml index a65510e1..a42a001c 100644 --- a/.github/workflows/docker-stable.yaml +++ b/.github/workflows/docker-stable.yaml @@ -24,6 +24,17 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GHCR_TOKEN }} + - name: Extract tag versions + id: extract_version + run: | + tag=${GITHUB_REF##*/} # gets the tag name, e.g., v1.2.3 + major=$(echo $tag | cut -d'.' -f1) + minor=$(echo $tag | cut -d'.' -f2) + patch=$(echo $tag | cut -d'.' -f3) + echo "major=${major}" >> $GITHUB_ENV + echo "minor=${minor}" >> $GITHUB_ENV + echo "patch=${patch}" >> $GITHUB_ENV- name: Build and push + - name: Build and push uses: docker/build-push-action@v5 with: @@ -33,4 +44,7 @@ jobs: push: true tags: | ghcr.io/${{ github.repository_owner }}/nauthilus:latest + ghcr.io/${{ github.repository_owner }}/nauthilus:${{ env.major }} + ghcr.io/${{ github.repository_owner }}/nauthilus:${{ env.major }}.${{ env.minor }} + ghcr.io/${{ github.repository_owner }}/nauthilus:${{ env.major }}.${{ env.minor }}.${{ env.patch }} outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Multi purpose authentication server