3030 - name : Get current date
3131 id : date
3232 run : echo "today=$(date +'%Y-%m-%d_%H%M%S')" >> $GITHUB_OUTPUT
33+ - name : Check for existing release
34+ id : check_release
35+ shell : bash
36+ run : |
37+ if release_details=$(gh release view "$RELEASE_TAG" --json tagName,name --jq '[.tagName, .name] | @tsv' 2>/dev/null); then
38+ IFS=$'\t' read -r existing_tag existing_name <<< "$release_details"
39+ if [[ "$existing_tag" != "$RELEASE_TAG" || "$existing_name" != "$RELEASE_NAME" ]]; then
40+ echo "::error::Release tag '$RELEASE_TAG' already exists with the name '$existing_name'; expected '$RELEASE_NAME'."
41+ exit 1
42+ fi
43+
44+ echo "release_exists=true" >> "$GITHUB_OUTPUT"
45+ echo "Release '$RELEASE_NAME' with tag '$RELEASE_TAG' already exists; only its artifacts will be updated."
46+ else
47+ echo "release_exists=false" >> "$GITHUB_OUTPUT"
48+ echo "Release '$RELEASE_NAME' with tag '$RELEASE_TAG' does not exist and will be created."
49+ fi
50+ env :
51+ GH_TOKEN : ${{ github.token }}
52+ RELEASE_TAG : ${{ steps.monkey365version.outputs.monkey365version }}
53+ RELEASE_NAME : ${{ steps.monkey365version.outputs.releasename }}
3354 - name : Create Release
3455 id : create_release
56+ if : steps.check_release.outputs.release_exists != 'true'
3557 run : >-
3658 gh release create "$RELEASE_TAG"
3759 --title "$RELEASE_NAME"
@@ -45,14 +67,15 @@ jobs:
4567 RELEASE_NOTES : Thanks for following [Monkey365](https://github.com/silverhack/monkey365)!
4668 # Create a zip of the folder
4769 - name : Create ZIP file of the folder
48- if : steps.create_release.outcome == 'success'
70+ if : steps.check_release.outputs.release_exists == 'true' || steps. create_release.outcome == 'success'
4971 run : |
5072 mkdir -p build
5173 git archive --format zip --prefix monkey365/ --add-file=LICENSE --output ./build/monkey365.zip main:src/monkey365
52- gh release upload ${{ steps.monkey365version.outputs.monkey365version }} . /build/monkey365.zip
74+ gh release upload "$RELEASE_TAG" . /build/monkey365.zip --clobber
5375 sha256sum ./build/monkey365.zip | awk '{print $1}' > ./build/monkey365.zip.sha256
54- gh release upload ${{ steps.monkey365version.outputs.monkey365version }} . /build/monkey365.zip.sha256
76+ gh release upload "$RELEASE_TAG" . /build/monkey365.zip.sha256 --clobber
5577 sha512sum ./build/monkey365.zip | awk '{print $1}' > ./build/monkey365.zip.sha512
56- gh release upload ${{ steps.monkey365version.outputs.monkey365version }} . /build/monkey365.zip.sha512
78+ gh release upload "$RELEASE_TAG" . /build/monkey365.zip.sha512 --clobber
5779 env :
58- GITHUB_TOKEN : ${{ github.TOKEN }}
80+ GH_TOKEN : ${{ github.token }}
81+ RELEASE_TAG : ${{ steps.monkey365version.outputs.monkey365version }}
0 commit comments