Skip to content

Commit

Permalink
ci: optimizing the tag presence checking process
Browse files Browse the repository at this point in the history
  • Loading branch information
Suisuroru committed Jan 23, 2025
1 parent aae57c8 commit e3fee09
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/auto_build_jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ jobs:
- name: Check if tag exists
id: check_tag
run: |
GITHUB_REPOSITORY="${{ github.repository }}"
OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
TAG_EXISTS=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" https://api.github.com/repos/$OWNER/$REPO/git/refs/tags/${{ env.VERSION }} | jq -e '.ref' | wc -l)
OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1)
REPO=$(echo "${{ github.repository }}" | cut -d'/' -f2)
TAG_EXISTS=$(gh api -H "api.github.com" /repos/$OWNER/$REPO/git/refs/tags/${{ env.VERSION }} --jq '.ref' | wc -l)
if [ "$TAG_EXISTS" -eq 1 ]; then
echo "Tag exists"
echo "SKIP_BUILD=true" >> $GITHUB_ENV
else
echo "Tag does not exist"
echo "SKIP_BUILD=false" >> $GITHUB_ENV
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Update version in plugin.yml
if: env.SKIP_BUILD == 'false'
Expand Down

0 comments on commit e3fee09

Please sign in to comment.