From 7f34ab76b8962c16ba2c2fb221eb49d710674e12 Mon Sep 17 00:00:00 2001 From: Arun Poudel Date: Thu, 19 Sep 2024 10:58:25 +0200 Subject: [PATCH] feat: tag release with vX (major) Github Actions/Workflow are usually tagged with v(major) alongside the primary version v(major).(minor).(patch) v(major) always follows the latest v(major).(minor).(patch) version. We have this in other workflows, but was missing here. --- .github/workflows/release-tagger.yaml | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/release-tagger.yaml diff --git a/.github/workflows/release-tagger.yaml b/.github/workflows/release-tagger.yaml new file mode 100644 index 0000000..118b63f --- /dev/null +++ b/.github/workflows/release-tagger.yaml @@ -0,0 +1,35 @@ +name: Release Tagger +on: + release: + types: + - released +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + tag: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Git + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + - name: Remove old tag and tag main with vX + run: | + git fetch --all + git checkout main + + # Extract vX from vX.Y.Z + NEW_TAG=$(echo "${{ github.event.release.tag_name }}" | cut -d'.' -f1) + + # Check if tag already exists and delete if it does + if git show-ref --tags $NEW_TAG; then + git tag -d $NEW_TAG + git push --delete origin $NEW_TAG + fi + + # Create new tag + git tag $NEW_TAG + git push origin refs/tags/$NEW_TAG