From c97798261fa4b592ba30fd57b234d20a1790eeb9 Mon Sep 17 00:00:00 2001 From: e133736 Date: Wed, 11 Jun 2025 11:22:20 -0500 Subject: [PATCH] Add GitHub Actions workflow for automatic tagging on master merge --- .github/workflows/auto-tag.yml | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/auto-tag.yml diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml new file mode 100644 index 00000000..96cfdd1c --- /dev/null +++ b/.github/workflows/auto-tag.yml @@ -0,0 +1,41 @@ +name: Auto Tag on Master Merge + +on: + push: + branches: + - master + - main + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get version from package.json + id: package-version + run: | + VERSION=$(node -p "require('./package.json').version") + echo "version=v$VERSION" >> $GITHUB_OUTPUT + + - name: Check if tag exists + id: check-tag + run: | + if git rev-parse "${{ steps.package-version.outputs.version }}" >/dev/null 2>&1; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + + - name: Create tag + if: steps.check-tag.outputs.exists == 'false' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "${{ steps.package-version.outputs.version }}" -m "Release ${{ steps.package-version.outputs.version }}" + git push origin "${{ steps.package-version.outputs.version }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}