From a43d4f16a68c81382d06220520cb1dd90d8769d5 Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 6 Nov 2024 15:13:17 +0530 Subject: [PATCH] Updated workflow to release floating tags --- ...ocker-image-on-release.yml => release.yml} | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) rename .github/workflows/{create-docker-image-on-release.yml => release.yml} (52%) diff --git a/.github/workflows/create-docker-image-on-release.yml b/.github/workflows/release.yml similarity index 52% rename from .github/workflows/create-docker-image-on-release.yml rename to .github/workflows/release.yml index 8e2ec5d..c211afa 100644 --- a/.github/workflows/create-docker-image-on-release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Publish Docker Image to GHCR +name: Release new version on: release: @@ -37,3 +37,26 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + create-floating-tag: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set major version + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + + current_version=${{github.event.release.tag_name}} + if [[ ! "$current_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: current_version does not follow semantic versioning (vX.Y.Z)." + exit 1 + fi + + major_version="${version%%.*}" + git tag -d "$major_version" 2>/dev/null || echo "Tag $major_version not found." + git tag $major_version $current_version + git push origin $major_version --force \ No newline at end of file