Tag builds since v0.2.2 built all artifacts but never published a release:
- tools/publish_release.sh only assembled AUTH in the GITEA_TOKEN branch; the
~/.git-credentials branch set CRED and then used an unbound ${AUTH[@]} under
`set -u`, so every API call failed and the job ended "could not create or find
release". It now sets AUTH=(-u "$CRED").
- The repo has no GITEA_TOKEN secret and the runner has no git credentials, so the
workflow now falls back to the built-in workflow token:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}.
v0.2.9 was then built and published locally with all five artifacts (portable
Linux/Windows/macOS, NSIS installer, AppImage) and the release page verified via
the API. v0.2.4-v0.2.8 remain unpublished; they are superseded by the latest.
Docs
- docs/RELEASING.md records the incident and the local-publish fallback.
- TODO gains a release-pipeline follow-up (verify CI on the next tag).
- MEMORY notes the root cause, the missing secret, and which releases exist.
- Version 0.2.10.
86 lines
2.9 KiB
Bash
Executable File
86 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Publish a release to the Gitea/Forgejo host, uploading the built artifacts.
|
|
#
|
|
# Requires:
|
|
# - GITEA_TOKEN (token with write access) OR credentials usable for basic auth
|
|
# (e.g. the same ones stored in ~/.git-credentials by `git push`)
|
|
# - build artifacts from tools/build_releases.sh (+ optional installer/AppImage)
|
|
#
|
|
# Usage:
|
|
# GITEA_TOKEN=xxx ./tools/publish_release.sh [version]
|
|
# (version defaults to config/version from project.godot)
|
|
set -euo pipefail
|
|
|
|
REPO="${REPO:-zwitschi/security-game}"
|
|
HOST="${HOST:-https://git.allucanget.biz}"
|
|
VERSION="${1:-$(grep -oP 'config/version="\K[^"]+' project.godot)}"
|
|
TAG="v$VERSION"
|
|
|
|
if [[ -n "${GITEA_TOKEN:-}" ]]; then
|
|
AUTH=("Authorization: token $GITEA_TOKEN")
|
|
elif [[ -f "$HOME/.git-credentials" ]]; then
|
|
CRED="$(python3 -c "
|
|
import os
|
|
for l in open(os.path.expanduser('~/.git-credentials')):
|
|
if '$HOST'.split('//')[1] in l:
|
|
print(l.split('://',1)[1].split('@')[0]); break")"
|
|
if [[ -z "$CRED" ]]; then
|
|
echo "error: no credentials for $HOST in ~/.git-credentials" >&2
|
|
exit 1
|
|
fi
|
|
# curl basic auth. (Previously only CRED was set, so ${AUTH[@]} was unbound
|
|
# under `set -u` and every API call failed silently.)
|
|
AUTH=(-u "$CRED")
|
|
else
|
|
echo "error: set GITEA_TOKEN or provide ~/.git-credentials" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Artifacts that must exist (run tools/build_releases.sh first).
|
|
portables=(
|
|
"build/step-line-linux-$VERSION.x86_64"
|
|
"build/step-line-windows-$VERSION.exe"
|
|
"build/step-line-macos-$VERSION.zip"
|
|
)
|
|
extras=(
|
|
"build/step-line-setup-$VERSION.exe"
|
|
"build/step-line-$VERSION-x86_64.AppImage"
|
|
)
|
|
all_artifacts=("${portables[@]}")
|
|
for f in "${extras[@]}"; do
|
|
if [[ -f "$f" ]]; then
|
|
all_artifacts+=("$f")
|
|
else
|
|
echo "note: optional artifact missing (skipping): $f"
|
|
fi
|
|
done
|
|
|
|
API="$HOST/api/v1/repos/$REPO/releases"
|
|
echo "==> Creating release $TAG on $HOST/$REPO"
|
|
RELEASE_ID="$(curl -s -X POST "$API" "${AUTH[@]}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Step Line $VERSION — playable prototype. See README for controls.\",\"draft\":false,\"prerelease\":false}" \
|
|
| python3 -c "import sys,json;print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)"
|
|
|
|
# If the release already exists (tag already pushed), reuse it.
|
|
if [[ -z "$RELEASE_ID" ]]; then
|
|
RELEASE_ID="$(curl -s "${AUTH[@]}" "$API/tags/$TAG" | python3 -c "import sys,json;print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)"
|
|
fi
|
|
if [[ -z "$RELEASE_ID" ]]; then
|
|
echo "error: could not create or find release $TAG" >&2
|
|
exit 1
|
|
fi
|
|
echo "Release id: $RELEASE_ID"
|
|
|
|
for f in "${all_artifacts[@]}"; do
|
|
if [[ ! -f "$f" ]]; then
|
|
echo "error: missing artifact $f — run ./tools/build_releases.sh first" >&2
|
|
exit 1
|
|
fi
|
|
echo "==> Uploading $(basename "$f")"
|
|
curl -s -X POST "$API/$RELEASE_ID/assets" "${AUTH[@]}" -F "attachment=@$f" >/dev/null
|
|
done
|
|
|
|
echo ""
|
|
echo "Release live: $HOST/$REPO/releases/tag/$TAG"
|