-
Notifications
You must be signed in to change notification settings - Fork 0
Sign and notarize the desktop DMG (AINFRA-2457) #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mokagio
wants to merge
22
commits into
main
Choose a base branch
from
mokagio/desktop-code-signing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
dd64ee4
Scaffold match cert delivery for the desktop app
mokagio 61f0f86
Sign and notarize the desktop DMG with Developer ID
mokagio b51f3f0
Add Buildkite pipeline to build the signed desktop DMG
mokagio e0ad9c0
Tighten verbose AI comments
mokagio 4f8ad51
Add Buildkite agent and plugin config
mokagio c58fb2b
Read fastlane team id from electron-builder config
mokagio 07b2f4d
Install composer on the agent before the build
mokagio cacc933
Install static-php-cli build toolchain on the agent
mokagio 9579a24
Set mac.notarize to a boolean
mokagio b113fb0
Decode literal newlines when writing the notarization key
mokagio 339a573
Read team id from the signing identity, not notarize
mokagio 6489ee2
Drop the cert-type prefix from mac.identity
mokagio 2d39f8c
Verify the notarized app, not the unsigned dmg
mokagio 706431b
Fail on unexpectedly finding multiple DMGs
mokagio 3c83d78
Fail if team ID cannot be computed from JSON
mokagio b5bf5d2
Accept plain semver release tags
mokagio a369ef1
Require plain semver release tags
mokagio 3c8e19c
Delete GHA workflow for macOS DMG release — Use Buildkite only
mokagio 5cc6c74
Remove dead desktop release workflow call
mokagio 8a592d4
Document Buildkite desktop release ownership
mokagio b5aa997
Fix desktop release install note
mokagio bc118e7
Merge remote-tracking branch 'origin/main' into mokagio/desktop-code-…
priethor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Build, sign, and notarize the Cortext desktop DMG. | ||
|
|
||
| # Release tag builds publish to the GitHub Release. | ||
| if [[ "${BUILDKITE_TAG:-}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| version="$BUILDKITE_TAG" | ||
| publish=true | ||
| else | ||
| base_version="$(python3 -c 'import json; print(json.load(open("apps/desktop/package.json"))["version"])')" | ||
| version="${base_version}-${BUILDKITE_COMMIT:0:7}" | ||
| publish=false | ||
| fi | ||
|
|
||
| echo "--- :package: install JS + PHP dependencies" | ||
| corepack enable | ||
| corepack prepare "pnpm@$(node -p "require('./package.json').packageManager.split('@')[1]")" --activate | ||
| # The xcode-* agent image ships no composer; brew pulls php in as a dependency. | ||
| command -v composer >/dev/null || brew install composer | ||
| composer install --no-dev --optimize-autoloader --no-interaction | ||
| pnpm install --frozen-lockfile | ||
| npm --prefix apps/desktop ci | ||
|
|
||
| # Electron 42 skips the binary download during `npm ci`; fetch it so | ||
| # electron-builder packages a complete app. | ||
| ( cd apps/desktop && npx install-electron ) | ||
|
|
||
| echo "--- :hammer_and_wrench: install static-php-cli build toolchain" | ||
| # static-php-cli source-builds any library without a pre-built binary (e.g. | ||
| # libxml2), which the minimal agent image can't do unaided. | ||
| brew install cmake autoconf automake libtool bison re2c | ||
| export PATH="$(brew --prefix bison)/bin:$PATH" | ||
|
|
||
| echo "--- :php: build bundled arm64 PHP runtime" | ||
| npm --prefix apps/desktop run runtime:php | ||
|
|
||
| echo "--- :card_index_dividers: build distribution snapshot" | ||
| CORTEXT_DESKTOP_DISTRIBUTION=1 npm --prefix apps/desktop run snapshot | ||
|
|
||
| echo "--- :key: install Developer ID cert into the agent keychain" | ||
| ( cd apps/desktop && install_gems && bundle exec fastlane set_up_signing ) | ||
|
|
||
| echo "--- :apple: build, sign, notarize DMG" | ||
| # electron-builder signs from the match-installed keychain cert (mac.identity) | ||
| # and notarizes via its built-in @electron/notarize, driven by APPLE_API_*. | ||
| # APPLE_API_KEY must be a path to the .p8, so materialize the key the agent | ||
| # carries as APP_STORE_CONNECT_API_KEY_KEY into a temp file. | ||
| apple_api_key_path="$(mktemp -t cortext_asc).p8" | ||
| trap 'rm -f "$apple_api_key_path"' EXIT | ||
| # The secret stores the .p8 with newlines as literal \n; %b turns them back into | ||
| # real newlines so the file is a valid PEM (a no-op if they are already real). | ||
| printf '%b' "$APP_STORE_CONNECT_API_KEY_KEY" > "$apple_api_key_path" | ||
| export APPLE_API_KEY="$apple_api_key_path" | ||
| export APPLE_API_KEY_ID="$APP_STORE_CONNECT_API_KEY_KEY_ID" | ||
| export APPLE_API_ISSUER="$APP_STORE_CONNECT_API_KEY_ISSUER_ID" | ||
|
|
||
| npm --prefix apps/desktop run dist -- -c.extraMetadata.version="$version" | ||
|
|
||
| echo "--- :white_check_mark: verify signature + notarization" | ||
| dmg=(apps/desktop/dist/*.dmg) | ||
| [[ ${#dmg[@]} -eq 1 ]] || { echo "Expected exactly one DMG, found ${#dmg[@]}"; exit 1; } | ||
| dmg="${dmg[0]}" | ||
| # electron-builder signs, notarizes and staples the .app, then wraps it in an | ||
| # unsigned .dmg — so the notarized artifact to verify is the app, not the dmg. | ||
| app="apps/desktop/dist/mac-arm64/Cortext.app" | ||
| codesign --verify --strict --deep --verbose=2 "$app" | ||
| spctl --assess --type exec --verbose=2 "$app" | ||
| xcrun stapler validate "$app" | ||
|
|
||
| if ! "$publish"; then | ||
| echo "--- :information_source: no release tag; signed DMG stashed as a Buildkite artifact" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "--- :rocket: attach DMG to draft GitHub Release" | ||
| if ! gh release view "$version" --repo Automattic/cortext >/dev/null 2>&1; then | ||
| gh release create "$version" \ | ||
| --repo Automattic/cortext \ | ||
| --draft \ | ||
| --title "Cortext $version" \ | ||
| --notes "Cortext $version" | ||
| fi | ||
| gh release upload "$version" "$dmg" --repo Automattic/cortext --clobber | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json | ||
| --- | ||
|
|
||
| agents: | ||
| queue: mac | ||
|
|
||
| env: | ||
| IMAGE_ID: $IMAGE_ID | ||
|
|
||
| steps: | ||
| - label: ":apple: Build, sign, notarize desktop DMG" | ||
| key: release-desktop | ||
| command: .buildkite/commands/release-desktop.sh | ||
| plugins: [$CI_TOOLKIT_PLUGIN, $NVM_PLUGIN] | ||
|
priethor marked this conversation as resolved.
|
||
| artifact_paths: | ||
| - "apps/desktop/dist/*.dmg" | ||
| - "apps/desktop/dist/*.dmg.blockmap" | ||
| notify: | ||
| - github_commit_status: | ||
| context: Build, Sign & Notarize Desktop | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Sourced by the pipeline-upload step so these values land in the rendered pipeline.yml. | ||
|
|
||
| CI_TOOLKIT_PLUGIN_VERSION='6.0.1' | ||
| NVM_PLUGIN_VERSION='0.6.0' | ||
| XCODE_VERSION=$(sed -E 's/^~> ?//' .xcode-version) | ||
|
|
||
| export IMAGE_ID="xcode-$XCODE_VERSION" | ||
| export CI_TOOLKIT_PLUGIN="automattic/a8c-ci-toolkit#$CI_TOOLKIT_PLUGIN_VERSION" | ||
| export NVM_PLUGIN="automattic/nvm#$NVM_PLUGIN_VERSION" |
This file was deleted.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 24.15 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.3.4 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 26.3 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| BUNDLE_PATH: "vendor/bundle" | ||
| BUNDLE_SPECIFIC_PLATFORM: "false" | ||
| BUNDLE_FORCE_RUBY_PLATFORM: "true" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| source 'https://rubygems.org' | ||
|
|
||
| gem 'fastlane', '~> 2.236' | ||
| gem 'fastlane-plugin-wpmreleasetoolkit', '~> 14.6' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be hidden away in CI toolkit if it proves a pattern used by other apps.
I considered adding the env vars directly in CI, but I think it's cleaner to have only the
APP_STORE_CONNECT_API_KEY_definitions there.