From 0a8c46e07f6f9d722c685efad1e670767c3fb908 Mon Sep 17 00:00:00 2001 From: Johannes Thiem Date: Thu, 18 Apr 2024 08:49:08 +0200 Subject: [PATCH] feat: verify tag with semver --- .github/workflows/docker-build.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 8f99309..657821f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -11,18 +11,25 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Check Version Format in Tag + if: startsWith(github.ref, 'refs/tags/v') + uses: nowsprinting/check-version-format-action@v4.0.2 + id: check-version + with: + prefix: 'v' + - name: Set tag id: set-tag run: | SHORT_SHA=$(git rev-parse --short HEAD) - TAG_VERSION=$(echo ${{ github.ref }} | sed 's,refs/tags/v,,g') - if [[ "${{ github.ref }}" == "refs/tags/v*" ]]; then - echo "::set-output name=tag1::latest" - echo "::set-output name=tag2::$TAG_VERSION" - else - echo "::set-output name=tag1::dev" - echo "::set-output name=tag2::commit-$SHORT_SHA" + TAG1="dev" + TAG2="commit-$SHORT_SHA" + if [[ "${{ steps.check-version.outputs.is_valid }}" == 'true' ]]; then + TAG1="latest" + TAG2="${{ steps.check-version.outputs.full_without_prefix }}" fi + echo "::set-output name=tag1::$TAG1" + echo "::set-output name=tag2::$TAG2" - name: Docker meta id: meta