Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersader committed Dec 10, 2024
1 parent 387b02a commit d7d8076
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,41 @@ jobs:
id: check_release
run: |
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.extract_data.outputs.version }})
if [ "$HTTP_STATUS" = "200" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete existing release and tag if found
if: steps.check_release.outputs.exists == 'true'
run: |
RELEASE_ID=$(curl -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.extract_data.outputs.version }} \
| jq -r .id)
# Delete the existing release
curl -s \
-X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID
# Delete the existing tag reference
curl -s \
-X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ steps.extract_data.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
id: create_release
Expand All @@ -83,4 +91,4 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: obsidian-vault-${{ steps.extract_data.outputs.version }}.zip
asset_name: obsidian-vault-${{ steps.extract_data.outputs.version }}.zip
asset_content_type: application/zip
asset_content_type: application/zip

0 comments on commit d7d8076

Please sign in to comment.