Merge pull request #138 from DimensionSrl/feature/updates #240
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
name: CI | |
on: [ pull_request, push ] | |
jobs: | |
## Test on latest MacOS | |
# test: | |
# runs-on: macos-13 | |
# steps: | |
# - name: Checkout the code | |
# uses: actions/checkout@v2 | |
# - name: Mock GoogleService-Info.plist | |
# run: mv NOICommunity/GoogleService-Info_mock.plist NOICommunity/GoogleService-Info.plist | |
# - name: Resolve package dependencies | |
# run: xcodebuild -resolvePackageDependencies | |
# - name: List schemes (optional step to gather information) | |
# run: xcodebuild -list -project NOICommunity.xcodeproj | |
# - name: Test the app | |
# run: | | |
# set -eo pipefail | |
# xcodebuild clean test \ | |
# -scheme NOICommunity \ | |
# -destination 'platform=iOS Simulator,OS=16.2,name=iPhone 14' \ | |
# IPHONEOS_DEPLOYMENT_TARGET='16.2' \ | |
# | xcpretty | |
## Deploy to TestFlight | |
deploy_testflight: | |
name: Deploy to Testflight | |
runs-on: macos-13 | |
if: github.ref == 'refs/heads/main' | |
# needs: [ test ] | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development | |
- name: Install the Apple certificate and provisioning profile | |
env: | |
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_BUILD_CERTIFICATE_BASE64 }} | |
P12_PASSWORD: ${{ secrets.IOS_KEY_PASSPHRASE }} | |
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.IOS_PROVISION_PROFILE_BASE64 }} | |
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEY_PASSPHRASE }} | |
run: | | |
# create variables | |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | |
# import certificate and provisioning profile from secrets | |
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH | |
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH | |
# create temporary keychain | |
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | |
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
# import certificate to keychain | |
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | |
security list-keychain -d user -s $KEYCHAIN_PATH | |
# apply provisioning profile | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | |
- name: Resolve package dependencies | |
run: xcodebuild -resolvePackageDependencies | |
- name: Inject GoogleService-Info.plist | |
env: | |
GOOGLE_SERVICE_INFO_PLIST: ${{ secrets.GOOGLE_SERVICE_INFO_PLIST }} | |
run: echo "$GOOGLE_SERVICE_INFO_PLIST" > NOICommunity/GoogleService-Info.plist | |
- name: Increment build number | |
run: | | |
set -eo pipefail | |
BUILD_NUMBER=$(date "+%Y%m%d%H%M%S") | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" NOICommunity/Info.plist | |
# Set -configuration to "Release", if you want to use the production Keycloak server | |
# and to "Release TMA" for the testingmachine-authentication Keycloak server | |
- name: Archive the project | |
run: | | |
set -eo pipefail | |
xcodebuild clean archive \ | |
-configuration "Release" \ | |
-scheme NOICommunity \ | |
-sdk iphoneos \ | |
-archivePath "$PWD/build/NOICommunity.xcarchive" \ | |
-destination "generic/platform=iOS,name=Any iOS Device" \ | |
OTHER_CODE_SIGN_FLAGS="--keychain ~/Library/Keychains/build.keychain" \ | |
CODE_SIGN_STYLE=Manual \ | |
PROVISIONING_PROFILE='8217a111-ad20-4a6f-a664-5c1e5714d6fa' \ | |
CODE_SIGN_IDENTITY="Apple Distribution" | |
- name: Export .ipa | |
run: | | |
set -eo pipefail | |
xcodebuild -archivePath "$PWD/build/NOICommunity.xcarchive" \ | |
-exportOptionsPlist exportOptions.plist \ | |
-exportPath $PWD/build \ | |
-allowProvisioningUpdates \ | |
-exportArchive | |
- name: Publish the App on TestFlight | |
if: success() | |
env: | |
APPLEID_USERNAME: ${{ secrets.APPLEID_USERNAME }} | |
APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }} | |
run: | | |
xcrun altool \ | |
--upload-app \ | |
-t ios \ | |
-f $PWD/build/NOICommunity.ipa \ | |
-u "$APPLEID_USERNAME" \ | |
-p "$APPLEID_PASSWORD" \ | |
--verbose |