Files
WT-Offline/.github/workflows/patch-pack.yml
T
N0VAN0M4LY f5c5377d44 feat(patch-pack): publish signed adaptation packs and install them locally
An adaptation pack is the patch set (exe, GUI, native definitions and
version records) released on its own, so a new game build can be adapted
without a new offline version. It is a zip with a manifest, signed with
Ed25519, published as a GitHub release tagged patches-<YYYY.MM.DD[.N]>.

- packages/patcher/src/patch-pack: manifest and version numbers, zip
  writing and reading with path and size checks, signatures, a check that
  a patch set reads as a whole; tuning/patch-pack.jsonc holds the
  repository and the limits.
- scripts/generate-patch-signing-key.ts writes the public key for the
  repository and the private key outside it; scripts/build-patch-pack.ts
  packs only committed files and signs with PATCH_SIGNING_KEY.
- .github/workflows/patch-pack.yml packs, signs and publishes on a
  patches-* tag or a manual run.
- Launcher main process: find the newest pack release, download, verify,
  unpack into user data and make it active; resource paths use the
  active pack when it is usable (a repository checkout only with
  WTO_USE_PATCH_PACK=1). The pages that show and start this come later.
2026-11-29 16:08:37 +08:00

69 lines
2.4 KiB
YAML

# Release an adaptation pack (packages/patcher/src/patch-pack/): pack and sign patches/ and publish
# it as a GitHub release tagged patches-<version>, where the launcher looks for it.
#
# Start it either way:
# - push a tag: git tag patches-2026.11.29 && git push origin patches-2026.11.29
# - from the Actions page (Run workflow), giving the version; the tag is created on the chosen
# branch's latest commit.
# The signing key comes from the repository secret PATCH_SIGNING_KEY
# (scripts/generate-patch-signing-key.ts).
name: Adaptation pack
on:
push:
tags: ['patches-*']
workflow_dispatch:
inputs:
version:
description: 'Pack version, YYYY.MM.DD or YYYY.MM.DD.N'
required: true
type: string
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
env:
# Packing needs no Electron binary.
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.version || '' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- run: npm ci
- name: Pack and sign
env:
PATCH_SIGNING_KEY: ${{ secrets.PATCH_SIGNING_KEY }}
run: |
if [ -n "$VERSION" ]; then
node scripts/build-patch-pack.ts --version "$VERSION" --out dist
else
# The version comes from the pushed tag (GITHUB_REF_NAME).
node scripts/build-patch-pack.ts --out dist
fi
- name: Publish the release
env:
GH_TOKEN: ${{ github.token }}
run: |
manifest=$(ls dist/*.manifest.json)
field() { node -e "const m=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'));const v=m[process.argv[2]];process.stdout.write(Array.isArray(v)?v.join(', '):String(v))" "$manifest" "$1"; }
version=$(field version)
printf 'Adaptation pack %s.\n\nChecked game versions: %s\nNeeds offline version %s or newer.\n' \
"$version" "$(field game_versions)" "$(field min_app_version)" > dist/notes.md
gh release create "patches-$version" \
"dist/wtoffline-patches-$version.zip" \
"dist/wtoffline-patches-$version.zip.sig" \
"dist/wtoffline-patches-$version.manifest.json" \
--title "Adaptation pack $version" \
--notes-file dist/notes.md \
--target "$GITHUB_SHA"