name: release # Tag-driven releases: pushing a `re3-vX.Y.Z` tag (or running this workflow # manually with a `version` input) builds the Linux x64 GL3+OpenAL binary, packages # it with the gamefiles/ overlay and INSTALL.md, and publishes a Gitea release with # the zip attached. Requires the runner's GITEA_TOKEN (or GITHUB_TOKEN) to have # repository write access for tags/releases. on: push: tags: - 're3-v*' workflow_dispatch: inputs: version: description: 'Version to release, e.g. 1.0.1 (creates the tag at the branch HEAD if missing)' required: false default: '' concurrency: group: release-${{ gitea.ref }} cancel-in-progress: false env: GITEA_API: https://git.thetomie.com/api/v1 REPO_FULL: rockstargames/re3 # The runner injects the job token via the SECRETS context (secrets.GITEA_TOKEN / # secrets.GITHUB_TOKEN), not as plain env vars — materialise it here once. API_TOKEN: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }} # Jobs run as root in the pinned container; keep this stable so the # actions/cache path below matches. CCACHE_DIR: /root/.cache/ccache # apt installs a fresh compiler (new mtime) every run; hash its CONTENT so the # cache still hits across runs (default mtime check would miss every time). CCACHE_COMPILERCHECK: content jobs: release: runs-on: ubuntu-latest # Same pin as linux.yml: the runner's default image fails to extract on the # runner host, and this image ships node20 (checkout@v4), python3 and zip. container: image: ghcr.io/catthehacker/ubuntu:act-24.04 options: --user root steps: # Recursive submodules are required: vendor/librw, vendor/ogg, vendor/opus and # vendor/opusfile are git submodules. fetch-depth: 0 keeps the full history and # tags, which the changelog below needs. - name: Checkout uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 # act_runner images run as root without sudo; install directly. `zip` and # `python3` are added on top of the linux.yml list: zip builds the release # archive, python3 builds/parses the JSON API payloads. Both are present in # the catthehacker image but pinning them keeps the step self-contained. - name: Install build deps run: | apt-get update DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ build-essential \ cmake \ ninja-build \ pkg-config \ file \ ccache \ zip \ python3 \ libglfw3-dev \ libopenal-dev \ libsndfile1-dev \ libmpg123-dev \ libgl-dev # Resolve TAG/VER from either the tag push or the manual version input and # export them to later steps. The dispatch input is injected via step env so # this script contains no `${{ }}` expressions and stays bash -n clean. - name: Resolve tag env: DISPATCH_VERSION: ${{ gitea.event.inputs.version }} run: | set -euo pipefail INPUT="${DISPATCH_VERSION:-}" TAG="" if [ -n "$INPUT" ]; then if ! [[ "$INPUT" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "error: version input '$INPUT' is not X.Y.Z" >&2 exit 1 fi TAG="re3-v${INPUT}" elif [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then # GITHUB_REF_NAME may not be set by every act_runner version; fall back # to stripping the prefix from GITHUB_REF. TAG="${GITHUB_REF_NAME:-${GITHUB_REF#refs/tags/}}" else echo "error: release requires either a re3-v* tag push or a version input" >&2 exit 1 fi if [[ ! "$TAG" =~ ^re3-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "error: resolved tag '$TAG' does not match re3-vX.Y.Z" >&2 exit 1 fi VER="${TAG#re3-v}" echo "TAG=$TAG" >> "$GITHUB_ENV" echo "VER=$VER" >> "$GITHUB_ENV" echo "Releasing $TAG (version $VER)" # On a tag push the tag is already checked out, so this is a no-op. On a # workflow_dispatch run the tag may not exist yet: create it via the API at # the current HEAD, treat 409 (already exists) as success, then fetch it. - name: Ensure tag exists run: | set -euo pipefail AUTH="Authorization: token ${API_TOKEN}" if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then echo "tag $TAG is already present locally" else echo "tag $TAG missing locally; creating it via the Gitea API" CODE=$(curl -sS -o /tmp/tag.json -w '%{http_code}' -X POST \ "$GITEA_API/repos/$REPO_FULL/tags" \ -H "$AUTH" -H 'Content-Type: application/json' \ -d "{\"tag_name\": \"$TAG\", \"target\": \"$(git rev-parse HEAD)\", \"message\": \"re3 v$VER\"}") case "$CODE" in 200|201) echo "created tag $TAG" ;; 409) echo "tag $TAG already exists on the server; continuing" ;; *) echo "error: tag API returned $CODE" >&2 cat /tmp/tag.json >&2 || true exit 1 ;; esac fi # Workspace is disposable: force-fetch the tag so the checkout has it. git fetch --force origin "refs/tags/$TAG:refs/tags/$TAG" # Persist the compiler cache across runs; restore-keys falls back to the most # recent cache for this platform when the exact ref key misses. - name: Restore ccache uses: actions/cache@v4 with: path: /root/.cache/ccache # Versioned key: a claimed primary key is never overwritten (cache # semantics), so bump this when the cache scheme changes (content-check). key: ccache-linux-x64-content-${{ gitea.ref }} restore-keys: | ccache-linux-x64- # GL3 renderer via vendored librw + OpenAL audio = the documented Linux configuration. - name: Configure run: | cmake -S . -B build -G Ninja \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DRE3_AUDIO=OAL \ -DRE3_VENDORED_LIBRW=True \ -DLIBRW_PLATFORM=GL3 \ -DLIBRW_GL3_GFXLIB=GLFW \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache # No -Werror: this legacy codebase warns, and warnings must not fail the build. - name: Build run: | cmake --build build --parallel "$(nproc)" # Locate the binary (known path first, find fallback) and export it for the # packaging step. - name: Smoke check run: | set -euo pipefail BIN=build/src/re3 if [ ! -x "$BIN" ]; then BIN="$(find build -type f -name re3 -perm -u+x | head -1 || true)" fi if [ -z "$BIN" ]; then echo "error: no re3 executable found under build/" >&2 find build -maxdepth 3 -type f | sort >&2 || true exit 1 fi file "$BIN" echo "BIN=$BIN" >> "$GITHUB_ENV" # Package: binary + the gamefiles/ overlay + an INSTALL.md, zipped at the root # of the workspace so the next steps can attach it directly. - name: Package run: | set -euo pipefail mkdir -p pkg cp "$BIN" pkg/re3 cp -r gamefiles/. pkg/ cat > pkg/INSTALL.md <<'EOF' # re3 — Linux x64 (GL3 + OpenAL) This is re3, a reverse-engineered source port of Grand Theft Auto III. It is **not** a standalone game and ships **no game assets**. **No license.** The code is provided for educational, documentation and modding purposes only. Do not sell it or any derivative; keep derivative work open source and give proper credit. You must own GTA III legally. ## Requirements * A legally-owned installation of **Grand Theft Auto III** (PC). * An OpenGL 3 capable GPU/driver with GLFW. * Runtime libraries (Debian/Ubuntu): `sudo apt install libopenal1 libsndfile1 libmpg123-0 libglfw3 libgl1` ## Install 1. Extract this zip over your GTA III installation directory, so the `re3` binary lands next to `data/`, `models/`, `audio/`, `TEXT/` and `movies/`. The `gamefiles/` overlay is already merged into this archive. 2. Run `./re3` from that directory. ## Notes * Settings are written to `re3.ini` next to the binary; saved games go to the `userfiles/` directory created next to it. * Ctrl+M opens the debug menu; the build's version string is shown there. EOF cd pkg zip -r "../re3-v$VER-linux-x64-gl3-oal.zip" . # Compose release notes from the tag range and create-or-update the Gitea # release. JSON is produced by python3 so the changelog is escaped safely. - name: Release notes + publish run: | set -euo pipefail AUTH="Authorization: token ${API_TOKEN}" PREV=$(git tag -l 're3-v*' --sort=-v:refname | grep -vx "$TAG" | head -n1 || true) if [ -z "$PREV" ]; then PREV="re3_v1.0" fi CHANGELOG=$(git log --oneline --no-decorate "$PREV..$TAG" 2>/dev/null | head -n 200 || echo "(first release under this scheme)") { echo "re3 v$VER — stable continuation of the upstream re3_v1.0 baseline" echo echo "## Changes since $PREV" echo printf '%s\n' "$CHANGELOG" echo echo "## Install" echo echo "You need a legally-owned Grand Theft Auto III installation." echo "Extract \`re3-v$VER-linux-x64-gl3-oal.zip\` over your GTA III directory (the \`re3\` binary lands next to the game data), then run \`./re3\`." echo echo "Runtime deps (Debian/Ubuntu): \`sudo apt install libopenal1 libsndfile1 libmpg123-0 libglfw3 libgl1\`." echo echo "Settings go to \`re3.ini\` next to the binary; saves go to \`userfiles/\`. Ctrl+M opens the debug menu (version string there)." } > notes.md python3 - "$TAG" "$(git rev-parse HEAD)" "re3 v$VER" notes.md > payload.json <<'PY' import json import sys tag, target, name, notes_path = sys.argv[1:5] with open(notes_path, encoding="utf-8") as f: body = f.read() json.dump({ "tag_name": tag, "target_commitish": target, "name": name, "body": body, "draft": False, "prerelease": False, }, sys.stdout) PY RID=$(curl -sS "$GITEA_API/repos/$REPO_FULL/releases/tags/$TAG" -H "$AUTH" \ | python3 -c 'import json, sys; print(json.load(sys.stdin).get("id", ""))' 2>/dev/null || true) if [ -n "$RID" ]; then curl -fsS -X PATCH "$GITEA_API/repos/$REPO_FULL/releases/$RID" \ -H "$AUTH" -H 'Content-Type: application/json' -d @payload.json -o /dev/null echo "updated existing release $RID" else curl -fsS -X POST "$GITEA_API/repos/$REPO_FULL/releases" \ -H "$AUTH" -H 'Content-Type: application/json' -d @payload.json -o /tmp/release.json RID=$(python3 -c 'import json; print(json.load(open("/tmp/release.json"))["id"])') echo "created release $RID" fi echo "RID=$RID" >> "$GITHUB_ENV" # Attach the zip. If a same-named asset already exists (release re-run), # delete it and retry once so re-runs are idempotent. - name: Attach zip run: | set -euo pipefail AUTH="Authorization: token ${API_TOKEN}" ASSET="re3-v$VER-linux-x64-gl3-oal.zip" URL="$GITEA_API/repos/$REPO_FULL/releases/$RID/assets?name=$ASSET" CODE=$(curl -sS -o /tmp/asset.json -w '%{http_code}' -X POST "$URL" \ -H "$AUTH" -F "attachment=@$ASSET") if [ "$CODE" = "200" ] || [ "$CODE" = "201" ]; then echo "uploaded asset $ASSET" else echo "asset upload returned $CODE; looking for an existing asset to replace" AID=$(curl -sS "$GITEA_API/repos/$REPO_FULL/releases/$RID/assets" -H "$AUTH" \ | python3 -c 'import json, sys; print(next((a["id"] for a in json.load(sys.stdin) if a.get("name") == sys.argv[1]), ""))' "$ASSET" 2>/dev/null || true) if [ -z "$AID" ]; then echo "error: could not upload asset (HTTP $CODE)" >&2 cat /tmp/asset.json >&2 || true exit 1 fi curl -fsS -X DELETE "$GITEA_API/repos/$REPO_FULL/releases/$RID/assets/$AID" -H "$AUTH" curl -fsS -X POST "$URL" -H "$AUTH" -F "attachment=@$ASSET" -o /dev/null echo "replaced existing asset $ASSET" fi - name: Done run: | echo "Release published: https://git.thetomie.com/rockstargames/re3/releases/tag/$TAG"