ci(release): auto-detect staging/prod host and use dynamic URLs
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:
parent
d545a9bd08
commit
0ed00f6abb
@ -78,15 +78,28 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
STAGING_HOST: ${{ variables.STAGING_HOST }}
|
STAGING_HOST: ${{ vars.STAGING_HOST }}
|
||||||
PROD_HOST: ${{ variables.PROD_HOST }}
|
PROD_HOST: ${{ vars.PROD_HOST }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# If staging:
|
# GITHUB_SERVER_URL is injected by Gitea and points at the instance
|
||||||
HOST=${STAGING_HOST}
|
# actually running this job. Strip scheme + any path to get the host.
|
||||||
# If Prod:
|
SERVER_HOST=${GITHUB_SERVER_URL#http://}
|
||||||
# HOST=${PROD_HOST}
|
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/}
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
GITEA_API=https://${HOST}/api/v1
|
GITEA_API=https://${HOST}/api/v1
|
||||||
@ -102,7 +115,7 @@ jobs:
|
|||||||
\"name\": \"gostations ${VERSION}\",
|
\"name\": \"gostations ${VERSION}\",
|
||||||
\"target\": \"${GITHUB_SHA}\",
|
\"target\": \"${GITHUB_SHA}\",
|
||||||
\"draft\": false,
|
\"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
|
}" > release.json
|
||||||
|
|
||||||
echo "Release creation response:"
|
echo "Release creation response:"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user