88jobs :
99 release :
1010 runs-on : ubuntu-latest
11+ permissions :
12+ contents : write
13+ pull-requests : write
14+ issues : write
15+ checks : write
16+ statuses : write
1117 steps :
1218 - uses : actions/checkout@v4
19+ with :
20+ token : ${{ secrets.GITHUB_TOKEN }}
1321 - uses : actions/setup-node@v4
1422 - name : Check if version already exists
1523 id : version-check
24+ env :
25+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
1626 run : |
1727 package_version=$(node -p "require('./package.json').version")
18- exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "")
28+ exists=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
29+ -H "Accept: application/vnd.github.v3+json" \
30+ "https://api.github.com/repos/${{ github.repository }}/releases/tags/v$package_version" \
31+ | jq -r .message)
1932
20- if [ -n "$exists" ];
21- then
33+ if [ "$exists" != "Not Found" ]; then
2234 echo "Version v$package_version already exists"
2335 echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again."
2436 echo "skipped=true" >> $GITHUB_OUTPUT
2739 echo "skipped=false" >> $GITHUB_OUTPUT
2840 echo "tag=v$package_version" >> $GITHUB_OUTPUT
2941 fi
30- env :
31- GH_TOKEN : ${{ secrets.GH_TOKEN }}
3242 - name : Setup git
3343 if : ${{ steps.version-check.outputs.skipped == 'false' }}
3444 run : |
@@ -51,12 +61,20 @@ jobs:
5161 git pull --rebase
5262 git push origin ${{ github.ref_name }}
5363 fi
54- - name : Create Github Release
55- uses : ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
64+ - name : Create GitHub Release
5665 if : ${{ steps.version-check.outputs.skipped == 'false' }}
57- with :
58- name : ${{ steps.version-check.outputs.tag }}
59- tag : ${{ steps.version-check.outputs.tag }}
60- commit : ${{ github.ref_name }}
61- token : ${{ secrets.GH_TOKEN }}
62- skipIfReleaseExists : true
66+ env :
67+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
68+ run : |
69+ curl -X POST \
70+ -H "Authorization: token $GITHUB_TOKEN" \
71+ -H "Accept: application/vnd.github.v3+json" \
72+ https://api.github.com/repos/${{ github.repository }}/releases \
73+ -d '{
74+ "tag_name": "${{ steps.version-check.outputs.tag }}",
75+ "target_commitish": "${{ github.ref_name }}",
76+ "name": "${{ steps.version-check.outputs.tag }}",
77+ "body": "Release ${{ steps.version-check.outputs.tag }}",
78+ "draft": false,
79+ "prerelease": false
80+ }'
0 commit comments