Skip to content

Commit e70ef6e

Browse files
committed
Add xcframework code signing
1 parent 3f2becf commit e70ef6e

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

.buildkite/pipeline.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@ steps:
7070
make setup-rust
7171
7272
echo "--- :swift: Building xcframework"
73+
install_gems
74+
bundle exec fastlane set_up_signing
75+
7376
make xcframework
7477
zip -r target/libwordpressFFI.xcframework.zip target/libwordpressFFI.xcframework
7578
artifact_paths:
7679
- target/libwordpressFFI.xcframework.zip
7780
- native/swift/Sources/wordpress-api-wrapper/*.swift
81+
plugins: [$CI_TOOLKIT]
7882
agents:
7983
queue: mac
8084
- label: ":swift: Build Docs"

.buildkite/release.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ make setup-rust
2121
echo "--- :rubygems: Setting up Gems"
2222
install_gems
2323

24+
echo "--- ::closed_lock_with_key:: Setting up Code Signing"
25+
bundle exec fastlane set_up_signing
26+
2427
echo "--- :rust: Building XCFramework"
2528
make xcframework-package
2629
make xcframework-package-checksum
30+
make xcframework-sign
2731

2832
release_version="$1"
2933
echo "--- :rocket: Publish release $release_version"

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ xcframework-package: xcframework-all
137137
xcframework-package-checksum:
138138
swift package compute-checksum libwordpressFFI.xcframework.zip | tee libwordpressFFI.xcframework.zip.checksum.txt
139139

140+
xcframework-sign:
141+
codesign --timestamp -v --sign "Apple Development: Created via API (886NX39KP6)" target/libwordpressFFI.xcframework
142+
140143
docker-image-web:
141144
docker build -t wordpress-rs-web -f wp_rs_web/Dockerfile . --progress=plain
142145

fastlane/Fastfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ PROJECT_NAME = 'wordpress-rs'
2424
# GlotPress configuration
2525
GLOTPRESS_PROJECT_BASE_URL = 'https://translate.wordpress.com/projects/mobile/wordpress-rs'
2626

27+
# Code Signing
28+
APPLE_TEAM_ID = 'PZYM8XX95Q'
29+
APPLE_BUNDLE_IDENTIFIER = 'com.automattic.hostmgr'
30+
31+
ASC_API_KEY_ENV_VARS = %w[
32+
APP_STORE_CONNECT_API_KEY_KEY_ID
33+
APP_STORE_CONNECT_API_KEY_ISSUER_ID
34+
APP_STORE_CONNECT_API_KEY_KEY
35+
].freeze
36+
37+
CODE_SIGNING_STORAGE_ENV_VARS = %w[
38+
MATCH_S3_ACCESS_KEY
39+
MATCH_S3_SECRET_ACCESS_KEY
40+
].freeze
41+
2742
# Supported locales mapping between GlotPress and project locale codes
2843
# This list combines locales supported in the iOS and Android apps
2944
SUPPORTED_LOCALES = [
@@ -396,6 +411,27 @@ lane :generate_fluent_file_from_po do |file_path:|
396411
fluent_file_path
397412
end
398413

414+
desc 'Download the development signing certificates to this machine'
415+
lane :set_up_signing do |readonly: true|
416+
require_env_vars!(*ASC_API_KEY_ENV_VARS, *CODE_SIGNING_STORAGE_ENV_VARS)
417+
418+
sync_code_signing(
419+
platform: 'macos',
420+
app_identifier: APPLE_BUNDLE_IDENTIFIER,
421+
team_id: APPLE_TEAM_ID,
422+
api_key: app_store_connect_api_key,
423+
type: 'development',
424+
certificate_id: 'Apple Development: Created via API (886NX39KP6)',
425+
426+
storage_mode: 's3',
427+
s3_region: 'us-east-2',
428+
s3_bucket: 'a8c-fastlane-match',
429+
430+
readonly: readonly
431+
)
432+
end
433+
434+
399435
# Utils
400436

401437
def xcframework_checksum
@@ -463,3 +499,17 @@ def only_date_headers_changed?(file_path)
463499

464500
changed_lines.all? { |l| l.include?('"POT-Creation-Date:') || l.include?('"PO-Revision-Date:') }
465501
end
502+
503+
# Use this to ensure all env vars a lane requires are set.
504+
#
505+
# The best place to call this is at the start of a lane, to fail early.
506+
def require_env_vars!(*keys)
507+
keys.each { |key| get_required_env!(key) }
508+
end
509+
510+
# Use this instead of getting values from `ENV` directly. It will throw an error if the requested value is missing.
511+
def get_required_env!(key)
512+
return ENV.fetch(key) if ENV.key?(key)
513+
514+
UI.user_error!("Environment variable `#{key}` is not set.")
515+
end

0 commit comments

Comments
 (0)