diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml new file mode 100644 index 0000000..f61b45c --- /dev/null +++ b/.github/workflows/auto-tag.yml @@ -0,0 +1,40 @@ +name: Auto Tag on Version Bump + +on: + push: + branches: + - master + paths: + - VERSION + +jobs: + tag-repo: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out repository + uses: actions/checkout@v5 + + - name: Get current version + id: version + run: | + VERSION=$(cat VERSION) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Check if tag already exists + id: checktag + run: | + if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then + echo "skip=true" >> $GITHUB_OUTPUT + else + echo "skip=false" >> $GITHUB_OUTPUT + fi + + - name: Push tag + if: steps.checktag.outputs.skip == 'false' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git tag "v${{ steps.version.outputs.version }}" + git push origin "v${{ steps.version.outputs.version }}"