Last active
February 6, 2017 18:01
-
-
Save nicolasrouanne/efb7f352d79572424718a5079da2a1f3 to your computer and use it in GitHub Desktop.
Shell script to generate push notifications certificates on many iOS bundles in just one command
This file contains 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
*.yaml |
This file contains 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
########################################################## | |
# Shell script to generate push notifications certificates | |
# on a many iOS bundles in just one command | |
########################################################## | |
#!/bin/bash | |
##################### | |
# SET OPTIONS | |
##################### | |
# initialize team_id to default Entreprise Account | |
team_id="K2YZCHB58J" | |
# set optional team_id parameter | |
while getopts ":t:" opt; do | |
case $opt in | |
t) | |
echo "Running pem with team_id $OPTARG" >&2 | |
team_id=$OPTARG | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." >&2 | |
exit 1 | |
;; | |
esac | |
done | |
##################### | |
# SET ARGUMENT | |
##################### | |
# script requires 1 argument | |
shift $(($OPTIND - 1)) | |
if [ $# -eq 0 ]; then | |
echo "ERROR: provide the path to the file listing the iOS bundle ids in a YAML format as argument." | |
exit 1 | |
fi | |
# initialize the array with ios_bundles list and assign the argument to it | |
declare -a ios_bundles | |
bundle_file="$1" | |
##################### | |
# RUN SCRIPT | |
##################### | |
# Load bundle_file into array ios_bundles | |
# NB: make sure to have a new line at end of file | |
let i=0 | |
while IFS=$'\n' read -r line_data; do | |
ios_bundles[i]="${line_data}" | |
((++i)) | |
done < $bundle_file | |
# For each array element, execute pem | |
let i=0 | |
while (( ${#ios_bundles[@]} > i )); do | |
printf "Executing pem for ${ios_bundles[i]}\n" | |
fastlane pem --username developer@nomadeducation.fr --team_id ${team_id} -a "${ios_bundles[i]}" | |
# copy the .pkey created into .pkey.pem | |
if [ -f ./production_"${ios_bundles[i]}".pkey ]; then | |
cp production_"${ios_bundles[i]}".pkey production_"${ios_bundles[i]}".pkey.pem | |
echo "Copied production_${ios_bundles[i]}.pkey to production_${ios_bundles[i]}.pkey.pem" | |
fi | |
((++i)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment