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

This commit is contained in:
Greg Gauthier 2026-06-06 08:00:04 +01:00
parent f3d338ea4f
commit 6a3e1e8b53

View File

@ -79,28 +79,47 @@ jobs:
env:
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
set -euo pipefail
VERSION=${GITHUB_REF#refs/tags/}
GITEA_API=https://repos.gmgauthier.com/api/v1
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 "Content-Type: application/json" \
-d "{
\"tag_name\": \"${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.\"
}" > 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
name=$(basename "$asset")
mime="application/octet-stream"
[[ "$name" =~ \.tar\.gz$ ]] && mime="application/gzip"
[[ "$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 "Content-Type: ${mime}" \
--data-binary "@$asset"
done
echo "All assets uploaded successfully."