Files
horizon-mods/.github/workflows/publish.yml
T
68bd653d9c Check native mods on the newest Nightly, together, before publish (#308)
Players' native builds broke on mods made for an older Horizon (targets moved
by the crate split, a support module refused by a glob) and the whole build
failed. scripts/native_compat.py applies mods as the launcher builds them:

- check (pull requests): each new native-mod version on the newest Nightly
  with the 20 most downloaded native mods, horizon-mixins apply then cargo
  check, and its support modules' (file, name) against every registry mod's.
- health (daily, native-compat.yml): every native mod's newest version on the
  newest Nightly; the ones horizon-mixins refuses go to the native-health
  release, and publish marks them `broken_on` in index.json so the launcher
  warns before an install.

The PR job runs main's script with a read-only token; the submission's build
scripts run under that token only.

Co-authored-by: Horizon agent <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-05 20:59:55 +01:00

105 lines
4.5 KiB
YAML

# Merging publishes: each new version's file becomes a release asset
# (<id>-<version>/<file>), then index.json and the icons go to GitHub Pages
# (https://horizon-rust.github.io/horizon-mods/index.json), which the launcher and
# playhorizon.dev/mods read. Nothing is published if any entry fails its checks.
# Every hour it runs again to refresh each project's `downloads`: GitHub's
# download counts of its release assets.
name: publish
on:
push:
branches: [main]
schedule:
- cron: "23 * * * *"
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: publish
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 30
environment:
name: github-pages
url: ${{ steps.pages.outputs.page_url }}
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
HORIZON_REV: ${{ vars.HORIZON_REV || 'main' }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin
~/.cargo/horizon-rev
key: cargo-horizon-mod-${{ env.HORIZON_REV }}
- run: scripts/install-tool.sh
# Files kept from the last run: GitHub counts every download of a release
# asset, so fetching them all again each hour would count as players.
- uses: actions/cache@v4
with:
path: files
key: files-${{ hashFiles('mods/*.toml') }}
restore-keys: files-
- run: scripts/fetch.sh .
- name: Build the index
run: |
mkdir -p site
cargo horizon-mod registry build . --files files --out site/index.json --site https://horizon-rust.github.io/horizon-mods/ --generated "$(date -u +%FT%TZ)"
- name: Publish new files as releases
run: |
cargo horizon-mod registry list . | while read -r sha id version file; do
tag="$id-$version"
gh release view "$tag" >/dev/null 2>&1 && continue
dir="$(mktemp -d)"
cp "files/$sha" "$dir/$file"
gh release create "$tag" "$dir/$file" --title "$id $version" --latest=false \
--notes "Reviewed in the registry: mods/$id.toml. SHA-256 $sha."
done
- name: Download counts
run: |
# Each version's file is the asset at its URL: a project's downloads
# are its files' counts, every version together.
gh api --paginate "repos/$GH_REPO/releases?per_page=100" \
--jq '.[].assets[] | {key: .browser_download_url, value: .download_count}' \
| jq -s from_entries > counts.json
jq --slurpfile counts counts.json '
.projects |= map(
([.versions[].file.url | $counts[0][.] // 0] | add) as $n
| if $n > 0 then .downloads = $n else . end)' site/index.json > index.counted.json
mv index.counted.json site/index.json
jq -r '.projects[] | "\(.id) \(.downloads // 0)"' site/index.json
- name: Native mods that don't apply on the newest Nightly
run: |
# native-compat.yml's daily health: the version each names gets `broken_on`, the Horizon
# commit horizon-mixins refused it on and its code, so the launcher warns before an install.
if gh release download native-health --pattern native-health.json --dir health 2>/dev/null; then
jq --slurpfile h health/native-health.json '
$h[0] as $health
| .projects |= map(. as $p | .versions |= map(
($health.broken[$p.id] // null) as $b
| if $b != null and $b.version == .version
then .broken_on = [{horizon: $health.horizon, code: $b.code}] else . end))' \
site/index.json > index.health.json
mv index.health.json site/index.json
jq -r '.projects[] | select(.versions[0].broken_on) | "\(.id) \(.versions[0].version): \(.versions[0].broken_on[0].code)"' site/index.json
fi
- name: The site
run: |
cp -R icons site/icons
cat > site/index.html <<'HTML'
<!doctype html><meta charset="utf-8"><title>Horizon mods</title>
<meta http-equiv="refresh" content="0; url=https://playhorizon.dev/mods">
<p><a href="https://playhorizon.dev/mods">playhorizon.dev/mods</a> · <a href="index.json">index.json</a></p>
HTML
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: site
- id: pages
uses: actions/deploy-pages@v4