Files
WT-Offline/.github/workflows/patch-pack.yml
T
N0VAN0M4LY bd7450d9a1
Adaptation pack / release (push) Waiting to run
fix(release): support prerelease adaptation packs
Include published prereleases in adaptation pack checks. Publish signed adaptation packs as prereleases and let manual workflow runs stage a draft for release notes.
2026-12-01 18:36:17 +08:00

79 lines
2.8 KiB
YAML

# Release an adaptation pack (packages/patcher/src/patch-pack/): pack and sign patches/ and publish
# it as a GitHub prerelease 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
draft:
description: 'Keep the signed prerelease as a draft for editing before publication'
type: boolean
default: false
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: Create the prerelease
env:
GH_TOKEN: ${{ github.token }}
DRAFT: ${{ inputs.draft || false }}
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
release_flags=(--prerelease)
if [ "$DRAFT" = 'true' ]; then
release_flags+=(--draft)
fi
gh release create "patches-$version" \
"dist/wtoffline-patches-$version.zip" \
"dist/wtoffline-patches-$version.zip.sig" \
"dist/wtoffline-patches-$version.manifest.json" \
"${release_flags[@]}" \
--title "Adaptation pack $version" \
--notes-file dist/notes.md \
--target "$GITHUB_SHA"