diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index b64d04e..7c6f070 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -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:"