diff --git a/.github/workflows/release-sign.yml b/.github/workflows/release-sign.yml index f7bc4c17..94d1704d 100644 --- a/.github/workflows/release-sign.yml +++ b/.github/workflows/release-sign.yml @@ -16,6 +16,7 @@ name: release-sign # package macOS. Builds the installer. # sign-installer Linux. Signs the installer with the Developer ID # Installer key and notarizes it. +# attest Linux. Records which commit and run built the installer. # sign-sparkle macOS. Signs the installer for Sparkle. # publish macOS. Publishes the installer. # @@ -566,6 +567,29 @@ jobs: if: always() run: rm -f /tmp/{installer_cert.pem,apple_apikey.p8,apple_apikey.json,kmsp11_config.yaml} + # Stores a build provenance attestation for the installer: a signed, public record of the + # commit and workflow run that produced it. "gh attestation verify" checks an installer + # against it. The installer is named by the checksum sign-installer recorded, so nothing is + # downloaded here. The job holds no secrets and no other job waits for it. + attest: + name: Attest the installer + needs: sign-installer + runs-on: ubuntu-22.04 + if: >- + ${{ !cancelled() && github.repository_owner == 'coder' && !inputs.dryrun && + needs.sign-installer.result == 'success' }} + permissions: + # To sign the attestation as this workflow run + id-token: write + # To store it + attestations: write + steps: + - name: Attest + uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 + with: + subject-name: Coder-Desktop.pkg + subject-digest: sha256:${{ needs.sign-installer.outputs.sha256 }} + # Sparkle, the app's updater, only accepts an installer whose Ed25519 signature verifies # against the public key built into the app. The signature covers the file as it is after # notarization, and Sparkle's signing tool only runs on macOS. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1c28b55b..9c9d81b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,3 +37,4 @@ jobs: permissions: contents: write # upload the release assets id-token: write # authenticate to Google Cloud + attestations: write # record which run built the installer diff --git a/RELEASING.md b/RELEASING.md index 5cdde12b..268d8ee9 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -48,6 +48,7 @@ alternate between the two: | `sign-app` | Linux | Signs the app with the Developer ID Application key, notarizes it | | `package` | macOS | Builds the installer | | `sign-installer` | Linux | Signs the installer with the Developer ID Installer key, notarizes it | +| `attest` | Linux | Records which commit and run built the installer | | `sign-sparkle` | macOS | Signs the installer for Sparkle | | `publish` | macOS | Publishes the installer and updates the appcast | @@ -64,6 +65,20 @@ Cloud KMS. The `sign-sparkle` job signs the finished installer with it, using Sparkle's own tool, which only runs on macOS. The job does nothing else, so that the key is never next to the tools `publish` downloads. +### Provenance + +The `attest` job stores a build provenance attestation for each published +installer: a signed, public record of the commit and workflow run that +produced it. To check an installer against it: + +```bash +gh attestation verify Coder-Desktop.pkg --repo coder/coder-desktop-macos \ + --cert-identity https://github.com/coder/coder-desktop-macos/.github/workflows/release-sign.yml@refs/heads/main +``` + +`--cert-identity` only accepts an attestation made by `release-sign.yml` on +`main`. Dry runs are not attested. + ### Secrets `sign-app`, `sign-installer` and `sign-sparkle` run in the `signing` @@ -123,6 +138,11 @@ it, and it cannot leave out the `approve` job. The first job stops the run if that commit is not on `main`. The jobs come from the newest `main`, while the scripts they run come from the tagged commit. +`release.yml` has to grant every permission those jobs ask for, and a release +tag uses its own copy of `release.yml`. If a job on `main` has gained a +permission since the tagged commit, the run fails before any job starts. Tag a +newer commit instead. + The approval is a job in `release-sign.yml`, so a change to that file on `main` could sign without it. What protects against that is the review of changes to `main`.