diff --git a/.agents/notes/implemented/architecture/2026-11-27-release-editor-packages.md b/.agents/notes/implemented/architecture/2026-11-27-release-editor-packages.md new file mode 100644 index 000000000..12af995d2 --- /dev/null +++ b/.agents/notes/implemented/architecture/2026-11-27-release-editor-packages.md @@ -0,0 +1,31 @@ +# Agent Note: Standalone desktop editor and signed release packaging + +Status: implemented + +## Problem + +Tagged releases of `nsgo-dev/game` previously created text-only GitHub Releases with changelog notes and no prebuilt desktop editor or CLI binaries. Users who wanted to open the visual 2D/3D scene editor had to invoke it through Go (`go run github.com/nsgo-dev/game/cmd/game@latest editor` or `nsgo game editor`), and there was no standalone desktop `nsgo.yaml` application entrypoint for packaging native installers. + +## Decision + +Add a thin desktop application entrypoint in `cmd/editor` (`cmd/editor/main.go` + `cmd/editor/nsgo.yaml`) and extend `.github/workflows/release.yml` to build, sign, verify, and attach full desktop installers for **NSGo Game Editor** alongside prebuilt `nsgo-game` CLI archives on every release. + +### Packaging and signing contract + +- `cmd/editor` delegates directly to `internal/gamecli.Run(editorArgs(os.Args[1:]))`, stripping macOS Finder's `-psn_*` flag so double-clicking the app opens the Start Screen while CLI invocations still accept project/scene/clip arguments. +- `cmd/editor/nsgo.yaml` declares `id: dev.nsgo.game.editor`, `release.github: nsgo-dev/game`, and `updates.key` matching the organization-wide `NSGO_UPDATES_KEY` secret so `go tool nsgo build` emits signed `appcast-.xml` feeds, `install.sh`, `install.ps1`, and `.AppImage.zsync` files alongside every installer. +- `.github/workflows/release.yml` builds all six desktop targets on Depot runners (`depot-macos-15` for `macos_arm64`/`macos_x64` `.dmg`, `depot-ubuntu-24.04-4` for `linux_x64`/`linux_arm64` `.deb`/`.pkg.tar.gz`/`.AppImage` and `windows_x64`/`windows_arm64` `-setup.exe`), plus cross-compiled `nsgo-game` CLI archives for all six desktop OS/arch pairs. +- macOS builds import the organization's Developer ID certificate (`MACOS_CERTIFICATE`, `MACOS_CERTIFICATE_PASSWORD`, `vars.MACOS_SIGNING_IDENTITY`) and App Store Connect API key (`APPSTORE_API_KEY_P8`, `APPSTORE_API_KEY_ID`, `APPSTORE_API_ISSUER_ID`), passing them to `go tool nsgo build` for hardened-runtime signing, notarization, and stapling, then verify every `.app` and `.dmg` with `codesign`, `xcrun stapler validate`, and `spctl --assess`. Non-release fork PRs without secrets fall back to ad hoc signing while tagged releases and `workflow_dispatch` uploads fail fast if signing or update secrets are missing. +- `workflow_dispatch` with an optional existing `tag` input (`mode=upload`) allows building and attaching signed editor and CLI assets onto an already-published release (such as `v0.1.0`) via `gh release upload --clobber` without moving or recreating the immutable Go module tag. + +## Alternatives considered + +1. **Build `cmd/game` directly as a desktop app**: Rejected because `cmd/game` requires a subcommand (`editor`) and exits with CLI usage text when launched with no arguments from Finder/Start Menu/desktop launchers. +2. **Move the existing `v0.1.0` tag to re-trigger a tag push release**: Rejected because `github.com/nsgo-dev/game@v0.1.0` is already indexed by `proxy.golang.org` and the Go checksum database; moving a published Go module tag breaks module verification. +3. **Require Windows Authenticode signing via Certum immediately**: Deferred because no `nsgo-dev` repository currently ships a Certum SimplySign runner integration; Windows installers are still built and signed for WinSparkle updates via `NSGO_UPDATES_KEY`, and Authenticode signing can be added later through `nsgo build -sign-command`. + +## Consequences + +- **Benefits**: Every GitHub Release ships ready-to-install macOS (signed & notarized `.dmg`), Linux (`.deb`, `.pkg.tar.gz`, `.AppImage`), and Windows (`-setup.exe`) desktop editors with one-line `install.sh`/`install.ps1` scripts, signed update appcasts, and prebuilt `nsgo-game` CLI binaries. Pull requests modifying `cmd/editor` or `release.yml` dry-run the entire packaging and signing pipeline before merge. +- **Costs**: Tagged releases wait on macOS notarization (typically a few minutes, bounded by a 60-minute job timeout) and carry ~200 MB of release assets per version. +- **Verification**: `go tool nsgo test ./cmd/editor`, `go tool nsgo test . -- -run TestStabilityTable`, `go tool nsgo build -target macos,windows,linux ./cmd/editor`, `actionlint`, `go run ./tools/changelog check`, `bun run verify-notes`, website `bun run test && bun run build`, and live PR CI execution of `.github/workflows/release.yml`. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 829ab4607..707d381b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,107 +1,95 @@ name: Release -# Runs the full test and cross-target check suite on release tags, then publishes a GitHub Release with notes extracted from CHANGELOG.md. +# Runs the full test and cross-target check suite on release tags, builds signed desktop +# installers for NSGo Game Editor (macOS signed & notarized with the org's Developer ID, +# Linux .deb / .pkg.tar.gz / .AppImage + install scripts, Windows -setup.exe installers, +# plus signed update appcasts via NSGO_UPDATES_KEY) and cross-platform nsgo-game CLI +# archives, then publishes them on the GitHub Release with notes extracted from CHANGELOG.md. +# +# Pull requests touching cmd/editor or this workflow build and sign (when org secrets are +# available) without publishing. workflow_dispatch with an existing tag (for example v0.1.0) +# builds and uploads the editor and CLI assets onto that release without moving the tag. on: push: tags: - "v*" + pull_request: + paths: + - ".github/workflows/release.yml" + - "cmd/editor/**" + workflow_dispatch: + inputs: + tag: + description: "Optional existing release tag (e.g. v0.1.0) to build and upload editor/CLI assets onto; leave empty to dry-run." + required: false + type: string concurrency: - group: release-${{ github.ref_name }} - cancel-in-progress: false + group: release-${{ github.event_name }}-${{ inputs.tag || github.event.pull_request.number || github.ref_name }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read jobs: - test: - name: Test (${{ matrix.os }}) - strategy: - fail-fast: false - matrix: - os: - - depot-ubuntu-24.04-4 - - depot-macos-15 - runs-on: ${{ matrix.os }} - timeout-minutes: 20 - steps: - - name: Check out - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - name: Set up Go - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 - with: - go-version-file: go.mod - cache: true - cache-dependency-path: go.sum - - name: Test - run: go tool nsgo test ./... - - check: - name: Build and vet - runs-on: depot-ubuntu-24.04-4 - timeout-minutes: 20 + meta: + name: Resolve version and release notes + runs-on: depot-ubuntu-24.04 + timeout-minutes: 10 + outputs: + mode: ${{ steps.resolve.outputs.mode }} + tag: ${{ steps.resolve.outputs.tag }} + version: ${{ steps.resolve.outputs.version }} steps: - name: Check out uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - name: Set up Go - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 - with: - go-version-file: go.mod - cache: true - cache-dependency-path: go.sum - - name: Check Go formatting + - name: Resolve release mode and version + id: resolve + env: + EVENT: ${{ github.event_name }} + REF_NAME: ${{ github.ref_name }} + INPUT_TAG: ${{ inputs.tag }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - unformatted=$(git ls-files -z -- '*.go' | xargs -0 -r gofmt -l) - if [ -n "$unformatted" ]; then - printf '%s\n' "$unformatted" - exit 1 + set -euo pipefail + if [ "$EVENT" = "push" ]; then + mode="release" + tag="$REF_NAME" + version="${tag#v}" + elif [ "$EVENT" = "workflow_dispatch" ] && [ -n "$INPUT_TAG" ]; then + mode="upload" + tag="$INPUT_TAG" + if ! [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::error::Invalid tag '$tag' (expected vX.Y.Z or vX.Y.Z-suffix)." + exit 1 + fi + gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null + version="${tag#v}" + else + mode="check" + version=$(sed -nE 's/^version: *"?([0-9.]+)"? *$/\1/p' cmd/editor/nsgo.yaml) + tag="v$version" fi - - name: Build and vet every target but iOS - run: go tool nsgo check -target macos,windows,linux,android,web - - apple: - name: Build and vet (iOS) - runs-on: depot-macos-15 - timeout-minutes: 20 - steps: - - name: Check out - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - name: Set up Go - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 - with: - go-version-file: go.mod - cache: true - cache-dependency-path: go.sum - - name: Build and vet iOS - run: go tool nsgo check -target ios,ios_simulator - - release: - name: Publish release - needs: - - test - - check - - apple - runs-on: depot-ubuntu-24.04-4 - timeout-minutes: 10 - permissions: - contents: write - steps: - - name: Check out - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false + { + echo "mode=$mode" + echo "tag=$tag" + echo "version=$version" + } >> "$GITHUB_OUTPUT" - name: Extract release notes from CHANGELOG.md env: - TAG: ${{ github.ref_name }} + MODE: ${{ steps.resolve.outputs.mode }} + TAG: ${{ steps.resolve.outputs.tag }} + VERSION: ${{ steps.resolve.outputs.version }} run: | set -euo pipefail + if [ "$MODE" = "check" ]; then + printf 'Dry-run build check for NSGo Game Editor %s.\n' "$VERSION" > release-notes.md + exit 0 + fi + if [ ! -f CHANGELOG.md ]; then echo "Error: CHANGELOG.md not found." >&2 exit 1 @@ -176,17 +164,399 @@ jobs: printf '%s' "$footer" >> release-notes.truncated.md mv release-notes.truncated.md release-notes.md fi - - name: Create GitHub Release + - name: Upload release notes + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: release-notes + path: release-notes.md + retention-days: 7 + if-no-files-found: error + + test: + name: Test (${{ matrix.os }}) + if: github.event_name == 'push' + strategy: + fail-fast: false + matrix: + os: + - depot-ubuntu-24.04-4 + - depot-macos-15 + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + steps: + - name: Check out + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Set up Go + uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 + with: + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + - name: Test + run: go tool nsgo test ./... + + check: + name: Build and vet + if: github.event_name == 'push' + runs-on: depot-ubuntu-24.04-4 + timeout-minutes: 20 + steps: + - name: Check out + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Set up Go + uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 + with: + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + - name: Check Go formatting + run: | + unformatted=$(git ls-files -z -- '*.go' | xargs -0 -r gofmt -l) + if [ -n "$unformatted" ]; then + printf '%s\n' "$unformatted" + exit 1 + fi + - name: Build and vet every target but iOS + run: go tool nsgo check -target macos,windows,linux,android,web + + apple: + name: Build and vet (iOS) + if: github.event_name == 'push' + runs-on: depot-macos-15 + timeout-minutes: 20 + steps: + - name: Check out + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Set up Go + uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 + with: + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + - name: Build and vet iOS + run: go tool nsgo check -target ios,ios_simulator + + editor: + name: Build Editor (${{ matrix.name }}) + needs: meta + runs-on: ${{ matrix.os }} + timeout-minutes: ${{ matrix.name == 'macOS' && 60 || 30 }} + strategy: + fail-fast: false + matrix: + include: + - name: macOS + os: depot-macos-15 + targets: macos_arm64,macos_x64 + installers: ".dmg" + - name: Linux + os: depot-ubuntu-24.04-4 + targets: linux_x64,linux_arm64 + installers: ".deb .pkg.tar.gz .AppImage" + scripts: true + - name: Windows + os: depot-ubuntu-24.04-4 + targets: windows_x64,windows_arm64 + installers: "-setup.exe" + env: + MACOS_SIGNING_IDENTITY: ${{ vars.MACOS_SIGNING_IDENTITY }} + steps: + - name: Check out + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Download release notes + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: release-notes + path: ${{ runner.temp }} + - name: Set up Go + uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 + with: + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + - name: Verify updates signing key for releases + if: needs.meta.outputs.mode != 'check' env: - TAG: ${{ github.ref_name }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HAS_UPDATES_KEY: ${{ secrets.NSGO_UPDATES_KEY != '' }} + run: | + if [ "$HAS_UPDATES_KEY" != "true" ]; then + echo "::error::NSGO_UPDATES_KEY is not set, so the installers cannot be signed for updates." + exit 1 + fi + - name: Import macOS signing certificate and notary key + id: signing + if: matrix.name == 'macOS' + env: + REQUIRE_SIGNING: ${{ needs.meta.outputs.mode != 'check' }} + MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} + MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} + APPSTORE_API_KEY_P8: ${{ secrets.APPSTORE_API_KEY_P8 }} + APPSTORE_API_KEY_ID: ${{ secrets.APPSTORE_API_KEY_ID }} + APPSTORE_API_ISSUER_ID: ${{ secrets.APPSTORE_API_ISSUER_ID }} + run: | + set -euo pipefail + for name in MACOS_SIGNING_IDENTITY MACOS_CERTIFICATE MACOS_CERTIFICATE_PASSWORD APPSTORE_API_KEY_P8 APPSTORE_API_KEY_ID APPSTORE_API_ISSUER_ID; do + if [ -z "${!name}" ]; then + if [ "$REQUIRE_SIGNING" = "true" ]; then + echo "::error::$name is not set, so the macOS packages cannot be signed and notarized." + exit 1 + fi + echo "::warning::$name is not set; the macOS packages will be signed ad hoc." + exit 0 + fi + done + keychain="$RUNNER_TEMP/signing.keychain-db" + password="$(openssl rand -base64 24)" + security create-keychain -p "$password" "$keychain" + security set-keychain-settings -lut 21600 "$keychain" + security unlock-keychain -p "$password" "$keychain" + printf '%s' "$MACOS_CERTIFICATE" | base64 --decode > "$RUNNER_TEMP/certificate.p12" + security import "$RUNNER_TEMP/certificate.p12" -k "$keychain" -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign + rm -f "$RUNNER_TEMP/certificate.p12" + security set-key-partition-list -S apple-tool:,apple: -s -k "$password" "$keychain" >/dev/null + # shellcheck disable=SC2046 # one argument per keychain path + security list-keychains -d user -s "$keychain" $(security list-keychains -d user | xargs) + if ! security find-identity -v -p codesigning "$keychain" | grep -qF "\"$MACOS_SIGNING_IDENTITY\""; then + echo "::error::MACOS_CERTIFICATE does not hold $MACOS_SIGNING_IDENTITY." + exit 1 + fi + key="$RUNNER_TEMP/notary-key.p8" + printf '%s' "$APPSTORE_API_KEY_P8" | base64 --decode > "$key" + chmod 600 "$key" + echo "keychain=$keychain" >> "$GITHUB_OUTPUT" + echo "notary-key=$key" >> "$GITHUB_OUTPUT" + - name: Build NSGo Game Editor + env: + VERSION: ${{ needs.meta.outputs.version }} + TARGETS: ${{ matrix.targets }} + KEYCHAIN: ${{ steps.signing.outputs.keychain }} + NOTARY_KEY: ${{ steps.signing.outputs.notary-key }} + NOTARY_KEY_ID: ${{ steps.signing.outputs.notary-key != '' && secrets.APPSTORE_API_KEY_ID || '' }} + NOTARY_ISSUER: ${{ steps.signing.outputs.notary-key != '' && secrets.APPSTORE_API_ISSUER_ID || '' }} + NSGO_UPDATES_KEY: ${{ secrets.NSGO_UPDATES_KEY }} run: | set -euo pipefail + sign=() + if [ -n "$KEYCHAIN" ]; then + sign=(-sign "$MACOS_SIGNING_IDENTITY") + export NSGO_NOTARY_KEY="$NOTARY_KEY" + export NSGO_NOTARY_KEY_ID="$NOTARY_KEY_ID" + export NSGO_NOTARY_ISSUER="$NOTARY_ISSUER" + fi + go tool nsgo build \ + -open=false \ + -version "$VERSION" \ + -target "$TARGETS" \ + -output "$RUNNER_TEMP/packages" \ + -release-notes "$RUNNER_TEMP/release-notes.md" \ + "${sign[@]}" \ + ./cmd/editor + - name: Verify macOS signatures and notarization + if: steps.signing.outputs.keychain != '' + env: + TARGETS: ${{ matrix.targets }} + run: | + set -euo pipefail + shopt -s nullglob + for target in ${TARGETS//,/ }; do + apps=("$RUNNER_TEMP"/packages/*-"$target"/*.app) + if [ "${#apps[@]}" -ne 1 ]; then + echo "::error::nsgo build made ${#apps[@]} apps for $target, not one" + exit 1 + fi + codesign --verify --deep --strict --verbose=2 "${apps[0]}" + codesign -dvv "${apps[0]}" 2>&1 | grep -F "Authority=$MACOS_SIGNING_IDENTITY" + dmgs=("$RUNNER_TEMP"/packages/releases/*-"${target/_/-}".dmg) + if [ "${#dmgs[@]}" -ne 1 ]; then + echo "::error::nsgo build made ${#dmgs[@]} disk images for $target, not one" + exit 1 + fi + xcrun stapler validate "${dmgs[0]}" + spctl --assess --type open --context context:primary-signature --verbose=2 "${dmgs[0]}" + done + - name: Collect editor packages + env: + TARGETS: ${{ matrix.targets }} + INSTALLERS: ${{ matrix.installers }} + SCRIPTS: ${{ matrix.scripts && 'true' || '' }} + REQUIRE_APPCAST: ${{ needs.meta.outputs.mode != 'check' }} + run: | + set -euo pipefail + cd "$RUNNER_TEMP/packages/releases" + shopt -s nullglob + read -ra suffixes <<<"$INSTALLERS" + for target in ${TARGETS//,/ }; do + for suffix in "${suffixes[@]}"; do + found=(*-"${target/_/-}${suffix}") + if [ "${#found[@]}" -ne 1 ] || [ ! -f "${found[0]}.sha256" ]; then + echo "::error::nsgo build made ${#found[@]} files matching *-${target/_/-}${suffix}, not one with its .sha256" + exit 1 + fi + done + appcast="appcast-${target}.xml" + if [ "$REQUIRE_APPCAST" = "true" ] && { [ ! -f "$appcast" ] || [ ! -f "${appcast}.sha256" ] || ! grep -q 'sparkle:edSignature=' "$appcast"; }; then + echo "::error::nsgo build made no signed $appcast with its .sha256" + exit 1 + fi + done + if [ -n "$SCRIPTS" ] && { [ ! -f install.sh ] || [ ! -f install.ps1 ]; }; then + echo "::error::nsgo build made no install.sh or install.ps1" + exit 1 + fi + out="$RUNNER_TEMP/out" + mkdir -p "$out" + for file in *; do + [ -f "$file" ] || continue + case "$file" in + install.sh | install.ps1) [ -n "$SCRIPTS" ] || continue ;; + esac + cp -- "$file" "$out/" + done + ls -lh "$out" + - name: Upload editor packages + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: editor-${{ matrix.name }} + path: ${{ runner.temp }}/out/ + retention-days: 7 + if-no-files-found: error + - name: Clean up signing keychain and notary key + if: always() && steps.signing.outputs.keychain != '' + env: + KEYCHAIN: ${{ steps.signing.outputs.keychain }} + NOTARY_KEY: ${{ steps.signing.outputs.notary-key }} + run: | + rm -f "$NOTARY_KEY" + security delete-keychain "$KEYCHAIN" - version="$TAG" - title="NSGo Game ${version#v}" - if [[ "$version" == *-* ]]; then - gh release create "$TAG" --title "$title" --notes-file release-notes.md --prerelease - else - gh release create "$TAG" --title "$title" --notes-file release-notes.md + cli: + name: Build nsgo-game CLI + needs: meta + runs-on: depot-ubuntu-24.04-4 + timeout-minutes: 20 + steps: + - name: Check out + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Set up Go + uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 + with: + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + - name: Build and archive nsgo-game for all desktop platforms + env: + VERSION: ${{ needs.meta.outputs.version }} + run: | + set -euo pipefail + out="$RUNNER_TEMP/cli" + mkdir -p "$out" + for pair in darwin/arm64 darwin/amd64 linux/amd64 linux/arm64 windows/amd64 windows/arm64; do + goos="${pair%/*}" + goarch="${pair#*/}" + os_label="$goos" + [ "$goos" = "darwin" ] && os_label="macos" + arch_label="$goarch" + [ "$goarch" = "amd64" ] && arch_label="x64" + bin="nsgo-game" + [ "$goos" = "windows" ] && bin="nsgo-game.exe" + stage="$RUNNER_TEMP/stage-${os_label}-${arch_label}" + mkdir -p "$stage" + CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" go build -trimpath -o "$stage/$bin" ./cmd/nsgo-game + base="nsgo-game-${VERSION}-${os_label}-${arch_label}" + if [ "$goos" = "windows" ]; then + (cd "$stage" && zip -q "$out/${base}.zip" "$bin") + (cd "$out" && sha256sum "${base}.zip" > "${base}.zip.sha256") + else + tar -C "$stage" -czf "$out/${base}.tar.gz" "$bin" + (cd "$out" && sha256sum "${base}.tar.gz" > "${base}.tar.gz.sha256") + fi + done + ls -lh "$out" + - name: Upload CLI archives + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: cli-binaries + path: ${{ runner.temp }}/cli/ + retention-days: 7 + if-no-files-found: error + + release: + name: Publish release + needs: + - meta + - test + - check + - apple + - editor + - cli + if: >- + always() && + needs.meta.result == 'success' && + needs.editor.result == 'success' && + needs.cli.result == 'success' && + (needs.test.result == 'success' || needs.test.result == 'skipped') && + (needs.check.result == 'success' || needs.check.result == 'skipped') && + (needs.apple.result == 'success' || needs.apple.result == 'skipped') && + (needs.meta.outputs.mode == 'release' || needs.meta.outputs.mode == 'upload') + runs-on: depot-ubuntu-24.04-4 + timeout-minutes: 15 + permissions: + contents: write + steps: + - name: Download release notes + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: release-notes + path: ${{ runner.temp }} + - name: Download release assets + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: "*" + path: ${{ runner.temp }}/downloads + - name: Assemble and verify asset checksums + run: | + set -euo pipefail + assets="$RUNNER_TEMP/assets" + mkdir -p "$assets" + for dir in "$RUNNER_TEMP"/downloads/editor-* "$RUNNER_TEMP"/downloads/cli-binaries; do + [ -d "$dir" ] || continue + cp -- "$dir"/* "$assets/" + done + cd "$assets" + for sum in *.sha256; do + expected=$(cut -d' ' -f1 "$sum") + actual=$(sha256sum "${sum%.sha256}" | cut -d' ' -f1) + if [ "$expected" != "$actual" ]; then + echo "::error::${sum%.sha256} does not match its .sha256" + exit 1 + fi + done + ls -lh "$assets" + - name: Publish GitHub Release + env: + MODE: ${{ needs.meta.outputs.mode }} + TAG: ${{ needs.meta.outputs.tag }} + VERSION: ${{ needs.meta.outputs.version }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + if [ "$MODE" = "upload" ]; then + gh release upload "$TAG" --repo "$GITHUB_REPOSITORY" --clobber "$RUNNER_TEMP"/assets/* + exit 0 + fi + title="NSGo Game ${VERSION}" + prerelease=() + if [[ "$VERSION" == *-* ]]; then + prerelease=(--prerelease) fi + gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag --title "$title" --notes-file "$RUNNER_TEMP/release-notes.md" "${prerelease[@]}" "$RUNNER_TEMP"/assets/* diff --git a/README.md b/README.md index 380ee2101..6dfb5ff2e 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,13 @@ go tool nsgo dev go tool nsgo dev -target web ``` -Or launch the visual scene editor or install the coding-agent skill: +Or download the standalone desktop **NSGo Game Editor** from [GitHub Releases](https://github.com/nsgo-dev/game/releases/latest) (macOS `.dmg`, Windows `-setup.exe`, Linux `.AppImage`/`.deb`/`.pkg.tar.gz`), launch it from Go, or install the coding-agent skill: ```sh -# Open the visual 2D/3D scene editor +# Install the standalone NSGo Game Editor (macOS / Linux) +curl -fsSL https://github.com/nsgo-dev/game/releases/latest/download/install.sh | sh + +# Or run the scene editor directly via Go go run github.com/nsgo-dev/game/cmd/game@latest editor # Install the Agent Skill for coding agents diff --git a/changelog.d/release-editor-packages.md b/changelog.d/release-editor-packages.md new file mode 100644 index 000000000..aac4fd6d8 --- /dev/null +++ b/changelog.d/release-editor-packages.md @@ -0,0 +1,3 @@ +### Added + +- `cmd/editor`: standalone desktop application entrypoint (`NSGo Game Editor`) packaged and signed automatically on releases across macOS (`arm64`/`x64` `.dmg`, Developer ID signed and notarized), Linux (`x64`/`arm64` `.deb`, `.pkg.tar.gz`, `.AppImage`), and Windows (`x64`/`arm64` `-setup.exe`), alongside signed update appcasts, `install.sh`/`install.ps1` scripts, and prebuilt `nsgo-game` CLI archives. diff --git a/cmd/editor/main.go b/cmd/editor/main.go new file mode 100644 index 000000000..339f08527 --- /dev/null +++ b/cmd/editor/main.go @@ -0,0 +1,30 @@ +// Command editor is the standalone desktop application for the NSGo Game Editor. +// Launched with no arguments (such as by double-clicking the packaged desktop app), +// it opens on the Start Screen with recent projects, templates, and the built-in demo. +// Arguments match `nsgo game editor`: an optional -library index, a project directory, +// game.yaml, or scene YAML file, and optionally an animation clip and object ID. +package main + +import ( + "os" + "strings" + + "github.com/nsgo-dev/game/internal/gamecli" +) + +func main() { + os.Exit(gamecli.Run(editorArgs(os.Args[1:]))) +} + +// editorArgs prefixes the editor subcommand and drops macOS Finder's -psn_* process serial flag. +func editorArgs(args []string) []string { + out := make([]string, 0, len(args)+1) + out = append(out, "editor") + for _, a := range args { + if strings.HasPrefix(a, "-psn_") { + continue + } + out = append(out, a) + } + return out +} diff --git a/cmd/editor/main_test.go b/cmd/editor/main_test.go new file mode 100644 index 000000000..344611486 --- /dev/null +++ b/cmd/editor/main_test.go @@ -0,0 +1,37 @@ +package main + +import ( + "os/exec" + "path/filepath" + "slices" + "strings" + "testing" +) + +func TestEditorArgs(t *testing.T) { + got := editorArgs([]string{"-psn_0_12345", "scenes/main.scene.yaml"}) + want := []string{"editor", "scenes/main.scene.yaml"} + if !slices.Equal(got, want) { + t.Fatalf("editorArgs = %v, want %v", got, want) + } + + gotEmpty := editorArgs(nil) + wantEmpty := []string{"editor"} + if !slices.Equal(gotEmpty, wantEmpty) { + t.Fatalf("editorArgs(nil) = %v, want %v", gotEmpty, wantEmpty) + } +} + +func TestEditorBinaryBuildsAndShowsHelp(t *testing.T) { + bin := filepath.Join(t.TempDir(), "nsgo-game-editor") + if out, err := exec.Command("go", "build", "-o", bin, ".").CombinedOutput(); err != nil { + t.Fatalf("go build ./cmd/editor: %v\n%s", err, out) + } + out, err := exec.Command(bin, "-help").CombinedOutput() + if err != nil { + t.Fatalf("editor -help: %v\n%s", err, out) + } + if !strings.Contains(string(out), "usage: game editor") { + t.Errorf("editor -help output = %q, want usage line", out) + } +} diff --git a/cmd/editor/nsgo.yaml b/cmd/editor/nsgo.yaml new file mode 100644 index 000000000..0dc789bd6 --- /dev/null +++ b/cmd/editor/nsgo.yaml @@ -0,0 +1,23 @@ +name: NSGo Game Editor +id: dev.nsgo.game.editor +version: 0.1.0 +build_number: 1 +copyright: "© 2026 NSGo authors" + +icon: + png: ../../apps/website/public/icon.png + +# Public key matching the organization's NSGO_UPDATES_KEY secret so releases write signed appcasts. +updates: + key: 8+lMn9ixDn7sbqoWxwRKQDGiZ6wwtfjRXos/4GQNURk= + +dev: + target: native + +build: + output: dist + open: false + targets: [macos_arm64, macos_x64, linux_x64, linux_arm64, windows_x64, windows_arm64] + +release: + github: nsgo-dev/game diff --git a/docs/en/editor.md b/docs/en/editor.md index 504c6e7ed..e4dbe49c5 100644 --- a/docs/en/editor.md +++ b/docs/en/editor.md @@ -2,6 +2,8 @@ This document records the scope decision for NSGo's game editor ([#159](https://github.com/nsgo-dev/game/issues/159)) and specifies the version 1 YAML scene format ([#160](https://github.com/nsgo-dev/game/issues/160)) implemented in `github.com/nsgo-dev/game/pkg/sceneformat`. +Prebuilt desktop installers for **NSGo Game Editor** (`cmd/editor`)—signed and notarized `.dmg` images for macOS (`arm64` / `x64`), `-setup.exe` installers for Windows (`x64` / `arm64`), and `.deb` / `.pkg.tar.gz` / `.AppImage` packages for Linux (`x64` / `arm64`)—are published on [GitHub Releases](https://github.com/nsgo-dev/game/releases/latest), alongside one-line installers (`install.sh` / `install.ps1`) and prebuilt `nsgo-game` CLI archives. You can also launch the editor directly via `nsgo game editor` or `go run ./cmd/editor`. + ## Editor Scope Decision (#159) NSGo takes **option (b) growing into (c)**: keep Go code and Tiled first-class, define a clean human-editable YAML scene format shared by hand-authored scenes and tooling, and build a lightweight NSGo-native scene editor on top of it. diff --git a/docs/en/stability.md b/docs/en/stability.md index dc68758e6..38bef84d7 100644 --- a/docs/en/stability.md +++ b/docs/en/stability.md @@ -62,6 +62,7 @@ Paths are relative to `github.com/nsgo-dev`. The table is checked by a test in t | Package | Status | Guide | | --- | --- | --- | | `game` | Stable | [Loop](loop.md) | +| `game/cmd/editor` | Experimental | [Scene Editor](editor.md) | | `game/cmd/game` | Experimental | [Command Line](cli.md) | | `game/cmd/gameapi` | Experimental | | | `game/cmd/gameproject` | Experimental | [Project File](project.md) | diff --git a/docs/zh/editor.md b/docs/zh/editor.md index 90691f513..be46c4ed9 100644 --- a/docs/zh/editor.md +++ b/docs/zh/editor.md @@ -2,6 +2,8 @@ 本文档记录 NSGo 游戏编辑器的范围决策([#159](https://github.com/nsgo-dev/game/issues/159)),并说明 `github.com/nsgo-dev/game/pkg/sceneformat` 实现的第 1 版 YAML 场景格式([#160](https://github.com/nsgo-dev/game/issues/160))。 +独立桌面版 **NSGo Game Editor**(`cmd/editor`)安装包已在 [GitHub Releases](https://github.com/nsgo-dev/game/releases/latest) 自动发布——包含经组织 Developer ID 签名与 Apple 公证的 macOS `.dmg`(`arm64` / `x64`)、Windows `-setup.exe`(`x64` / `arm64`)与 Linux `.deb` / `.pkg.tar.gz` / `.AppImage`(`x64` / `arm64`),并附带一键安装脚本(`install.sh` / `install.ps1`)与预编译 `nsgo-game` 命令行工具。也可通过 `nsgo game editor` 或 `go run ./cmd/editor` 直接启动。 + ## 编辑器范围决策(#159) NSGo 采用**方案(b)并向(c)演进**:保持 Go 代码与 Tiled 的一等公民地位,定义一套清晰、适合人手编写的 YAML 场景格式供手写场景与工具共用,并在此基础上逐步构建一个轻量级 NSGo 原生场景编辑器。 diff --git a/docs/zh/stability.md b/docs/zh/stability.md index 86e4d14a9..312089051 100644 --- a/docs/zh/stability.md +++ b/docs/zh/stability.md @@ -62,6 +62,7 @@ | 包 | 状态 | 指南 | | --- | --- | --- | | `game` | 稳定 | [Loop](loop.md) | +| `game/cmd/editor` | 实验性 | [场景编辑器](editor.md) | | `game/cmd/game` | 实验性 | [命令行](cli.md) | | `game/cmd/gameapi` | 实验性 | | | `game/cmd/gameproject` | 实验性 | [项目文件](project.md) | diff --git a/skills/nsgo-game/references/packages.md b/skills/nsgo-game/references/packages.md index 4dd569c43..411326296 100644 --- a/skills/nsgo-game/references/packages.md +++ b/skills/nsgo-game/references/packages.md @@ -161,6 +161,7 @@ Every non-internal package under `github.com/nsgo-dev` (shown relative to that p | --- | --- | --- | | `game/pkg/project` | Experimental | `game.yaml` parser, canonical encoder and `nsgo.yaml` consistency checker | | `game/pkg/refs` | Experimental | Stable file UIDs, project index and reference-rewriting file moves | +| `game/cmd/editor` | Experimental | Standalone desktop application entrypoint for the NSGo Game Editor | | `game/cmd/game` | Experimental | The `nsgo game` CLI | | `game/cmd/gameapi` | Experimental | Generates API reference JSON from package doc comments | | `game/cmd/gameproject` | Experimental | Formats and checks `game.yaml` against `nsgo.yaml` |