ci(release): sign Windows executable #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| frontend-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: bun install --frozen-lockfile | |
| - name: Lint | |
| working-directory: frontend | |
| run: bun run lint | |
| - name: Typecheck | |
| working-directory: frontend | |
| run: bun run typecheck | |
| go-test: | |
| runs-on: ubuntu-latest | |
| needs: [frontend-check] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.x" | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: bun install --frozen-lockfile | |
| - name: Build frontend (needed for go:embed) | |
| working-directory: frontend | |
| run: bun run build | |
| - name: Download Go dependencies | |
| run: go mod download | |
| - name: Run tests | |
| run: go test ./... | |
| go-build: | |
| runs-on: ubuntu-latest | |
| needs: [go-test] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.x" | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: bun install --frozen-lockfile | |
| - name: Build frontend (needed for go:embed) | |
| working-directory: frontend | |
| run: bun run build | |
| - name: Download Go dependencies | |
| run: go mod download | |
| - name: Build | |
| run: go build ./... | |
| windows-portable-build: | |
| runs-on: windows-latest | |
| needs: [frontend-check] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.x" | |
| - name: Install Wails CLI | |
| run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.13.0 | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: bun install --frozen-lockfile | |
| - name: Verify frontend | |
| working-directory: frontend | |
| run: | | |
| bun run test | |
| bun run lint | |
| bun run typecheck | |
| - name: Build frontend for Go embed | |
| working-directory: frontend | |
| run: bun run build | |
| - name: Run Go tests | |
| run: go test ./... | |
| - name: Build portable Windows executable | |
| run: wails build -platform windows/amd64 -clean | |
| - name: Upload portable executable | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: adbkit-windows-amd64 | |
| path: build/bin/ADBKit.exe | |
| windows-signed-release: | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: windows-latest | |
| environment: release | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25.x" | |
| - name: Install Wails CLI | |
| run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.13.0 | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: bun install --frozen-lockfile | |
| - name: Build signed release candidate | |
| run: wails build -platform windows/amd64 -clean | |
| - name: Sign and verify executable | |
| shell: pwsh | |
| env: | |
| WINDOWS_SIGNING_CERTIFICATE_BASE64: ${{ secrets.WINDOWS_SIGNING_CERTIFICATE_BASE64 }} | |
| WINDOWS_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PASSWORD }} | |
| WINDOWS_TIMESTAMP_URL: ${{ vars.WINDOWS_TIMESTAMP_URL }} | |
| run: | | |
| if ([string]::IsNullOrWhiteSpace($env:WINDOWS_SIGNING_CERTIFICATE_BASE64) -or [string]::IsNullOrWhiteSpace($env:WINDOWS_SIGNING_CERTIFICATE_PASSWORD)) { | |
| throw "Windows signing certificate secrets are required." | |
| } | |
| $certificatePath = Join-Path $env:RUNNER_TEMP "adbkit-signing.pfx" | |
| try { | |
| [IO.File]::WriteAllBytes($certificatePath, [Convert]::FromBase64String($env:WINDOWS_SIGNING_CERTIFICATE_BASE64)) | |
| $timestampUrl = $env:WINDOWS_TIMESTAMP_URL | |
| if ([string]::IsNullOrWhiteSpace($timestampUrl)) { | |
| $timestampUrl = "http://timestamp.digicert.com" | |
| } | |
| signtool sign /fd SHA256 /f $certificatePath /p $env:WINDOWS_SIGNING_CERTIFICATE_PASSWORD /tr $timestampUrl /td SHA256 build/bin/ADBKit.exe | |
| signtool verify /pa /all /v build/bin/ADBKit.exe | |
| } | |
| finally { | |
| Remove-Item -Force -ErrorAction SilentlyContinue $certificatePath | |
| } | |
| - name: Upload signed executable | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: adbkit-windows-amd64-signed | |
| path: build/bin/ADBKit.exe |