Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Windows desktop app that syncs game saves between a user's PCs (via a bundled/lo
- Install: `cd frontend && npm install` (Wails also runs this on build)
- Dev: `wails dev`
- Build: `wails build` → `build/bin/Syncer.exe` (`-nsis` for the installer). This is the public release: no mods, Google sign-in or launcher integration.
- Personal build: `wails build -tags personal` (the owner's build with all of those; it never installs the public release over itself). Dev with it: `wails dev -tags personal`.
- Personal build: `scripts/build-personal.ps1` (runs `wails build -tags personal -nsis` with the Google client from `.env.personal`; the owner's build with all of those; it never installs the public release over itself). Dev with it: `wails dev -tags personal`.
- Typecheck: `cd frontend && npm run check` (svelte-check)
- Test: `go test ./...` and `go test -tags personal ./...` and `cd frontend && npm test` (Vitest)
- Full gate before a PR (what CI runs): the check command below without `-short`, plus `wails build`
Expand Down
2 changes: 2 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ If a published release is bad, mark it as a draft again (or delete it) so the up
## Personal build

`wails build -tags personal` makes the maintainer's build (see [CONTRIBUTING.md](CONTRIBUTING.md#builds-public-vs-personal)). It is built locally, with the Google client passed through `-ldflags`, and is never published or attached to a release. CI only builds the public one.

`scripts/build-personal.ps1` builds it with its installer into `build\bin`. It reads the Google client from `.env.personal` at the repo root (gitignored; `GDRIVE_CLIENT_ID=…` and `GDRIVE_CLIENT_SECRET=…` on their own lines) or from environment variables of the same names, and stamps the version as the last tag plus the commit (`v1.0.0+personal.3a79b1e`). The personal build doesn't update itself: when it says a new release is out, pull `main` and run the script again. The exe contains the Google client, so don't share it.
49 changes: 49 additions & 0 deletions scripts/build-personal.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Builds the personal build (mods, Google sign-in, launcher API) with its
# installer into build\bin. It never updates itself, so pull and run this again
# to update. See RELEASING.md, "Personal build".
#
# The Google client comes from .env.personal at the repo root (gitignored):
# GDRIVE_CLIENT_ID=...
# GDRIVE_CLIENT_SECRET=...
# or from environment variables of the same names. Without it the build hides
# Sign in with Google.
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
Set-Location $root

$client = @{ GDRIVE_CLIENT_ID = $env:GDRIVE_CLIENT_ID; GDRIVE_CLIENT_SECRET = $env:GDRIVE_CLIENT_SECRET }
$file = Join-Path $root '.env.personal'
if (Test-Path $file) {
foreach ($line in Get-Content $file) {
if ($line -match '^\s*(GDRIVE_CLIENT_ID|GDRIVE_CLIENT_SECRET)\s*=\s*(.*?)\s*$') {
$client[$Matches[1]] = $Matches[2].Trim('"', "'")
}
}
}
if (-not $client.GDRIVE_CLIENT_ID -or -not $client.GDRIVE_CLIENT_SECRET) {
Write-Warning 'No Google client (.env.personal or GDRIVE_CLIENT_ID/GDRIVE_CLIENT_SECRET): Sign in with Google will be hidden.'
}

# The last release tag plus this commit, e.g. v1.0.0+personal.3a79b1e. Build
# metadata is ignored when versions are compared, so the app still says when a
# newer release is out: the cue to rebuild.
$tag = git describe --tags --abbrev=0 --match 'v*' 2>$null
if (-not $tag) { $tag = 'v0.0.0' }
$commit = git rev-parse --short HEAD
# Ignores what wails build itself rewrites (installer template, dist, line endings).
git diff --quiet HEAD -- . ':!build/windows/installer' ':!frontend/dist'
if ($LASTEXITCODE -ne 0) { $commit += '.dirty' }
$version = "$tag+personal.$commit"

$ldflags = "-s -w -X main.version=$version"
if ($client.GDRIVE_CLIENT_ID -and $client.GDRIVE_CLIENT_SECRET) {
$ldflags += " -X main.gdriveClientID=$($client.GDRIVE_CLIENT_ID) -X main.gdriveClientSecret=$($client.GDRIVE_CLIENT_SECRET)"
}

Write-Host "Building Syncer $version (personal)"
wails build -clean -nsis -trimpath -tags personal -ldflags $ldflags
if ($LASTEXITCODE -ne 0) { throw "wails build failed ($LASTEXITCODE)" }
if (-not (Test-Path build\bin\Syncer-amd64-installer.exe)) {
Write-Warning 'No installer: install NSIS (winget install NSIS.NSIS) and run this again, or use build\bin\Syncer.exe as is.'
}
Get-ChildItem build\bin\Syncer*.exe | ForEach-Object { Write-Host "Built $($_.FullName)" }