git clone https://garage44.eu/jeroen/cartopolis.git.. /.forgejo/workflows/release.yml
name: Release
# Native Linux (x86_64) build, published as a downloadable tarball on a Forgejo
# release. Two ways in:
# 1. push a tag v* -> a versioned release for that tag
# 2. manual "Run workflow" -> the rolling `continuous` prerelease (asset is
# replaced each run, so exactly one lives at a time)
on:
push:
tags: ['v*']
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
CARGO_NET_RETRY: "3"
# sccache, the same second cache layer ci.yml has had since it was written, and
# for the reason that file states at length: `rust-cache` has exactly one key, so
# a key change or a failed run leaves nothing behind, while sccache is keyed on
# the compiler invocation and its inputs and therefore cannot miss for a reason
# unrelated to the code. This lane is the one with the worst cache history in the
# repo -- see CACHE_ON_FAILURE above -- so it is the one that needed a floor
# under it most, and it was the only one without.
#
# This shares a cache *directory* with ci.yml but not its entries: a different
# target triple and a different profile mean a different compiler invocation and
# so a different key. What it warms from is its own history, which is the point.
#
# `[profile.release] incremental = false` (inherited by android-release) is what
# makes this work at all -- sccache silently declines to cache an incremental
# compilation. That setting was overridden by a `[build] incremental = true` in
# .cargo/config.toml until it was removed; without that fix this block would
# have been decoration.
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /sccache
SCCACHE_CACHE_SIZE: 20G
jobs:
# The gate, and it exists because nothing else here is one. CI is not a required
# check on this repo and `main` is allowed to be red, so before this job a tag
# pushed onto a red `main` published a tarball whose own tests fail — and a
# release is the one artifact nobody re-runs the suite against, because it looks
# finished.
#
# A separate job rather than steps inside `release`, for two reasons. It fails in
# its own box, so "the release did not publish" says which half broke without
# reading a log; and it runs the *dev* profile the tests are normally run in,
# where folding it into `release` would either run them under fat LTO (a full
# re-link per test binary) or drag a second profile's artifacts into that job's
# cache. The cost is one cold build on a rare workflow, which is the right side
# of that trade for the thing being published.
test:
name: gate — tests must pass
runs-on: ubuntu-latest
container:
image: cartopolis-ci:latest
# The compilation cache is the same host directory ci.yml mounts —
# sccache is keyed on the compiler invocation and is safe to share. The
# download cache is **this workflow's own copy**, and deploy-wasm.yml has
# the long version: a bind mount of `registry/` excludes cargo's lock,
# which lives one level above it at `$CARGO_HOME/.package-cache`, so two
# concurrent containers write one registry with nothing serialising them.
# A tag push during a `main` run is exactly that. Both are in the runner's
# `valid_volumes`. The two jobs here share one copy safely: `release`
# needs `test`, so they never overlap.
options: >-
--volume /data/ci-cache/sccache:/sccache
--volume /data/ci-cache/cargo-registry-release:/root/.cargo/registry
env:
# Byte-identical to ci.yml's build-test job, and that is the requirement
# rather than a tidiness preference: RUSTFLAGS is part of the sccache key,
# so any difference makes every rustc invocation in this job miss against
# the entries ci.yml wrote minutes earlier for the same crates, the same
# target and the same profile.
#
# The difference was one flag. This job set nothing and so inherited
# `.cargo/config.toml`'s `-C link-arg=-fuse-ld=lld -C target-cpu=x86-64-v3`,
# while ci.yml overrides the linker to mold. Same compiler, same code, same
# output — different command line, therefore a different key and a 100% miss
# rate. mold is baked into `cartopolis-ci:latest`, so this job can ask for it.
#
# `target-cpu=x86-64-v3` is repeated because RUSTFLAGS *replaces*
# `[target.x86_64-unknown-linux-gnu].rustflags` wholesale rather than adding
# to it; without it this job would silently drop the SIMD baseline the step
# below asserts the runner can execute. It does not replace `linker`, so
# clang still drives the link and hands off to mold.
#
# Job-scoped, exactly as ci.yml scopes its own: the `release` job below
# cross-compiles to x86_64-pc-windows-gnu, where `-fuse-ld=mold` is wrong and
# would break the link.
RUSTFLAGS: "-C link-arg=-fuse-ld=mold -C target-cpu=x86-64-v3"
steps:
- uses: actions/checkout@v4
with:
# Required, not an optimisation: see the release job below.
lfs: true
- uses: https://github.com/Swatinem/rust-cache@v2
with:
key: release-test
# This job *runs* what it builds, at `target-cpu=x86-64-v3`. Same guard, same
# reason, as ci.yml's build-test: on an older runner the failure would
# otherwise be an illegal instruction deep inside a test.
#
# The baseline now comes from this job's own RUSTFLAGS rather than from
# `.cargo/config.toml` — RUSTFLAGS replaces that file's per-target rustflags
# wholesale — which is exactly why the flag is repeated up there. If it is
# ever dropped from the env block, this guard keeps passing while the build
# quietly stops using the baseline, so keep the two together.
- name: Runner supports the x86-64-v3 baseline
run: |
grep -qw avx2 /proc/cpuinfo && grep -qw fma /proc/cpuinfo || {
echo "::error::Runner CPU lacks AVX2/FMA, but this job builds for x86-64-v3."
exit 1
}
# The same invocation ci.yml's build-test job runs, which is the whole point
# of this step: identical target, profile, feature unification and rustflags
# mean identical rustc command lines, so sccache serves this job from the
# entries that job just wrote.
#
# It was five `cargo test -p …` steps until now, and the comment above them
# claimed to match ci.yml — which stopped being true when ci.yml collapsed
# its own five into one and measured why. Under resolver v2 each invocation
# unifies features over only the packages it selects, so five invocations are
# five feature sets for the shared Bevy dependencies and five rebuilds of
# them: `big_space`, a small vendored crate running straight after a step
# that had just compiled all of Bevy, took 439 seconds there. None of that is
# its own code.
#
# The cost is fail-fast ordering — a `cartopolis_geo` break now surfaces after
# the whole workspace compiles rather than in seconds. Accepted here for the
# same reason ci.yml accepted it, and it matters less on a tag build than on
# a push.
- run: cargo test --locked --workspace --exclude cartopolis_android
# And the one check that renders: everything above proves the code compiles
# and its units behave, this proves the frame had a planet in it. Shipping a
# binary that type-checks and draws black is precisely what a release must
# not do. Constraints (orbit only, no colour assertions, virtual seconds)
# are documented at the same step in ci.yml.
- name: Headless scene smoke (orbit)
timeout-minutes: 15
env:
CARTO_TILE_URL: https://tiles.cartopolis.org/tiles/osm/{z}/{x}/{y}
run: |
cargo run --locked -p cartopolis -- \
--shot /tmp/orbit.png --dump-state /tmp/orbit.json \
--at 53.2194,6.5665,180000 --look=-90,0 \
--size 640x360 --settle 2 --wait 60 \
--expect 'settled==true' --expect 'globe_rendered>0' || {
echo "::error::scene smoke failed — the metrics behind it:"
cat /tmp/orbit.json 2>/dev/null || echo "(no dump: the run died before it captured)"
exit 1
}
# One job builds every target, so the `continuous` publish (which recreates the
# release) runs once — two publishing jobs would race and clobber each other's
# assets. Cross-compiles to Windows via the mingw-w64 toolchain in the image.
release:
needs: test
runs-on: ubuntu-latest
container:
image: cartopolis-ci:latest
# The compilation cache is the same host directory ci.yml mounts —
# sccache is keyed on the compiler invocation and is safe to share. The
# download cache is **this workflow's own copy**, and deploy-wasm.yml has
# the long version: a bind mount of `registry/` excludes cargo's lock,
# which lives one level above it at `$CARGO_HOME/.package-cache`, so two
# concurrent containers write one registry with nothing serialising them.
# A tag push during a `main` run is exactly that. Both are in the runner's
# `valid_volumes`. The two jobs here share one copy safely: `release`
# needs `test`, so they never overlap.
options: >-
--volume /data/ci-cache/sccache:/sccache
--volume /data/ci-cache/cargo-registry-release:/root/.cargo/registry
steps:
- uses: actions/checkout@v4
with:
# Required, not an optimisation: the font, app icon, star catalog and
# map fixtures are `include_bytes!`-ed, so without the smudge filter
# this job compiles 130-byte LFS pointers into the binary and only
# finds out at runtime. See `.gitattributes`.
lfs: true
- uses: https://github.com/Swatinem/rust-cache@v2
with:
# Release profile (fat LTO) artifacts are distinct from the CI debug cache.
key: release
# ci.yml's own rule for this cache: print the stats unconditionally, so the
# next person can tell whether it worked instead of inferring it from a
# duration. `if: always()` because a failed build is exactly when you want
# to know whether the cache was cold.
- name: sccache stats
if: always()
# **A diagnostic may not fail a deploy.** On 2026-09-05 this exact
# command ended a web publish: the wasm build had finished and trunk had
# written the distribution, and `--show-stats` then answered "Failed to
# read response header … Mismatch of client/server versions?" and exited
# 2 — so the threading check, the pre-compression and the publish never
# ran, and a good artifact was thrown away over the answer to "how did
# the cache do?".
#
# Why the server stopped answering is **not established**. It is not a
# stale server shared between lanes: each container has its own network
# namespace, so each has its own. What is established is that every
# compile had already succeeded, so whatever happened to the server
# happened after the work. Print the stats, say so when they cannot be
# printed, and let the checks that actually inspect the artifact decide.
run: sccache --show-stats || echo "sccache could not report its stats — the build above is unaffected"
- name: Build release binary (Linux x86_64)
run: cargo build --locked -p cartopolis --release
- name: Build release binary (Windows x86_64, cross)
run: cargo build --locked -p cartopolis --release --target x86_64-pc-windows-gnu
# Both packages carry the same paperwork, and one of the four files is not
# optional: LICENSE-THIRD-PARTY.md is the ODbL / CC BY 4.0 / OFL notice that
# OpenStreetMap, 3DBAG and Plus Jakarta Sans require to travel with anything
# built from them. A tarball without it is a distribution that does not
# discharge its obligations, which is a different kind of bug from a missing
# README.
#
# RUNNING.txt is written here rather than committed because it is about the
# *build*, not the source: what CPU this particular binary was compiled for,
# which is a property of `.cargo/config.toml` at the moment of the build.
# ci.yml's own rule for this cache: print the stats unconditionally, so the
# next person can tell whether it worked instead of inferring it from a
# duration. `if: always()` because a failed build is exactly when you want
# to know whether the cache was cold.
- name: sccache stats
if: always()
# **A diagnostic may not fail a deploy.** On 2026-09-05 this exact
# command ended a web publish: the wasm build had finished and trunk had
# written the distribution, and `--show-stats` then answered "Failed to
# read response header … Mismatch of client/server versions?" and exited
# 2 — so the threading check, the pre-compression and the publish never
# ran, and a good artifact was thrown away over the answer to "how did
# the cache do?".
#
# Why the server stopped answering is **not established**. It is not a
# stale server shared between lanes: each container has its own network
# namespace, so each has its own. What is established is that every
# compile had already succeeded, so whatever happened to the server
# happened after the work. Print the stats, say so when they cannot be
# printed, and let the checks that actually inspect the artifact decide.
run: sccache --show-stats || echo "sccache could not report its stats — the build above is unaffected"
- name: Package Linux tarball (binary + assets)
run: |
set -euo pipefail
PKG=cartopolis-linux-x86_64
rm -rf "$PKG" dist && mkdir -p "$PKG" dist
cp target/release/cartopolis "$PKG/"
cp -r assets "$PKG/"
# `|| true` on the branch, not on `cp`: under `set -e` a loop whose
# last iteration tests false fails the whole step.
for f in README.md CHANGELOG.md LICENSE LICENSE-MIT LICENSE-APACHE LICENSE-THIRD-PARTY.md; do
[ -f "$f" ] && cp "$f" "$PKG/" || true
done
cat > "$PKG/RUNNING.txt" <<'TXT'
Cartopolis — Linux x86_64
Run ./run.sh; it changes into this directory (so the binary finds
assets/) and checks the one requirement that has no polite failure.
REQUIREMENTS
* A CPU with AVX2 and FMA — Intel Haswell (2013) or AMD Excavator
(2015) and newer. This build is compiled for the x86-64-v3 baseline;
run.sh says so plainly rather than letting the binary take SIGILL.
* A GPU and driver with Vulkan.
* An internet connection: the map, the buildings, the terrain and the
weather are all streamed. Nothing is bundled.
LICENSING
Cartopolis itself is MIT OR Apache-2.0 (see LICENSE). The map data,
models and font it is built from carry their own terms and their own
required notices — LICENSE-THIRD-PARTY.md is that notice, and it is
part of this distribution.
TXT
# The CPU baseline is a real trap and it has no graceful failure mode:
# `.cargo/config.toml` builds x86_64 at `target-cpu=x86-64-v3`, so this
# binary uses AVX2 and FMA unconditionally and dies with SIGILL — no
# message, no log line, an "Illegal instruction" from the shell — on
# anything older than Haswell, which includes Atom-derived parts still
# on sale. ci.yml guards the *runner* against exactly this with a legible
# error; until this block, the shipped binary had no such guard, so the
# person least able to diagnose it got the least legible failure.
#
# Checked here rather than dropped from the build: the SIMD baseline is
# deliberate (`crates/cartopolis/src/simd_baseline.rs` exists to stop it
# being traded away for convenience) and the affected population is
# small. What was missing was saying so.
cat > "$PKG/run.sh" <<'SH'
#!/usr/bin/env bash
# Run cartopolis from its own directory so it finds ./assets.
cd "$(dirname "$0")"
# This build targets x86-64-v3 (AVX2 + FMA). On an older CPU the binary
# does not fail politely — it takes SIGILL on the first vector
# instruction, which the shell reports as "Illegal instruction" and
# nothing else. Say what happened while there is still a shell to say it in.
if [ -r /proc/cpuinfo ] && ! grep -qw avx2 /proc/cpuinfo; then
cat >&2 <<'MSG'
This build needs a CPU with AVX2 and FMA (Intel Haswell / AMD Excavator,
2013 or newer). Yours does not report AVX2, so cartopolis would stop with
"Illegal instruction" the moment it starts.
Build from source instead — that produces a binary for the machine it is
built on:
git lfs install && git clone https://code.garage44.eu/jeroen/cartopolis
cd cartopolis && cargo run -p cartopolis --release
MSG
exit 1
fi
exec ./cartopolis "$@"
SH
chmod +x "$PKG/run.sh"
tar -czf "dist/$PKG.tar.gz" "$PKG"
( cd dist && sha256sum "$PKG.tar.gz" > "$PKG.tar.gz.sha256" )
- name: Package Windows zip (binary + assets)
run: |
set -euo pipefail
PKG=cartopolis-windows-x86_64
rm -rf "$PKG" && mkdir -p "$PKG"
cp target/x86_64-pc-windows-gnu/release/cartopolis.exe "$PKG/"
cp -r assets "$PKG/"
# `|| true` on the branch, not on `cp`: under `set -e` a loop whose
# last iteration tests false fails the whole step.
for f in README.md CHANGELOG.md LICENSE LICENSE-MIT LICENSE-APACHE LICENSE-THIRD-PARTY.md; do
[ -f "$f" ] && cp "$f" "$PKG/" || true
done
# No run.sh equivalent: the same AVX2 requirement applies to this binary
# (it is the same compiler flags, cross-linked), but a batch file cannot
# ask Windows about CPU features without either PowerShell or a helper
# binary, and shipping a launcher that is itself compiled for AVX2 would
# be a joke at the user's expense. So it is stated in writing instead —
# here, and on the release page.
cat > "$PKG/RUNNING.txt" <<'TXT'
Cartopolis — Windows x86_64
Run cartopolis.exe from this folder; it reads assets\ from beside itself.
REQUIREMENTS
* A CPU with AVX2 and FMA — Intel Haswell (2013) or AMD Excavator
(2015) and newer. This build is compiled for the x86-64-v3 baseline,
and on an older processor it stops immediately with an illegal
instruction rather than a message. Building from source produces a
binary tuned for your own machine.
* A GPU and driver with Vulkan or DX12.
* An internet connection: the map, the buildings, the terrain and the
weather are all streamed. Nothing is bundled.
LICENSING
Cartopolis itself is MIT OR Apache-2.0 (see LICENSE). The map data,
models and font it is built from carry their own terms and their own
required notices — LICENSE-THIRD-PARTY.md is that notice, and it is
part of this distribution.
TXT
zip -qr "dist/$PKG.zip" "$PKG"
( cd dist && sha256sum "$PKG.zip" > "$PKG.zip.sha256" )
ls -la dist
- name: Publish to Forgejo release
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
PAGE: ${{ github.server_url }}/${{ github.repository }}/releases
SHA: ${{ github.sha }}
run: |
set -euo pipefail
auth="Authorization: token $TOKEN"
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
TAG="$GITHUB_REF_NAME"; PRE=false; TITLE="$GITHUB_REF_NAME"
else
TAG=continuous; PRE=true; TITLE="Continuous build (latest main)"
fi
echo "Publishing tag=$TAG prerelease=$PRE"
# Look up an existing release for this tag.
rid=$(curl -s -H "$auth" "$API/releases/tags/$TAG" | jq -r '.id // empty')
# Rolling `continuous`: drop the old release + tag so it re-points to HEAD.
if [ "$TAG" = continuous ] && [ -n "$rid" ]; then
curl -s -X DELETE -H "$auth" "$API/releases/$rid" || true
curl -s -X DELETE -H "$auth" "$API/tags/$TAG" || true
rid=""
fi
# The release notes. Written here rather than left empty because the
# page is where two things have to be said and there is nowhere else to
# say them: the AVX2 requirement (the binary's only unrecoverable
# failure, and it prints nothing), and that there is an Android build at
# all — an APK cannot be a release asset here, it lives at its own URL,
# so a phone user who lands on this page otherwise leaves empty-handed.
NOTES=$(cat <<MD
A 3D world built on the real planet: walk a street of OpenStreetMap buildings,
keep flying up past the atmosphere, and drop back down anywhere on Earth.
**Downloads**
- \`cartopolis-linux-x86_64.tar.gz\` — unpack and run \`./run.sh\`
- \`cartopolis-windows-x86_64.zip\` — unpack and run \`cartopolis.exe\`
- **Android:** https://cartopolis.org/apk/ (not an asset here — it is
signed and served separately, with install instructions on that page)
- **Browser:** https://cartopolis.org
Each archive has a \`.sha256\` beside it.
**Before you download**
These binaries need a CPU with **AVX2 and FMA** — Intel Haswell (2013) or AMD
Excavator (2015) and newer. They are compiled for the x86-64-v3 baseline and
will stop with an illegal instruction on anything older; \`run.sh\` checks for
it and says so, but Windows cannot. Build from source on an older machine.
You also need a GPU with Vulkan (or DX12 on Windows) and an internet
connection — the map, buildings, terrain and weather are all streamed.
**Licence**
MIT OR Apache-2.0. The map data, models and font carry their own terms;
\`LICENSE-THIRD-PARTY.md\` in each archive is the required notice.
Built from \`$SHA\`. Changes: see \`CHANGELOG.md\` in the archive.
MD
)
# Create the release if it doesn't exist yet.
if [ -z "$rid" ]; then
body=$(jq -n --arg tag "$TAG" --arg name "$TITLE" --arg sha "$SHA" --argjson pre "$PRE" --arg notes "$NOTES" \
'{tag_name:$tag, name:$name, target_commitish:$sha, prerelease:$pre, draft:false, body:$notes}')
rid=$(curl -sf -X POST -H "$auth" -H "Content-Type: application/json" -d "$body" "$API/releases" | jq -r '.id')
fi
echo "release id: $rid"
# Upload assets, replacing any same-named asset (idempotent re-runs).
for f in dist/*; do
name=$(basename "$f")
old=$(curl -s -H "$auth" "$API/releases/$rid/assets" | jq -r ".[] | select(.name==\"$name\") | .id")
[ -n "$old" ] && curl -s -X DELETE -H "$auth" "$API/releases/$rid/assets/$old" >/dev/null || true
curl -sf -X POST -H "$auth" -F "attachment=@$f;filename=$name" "$API/releases/$rid/assets?name=$name" >/dev/null
echo "uploaded $name"
done
echo "Done -> $PAGE/tag/$TAG"