Skip to content

Instantly share code, notes, and snippets.

@behdaad
Last active May 30, 2021 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save behdaad/8a7efc0aad2d913c1539d4c8d3532cb6 to your computer and use it in GitHub Desktop.
Save behdaad/8a7efc0aad2d913c1539d4c8d3532cb6 to your computer and use it in GitHub Desktop.
GitLab CI/CD for Xcode Projects/Workspaces
variables:
GIT_STRATEGY: fetch
DEBUG_SCHEME: Debug
PRODUCTION_SCHEME: Production
stages:
- test
- danger
- archive
test_project:
stage: test
only:
- merge_requests
script:
- xcodebuild ONLY_ACTIVE_ARCH=YES -workspace Workspace.xcworkspace -scheme $PRODUCTION_SCHEME clean test -destination 'platform=iOS Simulator,name=iPhone 12 Pro,OS=14.5' | xcpretty && exit ${PIPESTATUS[0]}
danger_project:
stage: danger
only:
- merge_requests
script:
- export DANGER_GITLAB_HOST="gitlab.com"
- export DANGER_GITLAB_API_BASE_URL="https://gitlab.com/api/v4"
- export DANGER_GITLAB_API_TOKEN=$DANGER_GITLAB_API_TOKEN
- danger --fail-on-errors=true
archive_debug_project:
stage: archive
script:
- xcodebuild archive -workspace Workspace.xcworkspace -scheme $DEBUG_SCHEME -archivePath outputs/Archives/Project_$DEBUG_SCHEME.xcarchive -allowProvisioningUpdates | xcpretty
- xcodebuild -exportArchive -archivePath outputs/Archives/Project_$DEBUG_SCHEME.xcarchive -exportPath outputs/IPAs -exportOptionsPlist ~/Developer/Project/ExportOptions.plist -allowProvisioningUpdates | xcpretty
only:
- merge_requests
artifacts:
paths:
- outputs/IPAs
expire_in: never
archive_production_project:
stage: archive
script:
- xcodebuild archive -workspace Workspace.xcworkspace -scheme $PRODUCTION_SCHEME -archivePath outputs/Archives/Project_$PRODUCTION_SCHEME.xcarchive -allowProvisioningUpdates | xcpretty
- xcodebuild -exportArchive -archivePath outputs/Archives/Project_$PRODUCTION_SCHEME.xcarchive -exportPath outputs/IPAs -exportOptionsPlist ~/Developer/Project/ExportOptions.plist -allowProvisioningUpdates | xcpretty
when: manual
only:
- rc
- merge_requests
artifacts:
paths:
- outputs/IPAs
expire_in: never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment