diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf0dc15..85b6e56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,9 +138,13 @@ jobs: go-version-file: go.mod - run: bun install --frozen-lockfile - run: bun run build + # In two stages, as the release runs it to sign lowquery.exe in between. + - name: Build lowquery.exe + shell: bash + run: bash packaging/windows/build.sh exe - name: Build the setup and the portable zip shell: bash - run: bash packaging/windows/build.sh + run: bash packaging/windows/build.sh package - name: Download the Tauri setup shell: bash env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 263d43f..c72e4fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,9 +64,83 @@ jobs: go-version-file: go.mod - run: bun install --frozen-lockfile - run: bun run build + - name: Build lowquery.exe + shell: bash + run: bash packaging/windows/build.sh exe + # Authenticode signing through SignPath Foundation, on once the repository + # has the SIGNPATH_ORGANIZATION_ID variable and the SIGNPATH_API_TOKEN + # secret (artifact configurations in packaging/windows/signpath). Each + # request waits for a maintainer to approve it in SignPath. SignPath does + # not sign inside NSIS installers, so lowquery.exe is signed first, the + # setup and the zip are built from it, and then the setup is signed. + - name: Upload lowquery.exe for signing + id: unsigned-exe + if: vars.SIGNPATH_ORGANIZATION_ID != '' + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 + with: + name: unsigned-lowquery-exe + path: build/windows/lowquery.exe + if-no-files-found: error + - name: Sign lowquery.exe (approve in SignPath) + if: vars.SIGNPATH_ORGANIZATION_ID != '' + uses: signpath/github-action-submit-signing-request@a2c5b60d9c75f073142b653c354b632eedce097b # v3.2 + with: + api-token: ${{ secrets.SIGNPATH_API_TOKEN }} + organization-id: ${{ vars.SIGNPATH_ORGANIZATION_ID }} + project-slug: ${{ vars.SIGNPATH_PROJECT_SLUG || 'LowQuery' }} + signing-policy-slug: ${{ vars.SIGNPATH_SIGNING_POLICY_SLUG || 'release-signing' }} + artifact-configuration-slug: lowquery-exe + github-artifact-id: ${{ steps.unsigned-exe.outputs.artifact-id }} + wait-for-completion-timeout-in-seconds: 10800 + output-artifact-directory: build/signed-exe + parameters: | + version: ${{ toJSON(env.VERSION) }} + - name: Use the signed lowquery.exe + if: vars.SIGNPATH_ORGANIZATION_ID != '' + shell: pwsh + run: | + $sig = Get-AuthenticodeSignature build/signed-exe/lowquery.exe + if ($sig.Status -ne 'Valid') { throw "lowquery.exe: $($sig.Status) $($sig.StatusMessage)" } + $sig.SignerCertificate.Subject + Copy-Item build/signed-exe/lowquery.exe build/windows/lowquery.exe -Force - name: Build the setup and the portable zip shell: bash - run: bash packaging/windows/build.sh + run: bash packaging/windows/build.sh package + - name: Upload the setup for signing + id: unsigned-setup + if: vars.SIGNPATH_ORGANIZATION_ID != '' + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 + with: + name: unsigned-setup + path: build/release/LowQuery-${{ env.VERSION }}-windows-x64-setup.exe + if-no-files-found: error + - name: Sign the setup (approve in SignPath) + if: vars.SIGNPATH_ORGANIZATION_ID != '' + uses: signpath/github-action-submit-signing-request@a2c5b60d9c75f073142b653c354b632eedce097b # v3.2 + with: + api-token: ${{ secrets.SIGNPATH_API_TOKEN }} + organization-id: ${{ vars.SIGNPATH_ORGANIZATION_ID }} + project-slug: ${{ vars.SIGNPATH_PROJECT_SLUG || 'LowQuery' }} + signing-policy-slug: ${{ vars.SIGNPATH_SIGNING_POLICY_SLUG || 'release-signing' }} + artifact-configuration-slug: setup-exe + github-artifact-id: ${{ steps.unsigned-setup.outputs.artifact-id }} + wait-for-completion-timeout-in-seconds: 10800 + output-artifact-directory: build/signed-setup + parameters: | + version: ${{ toJSON(env.VERSION) }} + - name: Use the signed setup + if: vars.SIGNPATH_ORGANIZATION_ID != '' + shell: pwsh + run: | + $name = "LowQuery-$env:VERSION-windows-x64-setup.exe" + $sig = Get-AuthenticodeSignature "build/signed-setup/$name" + if ($sig.Status -ne 'Valid') { throw "${name}: $($sig.Status) $($sig.StatusMessage)" } + Copy-Item "build/signed-setup/$name" "build/release/$name" -Force + # The zip carries the same signed lowquery.exe as the setup. + Remove-Item -Recurse -Force build/zipcheck -ErrorAction SilentlyContinue + Expand-Archive "build/release/LowQuery-$env:VERSION-windows-x64-portable.zip" build/zipcheck + $inner = Get-AuthenticodeSignature build/zipcheck/LowQuery.exe + if ($inner.Status -ne 'Valid') { throw "LowQuery.exe in the zip: $($inner.Status)" } - name: Sign the setup for the updater shell: bash env: @@ -175,6 +249,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} VERSION: ${{ needs.verify.outputs.version }} + SIGNPATH_ORGANIZATION_ID: ${{ vars.SIGNPATH_ORGANIZATION_ID }} run: | set -euo pipefail # A maintainer usually writes the notes in a draft before the build @@ -183,6 +258,17 @@ jobs: gh release create "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --verify-tag \ --generate-notes --draft --title "LowQuery $VERSION" fi + # SignPath Foundation asks for the code signing policy on every + # release page. + if [ -n "$SIGNPATH_ORGANIZATION_ID" ]; then + body="$(gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --json body -q .body)" + if ! grep -qi 'code signing policy' <<<"$body"; then + printf '%s\n\n%s\n' "$body" \ + "Windows files are signed through SignPath Foundation: see the [code signing policy](https://github.com/$GITHUB_REPOSITORY#code-signing-policy)." \ + > notes.md + gh release edit "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --notes-file notes.md + fi + fi - name: Write the updater manifest (latest.json) shell: bash env: diff --git a/README.md b/README.md index 71e8988..8d86235 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,19 @@ gh attestation verify LowQuery--linux-x64.AppImage --repo LowBloat/LowQ - **Windows:** SmartScreen shows "Windows protected your PC". Choose **More info → Run anyway**. - **macOS:** Gatekeeper may say the app "is damaged" or "cannot be opened". Right-click LowQuery in Applications and choose **Open**, or run `xattr -dr com.apple.quarantine /Applications/LowQuery.app` once. +### Code signing policy + +Free code signing provided by [SignPath.io](https://about.signpath.io), certificate by [SignPath Foundation](https://signpath.org). + +The Windows executable and setup are built from this repository by the [release workflow](.github/workflows/release.yml) on GitHub-hosted runners and signed only after a maintainer approves each release in SignPath. + +- Committers and reviewers: [Fábio Henrique Araújo](https://github.com/FabioHAraujo) +- Approvers: [Fábio Henrique Araújo](https://github.com/FabioHAraujo) + +Changes from people outside the team come in as pull requests and are reviewed before they are merged. + +**Privacy.** LowQuery sends no telemetry and has no account. It connects only to the databases you add, and on its own it makes just one kind of request: it downloads `latest.json` from this repository's GitHub Releases to look for a new version. That request carries no data about you or your databases beyond what any HTTPS request to GitHub does. The Windows setup downloads Microsoft's WebView2 runtime only if the system does not have it. Passwords stay in the system keychain, and AI agents reach your databases only through the `lowquery mcp` server you set up for them. + ### Run your first query 1. Open LowQuery and choose **New connection**. diff --git a/packaging/windows/build.sh b/packaging/windows/build.sh index 284bb97..b326952 100644 --- a/packaging/windows/build.sh +++ b/packaging/windows/build.sh @@ -3,29 +3,52 @@ # build/release/LowQuery--windows-x64-setup.exe NSIS setup (updater file) # build/release/LowQuery--windows-x64-portable.zip LowQuery.exe, README, LICENSE # Needs dist/ (bun run build), Go and makensis (MAKENSIS overrides the path). +# +# The release signs in between, so the build runs in stages: +# build.sh exe build/windows/lowquery.exe +# build.sh package the setup and the zip from build/windows/lowquery.exe +# build.sh both set -euo pipefail cd "$(dirname "$0")/../.." source packaging/common.sh +stage="${1:-all}" +case "$stage" in +exe | package | all) ;; +*) + echo "usage: build.sh [exe|package]" >&2 + exit 2 + ;; +esac version="$(app_version)" -require_dist work=build/windows -rm -rf "$work" -mkdir -p "$work" "$RELEASE_DIR" - -# Icon, version information and manifest (DPI awareness, Common Controls 6), -# compiled into a .syso that go build links into package main. Wails' own -# build generates it the same way and deletes it afterwards. -render packaging/windows/info.json "$version" "$work/info.json" -render packaging/windows/lowquery.exe.manifest "$version" "$work/lowquery.exe.manifest" -syso="$PWD/wails_windows_amd64.syso" -trap 'rm -f "$syso"' EXIT -wails3 generate syso -arch amd64 -icon packaging/icons/icon.ico \ - -manifest "$work/lowquery.exe.manifest" -info "$work/info.json" -out "$syso" - -GOOS=windows GOARCH=amd64 go build -tags production -trimpath \ - -ldflags "-s -w -H windowsgui" -o "$work/lowquery.exe" . -rm -f "$syso" +mkdir -p "$RELEASE_DIR" + +if [ "$stage" != package ]; then + require_dist + rm -rf "$work" + mkdir -p "$work" + + # Icon, version information and manifest (DPI awareness, Common Controls 6), + # compiled into a .syso that go build links into package main. Wails' own + # build generates it the same way and deletes it afterwards. + render packaging/windows/info.json "$version" "$work/info.json" + render packaging/windows/lowquery.exe.manifest "$version" "$work/lowquery.exe.manifest" + syso="$PWD/wails_windows_amd64.syso" + trap 'rm -f "$syso"' EXIT + wails3 generate syso -arch amd64 -icon packaging/icons/icon.ico \ + -manifest "$work/lowquery.exe.manifest" -info "$work/info.json" -out "$syso" + + GOOS=windows GOARCH=amd64 go build -tags production -trimpath \ + -ldflags "-s -w -H windowsgui" -o "$work/lowquery.exe" . + rm -f "$syso" +fi +[ "$stage" = exe ] && exit 0 + +if [ ! -f "$work/lowquery.exe" ]; then + echo "$work/lowquery.exe is missing: run build.sh exe first." >&2 + exit 1 +fi makensis="${MAKENSIS:-}" if [ -z "$makensis" ]; then diff --git a/packaging/windows/signpath/README.md b/packaging/windows/signpath/README.md new file mode 100644 index 0000000..d4e2b42 --- /dev/null +++ b/packaging/windows/signpath/README.md @@ -0,0 +1,28 @@ +# Signing the Windows release with SignPath + +The release workflow signs `lowquery.exe` and the setup with Authenticode through [SignPath Foundation](https://signpath.org), which signs open-source projects for free. Until the repository has the settings below, releases build unsigned as before. + +## In SignPath + +1. Add the predefined trusted build system **GitHub.com** to the organization and link it to the project. +2. Create the project with the slug `LowQuery` and the repository URL `https://github.com/LowBloat/LowQuery`. +3. Add two artifact configurations with these slugs and the XML of the files here: + - `lowquery-exe`: [lowquery-exe.xml](lowquery-exe.xml), the app executable. + - `setup-exe`: [setup-exe.xml](setup-exe.xml), the NSIS setup. +4. Use the signing policy `release-signing`, with manual approval. Give the CI user the submitter role and the maintainer the approver role. +5. Create an API token for the CI user. + +## In GitHub (Settings → Secrets and variables → Actions) + +- Variable `SIGNPATH_ORGANIZATION_ID`: the organization ID from SignPath. Signing is on once it is set. +- Secret `SIGNPATH_API_TOKEN`: the CI user's API token. +- Optional variables `SIGNPATH_PROJECT_SLUG` and `SIGNPATH_SIGNING_POLICY_SLUG` if the slugs differ from `LowQuery` and `release-signing`. + +## During a release + +The Windows job sends two signing requests and waits up to 3 hours for each: + +1. `lowquery.exe`. The setup and the portable zip are then built from the signed file. +2. The setup. + +Approve both in SignPath. The workflow then checks both signatures (the setup's and the one inside the zip) and signs the setup for the updater with the minisign key. It also adds the link to the code signing policy to the release notes. diff --git a/packaging/windows/signpath/lowquery-exe.xml b/packaging/windows/signpath/lowquery-exe.xml new file mode 100644 index 0000000..364b93b --- /dev/null +++ b/packaging/windows/signpath/lowquery-exe.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/packaging/windows/signpath/setup-exe.xml b/packaging/windows/signpath/setup-exe.xml new file mode 100644 index 0000000..c87672c --- /dev/null +++ b/packaging/windows/signpath/setup-exe.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + +