diff --git a/.github/workflows/plugin-release.yaml b/.github/workflows/plugin-release.yaml index d8405a5..271ea55 100644 --- a/.github/workflows/plugin-release.yaml +++ b/.github/workflows/plugin-release.yaml @@ -39,8 +39,27 @@ jobs: with: node-version: ${{ inputs.node-version }} + check-tag: + runs-on: runners-privilegedescalation + outputs: + skip: ${{ steps.check.outputs.skip }} + steps: + - name: Check if tag already exists + id: check + run: | + HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ + -H "Authorization: Bearer ${{ github.token }}" \ + "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/v${{ inputs.version }}") + if [ "$HTTP_CODE" = "200" ]; then + echo "::notice::Tag v${{ inputs.version }} already exists. Release skipped (not an error)." + echo "skip=true" >> $GITHUB_OUTPUT + else + echo "skip=false" >> $GITHUB_OUTPUT + fi + release: - needs: ci + needs: [ci, check-tag] + if: needs.check-tag.outputs.skip != 'true' runs-on: runners-privilegedescalation timeout-minutes: 10 @@ -63,13 +82,6 @@ jobs: node-version: ${{ inputs.node-version }} cache: 'npm' - - name: Check tag does not already exist - run: | - if git tag -l "v${{ inputs.version }}" | grep -q "v${{ inputs.version }}"; then - echo "::error::Tag v${{ inputs.version }} already exists. Skipping duplicate release." - exit 1 - fi - - name: Configure Git run: | git config --global user.name "github-actions[bot]"