fix(release): add robust error handling, --fail, set -euo pipefail, RELEASE_ID validation, and debug output to Create Release step so failures are visible instead of silently passing
Some checks failed
gobuild / build (push) Failing after 6s
Some checks failed
gobuild / build (push) Failing after 6s
This commit is contained in:
parent
f3d338ea4f
commit
6a3e1e8b53
@ -79,28 +79,47 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
GITEA_API=https://repos.gmgauthier.com/api/v1
|
GITEA_API=https://repos.gmgauthier.com/api/v1
|
||||||
REPO=${GITHUB_REPOSITORY}
|
REPO=${GITHUB_REPOSITORY}
|
||||||
|
|
||||||
curl -X POST "${GITEA_API}/repos/${REPO}/releases" \
|
echo "Creating release for tag ${VERSION} on ${REPO}..."
|
||||||
|
|
||||||
|
curl --fail --silent --show-error -X POST "${GITEA_API}/repos/${REPO}/releases" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"${VERSION}\",
|
\"tag_name\": \"${VERSION}\",
|
||||||
\"name\": \"gostations ${VERSION}\",
|
\"name\": \"gostations ${VERSION}\",
|
||||||
|
\"target\": \"${GITHUB_SHA}\",
|
||||||
|
\"draft\": false,
|
||||||
\"body\": \"## Quick Install\n\n### Bash (Linux/macOS)\n\n\`\`\`bash\ncurl -L https://repos.gmgauthier.com/${REPO}/releases/download/${VERSION}/gostations-install.sh | VERSION=${VERSION} bash\n\`\`\`\n\n### PowerShell (Windows/macOS/Linux)\n\n\`\`\`powershell\nirm https://repos.gmgauthier.com/${REPO}/releases/download/${VERSION}/gostations-install.ps1 | iex\n\`\`\`\n\nPlatform binaries (tar.gz) + checksums.txt are attached. See README.md and CHANGELOG (if present) for details. Legacy wmenu UI still available with --legacy.\"
|
\"body\": \"## Quick Install\n\n### Bash (Linux/macOS)\n\n\`\`\`bash\ncurl -L https://repos.gmgauthier.com/${REPO}/releases/download/${VERSION}/gostations-install.sh | VERSION=${VERSION} bash\n\`\`\`\n\n### PowerShell (Windows/macOS/Linux)\n\n\`\`\`powershell\nirm https://repos.gmgauthier.com/${REPO}/releases/download/${VERSION}/gostations-install.ps1 | iex\n\`\`\`\n\nPlatform binaries (tar.gz) + checksums.txt are attached. See README.md and CHANGELOG (if present) for details. Legacy wmenu UI still available with --legacy.\"
|
||||||
}" > release.json
|
}" > release.json
|
||||||
|
|
||||||
RELEASE_ID=$(jq .id release.json)
|
echo "Release creation response:"
|
||||||
|
cat release.json
|
||||||
|
|
||||||
|
RELEASE_ID=$(jq -r '.id // empty' release.json)
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "ERROR: Failed to create release. No release ID returned. Check the response above and your RELEASE_TOKEN secret (must have 'repo' scope and write access)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release created with ID: $RELEASE_ID"
|
||||||
|
|
||||||
for asset in build/* ; do
|
for asset in build/* ; do
|
||||||
name=$(basename "$asset")
|
name=$(basename "$asset")
|
||||||
mime="application/octet-stream"
|
mime="application/octet-stream"
|
||||||
[[ "$name" =~ \.tar\.gz$ ]] && mime="application/gzip"
|
[[ "$name" =~ \.tar\.gz$ ]] && mime="application/gzip"
|
||||||
[[ "$name" =~ \.(txt|sh|ps1)$ ]] && mime="text/plain"
|
[[ "$name" =~ \.(txt|sh|ps1)$ ]] && mime="text/plain"
|
||||||
curl -X POST "${GITEA_API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${name}" \
|
echo "Uploading asset: $name"
|
||||||
|
curl --fail --silent --show-error -X POST "${GITEA_API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${name}" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: ${mime}" \
|
-H "Content-Type: ${mime}" \
|
||||||
--data-binary "@$asset"
|
--data-binary "@$asset"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "All assets uploaded successfully."
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user