Last active
November 13, 2024 19:08
-
-
Save Berhtulf/ab3fb663187e7644410c0401b207aa45 to your computer and use it in GitHub Desktop.
Xcode Cloud - CI/CD Push tag to Github
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
# 1. Create 'ci_scripts' folder in your main project directory | |
# 2. Create 'ci_post_xcodebuild.sh' inside of it | |
# 3. Make it an executable by running 'chmod +x $ci_post_xcodebuild.sh' | |
set -e # fails build if any command fails | |
if [ ${CI_XCODEBUILD_EXIT_CODE} != 0 ] | |
then | |
exit 1 | |
fi | |
if [[ -n $CI_APP_STORE_SIGNED_APP_PATH ]]; # checks if there is an AppStore signed archive after running xcodebuild | |
then | |
BUILD_TAG=${CI_BUILD_NUMBER} | |
VERSION=$(cat ../${CI_PRODUCT}.xcodeproj/project.pbxproj | grep -m1 'MARKETING_VERSION' | cut -d'=' -f2 | tr -d ';' | tr -d ' ') | |
git tag ${CI_PRODUCT}/Release/$VERSION\($BUILD_TAG\) | |
git push --tags https://${GIT_AUTH}@github.com/USER_NAME/REPOSITORY.git | |
fi | |
# use workflow Environment to configure your GIT_AUTH variable - username:personalAccessToken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the reply! I see you also changed
-n
(check if string is empty) to-d
(check if directory exists) in that snippet (but not in the gist?). I had coincidentally noticed that Apple's post-build script sample for something else used-d
, so I tried making that change alone, which seemed to work well enough without theCI_XCODEBUILD_EXIT_CODE
check. Before that, I had been trying to check if an IPA existed within that directory, but that seems like overkill now:if [[ -n "$CI_APP_STORE_SIGNED_APP_PATH" ]] && ls "$CI_APP_STORE_SIGNED_APP_PATH" | grep -q "Vida.ipa"; then
Funny that
CI_XCODEBUILD_EXIT_CODE
does seem like a much more direct way of checking this, to where you probably wouldn't even need to look atCI_APP_STORE_SIGNED_APP_PATH
. Wonder why Apple doesn't use it?