@@ -24,6 +24,21 @@ PROJECT_NAME = 'wordpress-rs'
2424# GlotPress configuration
2525GLOTPRESS_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
2944SUPPORTED_LOCALES = [
@@ -396,6 +411,27 @@ lane :generate_fluent_file_from_po do |file_path:|
396411 fluent_file_path
397412end
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
401437def 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:' ) }
465501end
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