Skip to content

Instantly share code, notes, and snippets.

@omarzl
Created June 5, 2024 17:35
Show Gist options
  • Save omarzl/d82b8898077fc08fc01873f0e3d303f7 to your computer and use it in GitHub Desktop.
Save omarzl/d82b8898077fc08fc01873f0e3d303f7 to your computer and use it in GitHub Desktop.
sign_here_example.sh
#!/bin/zsh
# Installs bazelisk in case it isn't installed
if ! command -v bazelisk &> /dev/null; then
HOMEBREW_NO_AUTO_UPDATE=true brew install bazelisk
fi
# If you already have a registered certificate in the App Store Connect, you can
# export the private key from the Keychain (without a password). It will be saved
# in p12 format, you need to convert it to pem:
# `openssl pkcs12 -in key.p12 -out key.pem -nocerts -nodes`
# Then write the path to the key.pem in this variable
#
# If you don't have a registered cert, this script will create the private key and the cert.
# Just write a path where you would like your key to be saved, example:
# /Users/omarzl/signing/key.pem
private_key_path=
# Creates the private key if it doesn't exist
if [ ! -f $private_key_path ]; then
openssl genrsa -out $private_key_path 2048
fi
# Clones the repo (the detailed docs of the tool can be found there)
if [ ! -d sign-here ]; then
git clone --depth 1 git@github.com:Tinder/sign-here.git
fi
cd sign-here
# Before running this script, you should set each parameter value.
# You should have an App Store Connect key to be able to connect to the API, see:
# https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api
PARAMS=(
create-provisioning-profile
--key-identifier ABCD # The ASC Key ID
--issuer-id ABCD-ABCD-ABCD # The ASC Issuer ID
--itunes-connect-key-path /Users/omarzl/signing/AuthKey.p8 # The ASC Key file path
--keychain-name login.keychain # If you do not have a specific Keychain for this, you can use the login Keychain
--keychain-password PASS # The password of the Keychain
--bundle-identifier com.omarzl.example # The bundle ID of your app
--platform IOS --profile-type IOS_APP_ADHOC --certificate-type IOS_DISTRIBUTION # This example will create an Ad Hoc profile
--output-path /Users/omarzl/Library/MobileDevice/Provisioning\ Profiles/Test.mobileprovision # Location where the profile will be saved
--openssl-path $(command -v openssl)
--certificate-signing-request-subject /emailAddress=example@example.com/CN=ozl/C=MX # In case you do not have a certificate, this tool will create it. Set here the desired subject
--private-key-path $private_key_path
--profile-name Test # The name that the profile will have
--auto-regenerate # Automatically regenerates a profile when the device count changes
)
# Builds and runs the target
bazel run //Sources/SignHereTool:sign-here -- "${PARAMS[@]}"
# Clean up
cd ..
rm -rf sign-here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment