From e0b50c0007c4f11d1879fc77b2b64ce8c3ebbd29 Mon Sep 17 00:00:00 2001 From: Maiko Sinkyaet Tan Date: Mon, 13 Nov 2023 14:28:32 +0800 Subject: [PATCH] ci: add tagger workflow (#118) * ci: add tagger workflow * ci: use new output style for github actions --- .github/workflows/tagger.yml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/tagger.yml diff --git a/.github/workflows/tagger.yml b/.github/workflows/tagger.yml new file mode 100644 index 000000000..b733a4955 --- /dev/null +++ b/.github/workflows/tagger.yml @@ -0,0 +1,43 @@ +name: Tagger + +on: + push: + branches: + - main + +jobs: + tagger: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Check current version + id: check_version + run: echo "VERSION=$(node -p "require('./packages/core/package.json').version")" >> $GITHUB_OUTPUT + + - name: Check remote tags + id: check_tags + run: | + git fetch --tags + echo "TAGS=$(git tag -l)" >> $GITHUB_OUTPUT + + - name: Check if tag exists + id: check_tag + run: | + if [[ "${{ steps.check_tags.outputs.TAGS }}" == *"${{ steps.check_version.outputs.VERSION }}"* ]]; then + echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT + else + echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT + fi + + - name: Push tag + if: ${{ github.ref == 'refs/heads/master' && steps.check_tag.outputs.TAG_EXISTS == 'false' }} + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git tag ${{ steps.check_version.outputs.VERSION }} + git push origin ${{ steps.check_version.outputs.VERSION }}