-
-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathappveyor.yml
More file actions
181 lines (167 loc) · 8.46 KB
/
Copy pathappveyor.yml
File metadata and controls
181 lines (167 loc) · 8.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
version: '{build}'
skip_non_tags: true
skip_branch_with_pr: true
matrix:
fast_finish: true
# https://www.appveyor.com/docs/build-environment/#build-worker-images
image: Visual Studio 2022
environment:
GOFLAGS: -mod=mod
GOPROXY: https://proxy.golang.org,direct
GOSUMDB: sum.golang.org
# go.mod requires 1.26.3; AppVeyor VS2022 image may only ship C:\go (1.25.x).
GOTOOLCHAIN: go1.26.3+auto
WAILS3_VERSION: v3.0.0-alpha.102
DATEVERSION: $(APPVEYOR_REPO_TAG_NAME)
SIGNPATH_ORGANIZATION_ID: "a2a88c4e-72da-4d2c-925e-91f41aff9d77"
SIGNPATH_PROJECT_SLUG: "TcNo-Acc-Switcher"
SIGNPATH_POLICY_SLUG: "test-signing"
# Origin verification is triggered by the deploy Webhook below (not the deploy script).
SIGNPATH_TRIGGER_VIA_WEBHOOK: "true"
SIGNPATH_API_TOKEN:
secure: nCxtLCPGtKTrnt0aDyNiCJja492RG+t4+Z/zDMOWQKQgGOOXWhO1AXuGEzGu7j55
github_release_token:
secure: 1HFaonHaIKyvSv76Nf4j1RDHbeWJBF9laym2kreewJBKLhFHQ3k6MWQ3dZlFQ0QloTW0DpYWdpLth0ALUu/ejE8WwoalGgptnYi70EK+Uq5EnS0vq/1ltrzr9XLvznHJ
pull_requests:
do_not_increment_build_number: true
init:
- ps: |
# pnpm/vite and wails3 log to stderr; PS 7 treats that as NativeCommandError.
$ErrorActionPreference = 'Continue'
if (Get-Variable -Name PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
$PSNativeCommandUseErrorActionPreference = $false
}
- ps: Write-Host "APPVEYOR_REPO_TAG_NAME is $env:APPVEYOR_REPO_TAG_NAME"
- ps: Write-Host "DATEVERSION is $env:DATEVERSION"
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
install:
- ps: |
# C:\go126 exists on newer AppVeyor images; C:\go is the default fallback.
$goRoot = $null
foreach ($candidate in @('C:\go126', 'C:\go')) {
if (Test-Path "$candidate\bin\go.exe") {
$goRoot = $candidate
break
}
}
if (-not $goRoot) {
throw 'No Go installation found under C:\go126 or C:\go'
}
$env:GOROOT = $goRoot
$env:Path = "$goRoot\bin;$env:Path"
Write-Host "Go toolchain: $(((cmd /c 'go version 2>&1') | Out-String).Trim())"
Write-Host "GOROOT=$env:GOROOT GOTOOLCHAIN=$env:GOTOOLCHAIN"
$goMod = Join-Path $env:APPVEYOR_BUILD_FOLDER 'go.mod'
if (-not (Test-Path $goMod)) {
throw "go.mod not found at $goMod"
}
$requiredGo = (Select-String -Path $goMod -Pattern '^go\s+(\S+)' | ForEach-Object { $_.Matches[0].Groups[1].Value })
$actualGo = ((cmd /c 'go env GOVERSION 2>&1') | Out-String).Trim() -replace '^go', ''
if ($actualGo -ne $requiredGo) {
Write-Host "VM Go is $actualGo; fetching go $requiredGo via GOTOOLCHAIN=go$requiredGo+auto"
$env:GOTOOLCHAIN = "go$requiredGo+auto"
go version 2>&1 | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$actualGo = ((cmd /c 'go env GOVERSION 2>&1') | Out-String).Trim() -replace '^go', ''
if ($actualGo -ne $requiredGo) {
throw "Failed to activate go $requiredGo (still on $actualGo, GOROOT=$goRoot)."
}
}
Write-Host "Using Go $actualGo (GOROOT=$env:GOROOT, GOTOOLCHAIN=$env:GOTOOLCHAIN)"
- ps: Install-Module -Name SignPath -RequiredVersion 4.4.6 -Force -Scope CurrentUser
- npm install -g pnpm@11.0.8
- ps: |
Write-Host "pnpm version: $(pnpm --version)"
- ps: |
$env:Path = "$env:USERPROFILE\go\bin;$env:Path"
function Get-Wails3VersionText {
# wails3 prints its version to stderr; cmd avoids PowerShell NativeCommandError noise in CI logs
return (& cmd /c "wails3 version 2>&1").Trim()
}
$wails3Exe = Join-Path $env:USERPROFILE 'go\bin\wails3.exe'
if ((Test-Path $wails3Exe) -and ((Get-Wails3VersionText) -match [regex]::Escape($env:WAILS3_VERSION))) {
Write-Host "wails3 $($env:WAILS3_VERSION) already installed."
} else {
Write-Host "Installing wails3 $($env:WAILS3_VERSION) (pinned; do not use @latest)..."
go install "github.com/wailsapp/wails/v3/cmd/wails3@$($env:WAILS3_VERSION)" 2>&1 | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Host "wails3 installed: $(Get-Wails3VersionText)"
}
- ps: |
& "$env:APPVEYOR_BUILD_FOLDER\other\NSIS\nsis7zplugin.ps1"
- set PATH=%USERPROFILE%\go\bin;%PATH%
- ps: |
$tag = $env:DATEVERSION -replace '^v', ''
if (-not $tag) { $tag = $env:APPVEYOR_REPO_TAG_NAME -replace '^v', '' }
$nums = @()
foreach ($m in [regex]::Matches($tag, '\d+')) { $nums += [int]$m.Value }
if ($nums.Count -eq 0) { throw "Tag '$tag' has no numeric version for NSIS." }
while ($nums.Count -lt 4) { $nums += 0 }
if ($nums.Count -gt 4) { $nums = $nums[0..3] }
$nsisVersion = $nums -join '.'
$env:APP_VERSION = $tag
$env:NSIS_VERSION = $nsisVersion
Write-Host "Tag: $env:DATEVERSION Display: $tag NSIS VIProductVersion: $nsisVersion"
$configPath = "$env:APPVEYOR_BUILD_FOLDER\build\config.yml"
$config = [System.IO.File]::ReadAllText($configPath)
$config = $config -replace '(?m)^(\s+)version:\s*"[^"]*"', "`${1}version: `"$tag`""
[System.IO.File]::WriteAllText($configPath, $config, [System.Text.UTF8Encoding]::new($false))
$infoPath = "$env:APPVEYOR_BUILD_FOLDER\build\windows\info.json"
$info = [System.IO.File]::ReadAllText($infoPath)
$info = $info -replace '"file_version":\s*"[^"]*"', "`"file_version`": `"$nsisVersion`""
$info = $info -replace '"ProductVersion":\s*"[^"]*"', "`"ProductVersion`": `"$nsisVersion`""
[System.IO.File]::WriteAllText($infoPath, $info, [System.Text.UTF8Encoding]::new($false))
Write-Host "config.yml and info.json updated."
- ps: |
Push-Location "$env:APPVEYOR_BUILD_FOLDER\frontend"
pnpm install --frozen-lockfile
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Pop-Location
build_script:
- wails3 generate bindings -f "-tags production" -clean=true -ts
- ps: |
Push-Location "$env:APPVEYOR_BUILD_FOLDER\frontend"
$env:PRODUCTION = "true"
pnpm run build
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Pop-Location
- ps: cd build; wails3 generate icons -input appicon.png -macfilename darwin/icons.icns -windowsfilename windows/icon.ico; cd ..
- ps: Copy-Item -Force "$env:APPVEYOR_BUILD_FOLDER\other\NSIS\img\icon.ico" "$env:APPVEYOR_BUILD_FOLDER\build\windows\icon.ico"
- ps: cd build; wails3 generate syso -arch amd64 -icon windows/icon.ico -manifest windows/wails.exe.manifest -info windows/info.json -out ..\wails_windows_amd64.syso; cd ..
- go build -tags production -trimpath -buildvcs=false -ldflags="-w -s -H windowsgui" -o bin\TcNo-Acc-Switcher.exe
- ps: Remove-Item -Force *.syso
after_build:
- ps: |
Write-Host "NSIS VIProductVersion: $env:NSIS_VERSION"
Write-Host "NSIS DisplayVersion: $env:DATEVERSION"
Write-Host "Copying NSIS images..."
$imgDest = "$env:APPVEYOR_BUILD_FOLDER\build\windows\nsis\img"
New-Item -ItemType Directory -Force -Path $imgDest | Out-Null
Copy-Item -Force "$env:APPVEYOR_BUILD_FOLDER\other\NSIS\img\*" $imgDest
Write-Host "Fetching WebView2 bootstrapper..."
$nsisDir = "$env:APPVEYOR_BUILD_FOLDER\build\windows\nsis"
# wails3 logs to stderr; PS 7 treats that as NativeCommandError without this guard.
$ErrorActionPreference = 'Continue'
if (Get-Variable -Name PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
$PSNativeCommandUseErrorActionPreference = $false
}
wails3 generate webview2bootstrapper -dir $nsisDir 2>&1 | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$bootstrapper = Join-Path $nsisDir 'MicrosoftEdgeWebview2Setup.exe'
if (-not (Test-Path $bootstrapper)) {
throw "WebView2 bootstrapper was not created at $bootstrapper"
}
artifacts:
- path: bin\TcNo-Acc-Switcher.exe
name: executable
deploy:
- provider: Webhook
url: https://app.signpath.io/API/v1/%SIGNPATH_ORGANIZATION_ID%/Integrations/AppVeyor?ProjectSlug=%SIGNPATH_PROJECT_SLUG%&SigningPolicySlug=%SIGNPATH_POLICY_SLUG%
authorization: Bearer $(SIGNPATH_API_TOKEN)
request_timeout: 10
on:
APPVEYOR_REPO_TAG: true
after_deploy:
- ps: . "$env:APPVEYOR_BUILD_FOLDER\ci\appveyor-deploy.ps1"
#on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))