ci(release): auto-detect staging/prod host and use dynamic URLs
All checks were successful
CI / Test (push) Successful in 53s
Release / Create Release (push) Successful in 2m7s
CI / Build (push) Successful in 40s

Replace deprecated `variables.` syntax with `vars.`, add logic to detect
the running environment from GITHUB_SERVER_URL, and update release body
URLs to use the detected HOST instead of a hardcoded domain.
This commit is contained in:
Greg Gauthier 2026-06-12 22:55:22 +01:00
parent d545a9bd08
commit 0ed00f6abb

View File

@ -78,15 +78,28 @@ jobs:
shell: bash
env:
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
STAGING_HOST: ${{ variables.STAGING_HOST }}
PROD_HOST: ${{ variables.PROD_HOST }}
STAGING_HOST: ${{ vars.STAGING_HOST }}
PROD_HOST: ${{ vars.PROD_HOST }}
run: |
set -euo pipefail
# If staging:
HOST=${STAGING_HOST}
# If Prod:
# HOST=${PROD_HOST}
# GITHUB_SERVER_URL is injected by Gitea and points at the instance
# actually running this job. Strip scheme + any path to get the host.
SERVER_HOST=${GITHUB_SERVER_URL#http://}
SERVER_HOST=${SERVER_HOST#https://}
SERVER_HOST=${SERVER_HOST%%/*}
# Pick the configured host variable matching the running environment.
case "$SERVER_HOST" in
"$PROD_HOST") HOST="$PROD_HOST" ;;
"$STAGING_HOST") HOST="$STAGING_HOST" ;;
*)
echo "ERROR: running on unrecognized host '${SERVER_HOST}'."
echo "Expected STAGING_HOST='${STAGING_HOST}' or PROD_HOST='${PROD_HOST}'."
exit 1
;;
esac
echo "Detected environment host: ${HOST}"
VERSION=${GITHUB_REF#refs/tags/}
GITEA_API=https://${HOST}/api/v1
@ -102,7 +115,7 @@ jobs:
\"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://${HOST}/${REPO}/releases/download/${VERSION}/gostations-install.sh | VERSION=${VERSION} bash\n\`\`\`\n\n### PowerShell (Windows/macOS/Linux)\n\n\`\`\`powershell\nirm https://${HOST}/${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
echo "Release creation response:"