Skip to content

Commit

Permalink
ci: ios build workflows
Browse files Browse the repository at this point in the history
Signed-off-by: andrei-zgirvaci <[email protected]>
  • Loading branch information
andrei-zgirvaci committed Apr 17, 2024
1 parent 389f334 commit e89489a
Showing 1 changed file with 149 additions and 56 deletions.
205 changes: 149 additions & 56 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,62 @@ name: Distribute Sample App to App Center & Build Docs

on:
push:
branches: [main, ci]
branches: [main, ci, setup-ios]

jobs:
build-and-deploy-sample-app:
# build-and-deploy-android-sample-app:
# env:
# SAMPLE_APP_PATH: 'apps/sample-app/android'

# runs-on: ubuntu-latest

# steps:
# - name: Checkout repository
# uses: actions/checkout@v4

# - name: Setup Bun
# uses: oven-sh/setup-bun@v1
# with:
# bun-version: latest

# - name: Install dependencies
# run: bun install

# - name: Setup JDK
# uses: actions/setup-java@v4
# with:
# distribution: 'zulu'
# java-version: '17'

# - name: Add secrets to `local.properties`
# run: |
# echo GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
# echo FACEBOOK_APP_ID=${{ secrets.FACEBOOK_APP_ID }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
# echo FACEBOOK_CLIENT_TOKEN=${{ secrets.FACEBOOK_CLIENT_TOKEN }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
# echo DROPBOX_APP_KEY=${{ secrets.DROPBOX_APP_KEY }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
# echo MICROSOFT_CLIENT_ID=${{ secrets.MICROSOFT_CLIENT_ID }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
# echo MICROSOFT_HOST_PATH=com.openmobilehub.reactnative.auth.sample.MainApplication >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
# echo MICROSOFT_SIGNATURE_HASH=${{ secrets.MICROSOFT_SIGNATURE_HASH }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties

# - name: Build release
# run: |
# cd ${{ env.SAMPLE_APP_PATH }}
# ./gradlew assembleRelease

# - name: Upload .apk to App Center
# uses: wzieba/AppCenter-Github-Action@v1
# with:
# appName: Callstack-dev/RN-Android-OMH-Auth-Sample
# group: Testers
# token: ${{ secrets.APP_CENTER_TOKEN }}
# file: ${{ env.SAMPLE_APP_PATH }}/app/build/outputs/apk/release/app-release.apk
# notifyTesters: true
# debug: true
# gitReleaseNotes: true

build-and-deploy-ios-sample-app:
env:
SAMPLE_APP_PATH: 'apps/sample-app/android'
SAMPLE_APP_PATH: 'apps/sample-app/ios'

runs-on: ubuntu-latest

Expand All @@ -23,79 +73,122 @@ jobs:
- name: Install dependencies
run: bun install

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: KEYCHAIN_PASSWORD

- name: Add secrets to `local.properties`
run: |
echo GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
echo FACEBOOK_APP_ID=${{ secrets.FACEBOOK_APP_ID }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
echo FACEBOOK_CLIENT_TOKEN=${{ secrets.FACEBOOK_CLIENT_TOKEN }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
echo DROPBOX_APP_KEY=${{ secrets.DROPBOX_APP_KEY }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
echo MICROSOFT_CLIENT_ID=${{ secrets.MICROSOFT_CLIENT_ID }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
echo MICROSOFT_HOST_PATH=com.openmobilehub.reactnative.auth.sample.MainApplication >> ${{ env.SAMPLE_APP_PATH }}/local.properties &&
echo MICROSOFT_SIGNATURE_HASH=${{ secrets.MICROSOFT_SIGNATURE_HASH }} >> ${{ env.SAMPLE_APP_PATH }}/local.properties
- name: Build release
# 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 > $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode > $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 set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $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: install Cocoapod dependencies
run: |
cd ${{ env.SAMPLE_APP_PATH }}
pod repo update
pod install
- name: build archive
run: |
cd ${{ env.SAMPLE_APP_PATH }}
./gradlew assembleRelease
xcodebuild -workspace SampleApp.xcworkspace \
-scheme "SampleApp" \
-sdk iphoneos \
-configuration Debug \
-destination generic/platform=iOS \
-archivePath $RUNNER_TEMP/SampleApp.xcarchive \
archive
- name: export ipa
env:
EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }}

run: |
# create variables
EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist
- name: Upload .apk to App Center
# import profile lists from secrets
echo -n "$EXPORT_OPTIONS_PLIST" | base64 --decode > $EXPORT_OPTS_PATH
# extract .ipa
xcodebuild -exportArchive -archivePath $RUNNER_TEMP/SampleApp.xcarchive -exportOptionsPlist $EXPORT_OPTS_PATH -exportPath $RUNNER_TEMP/build
ls $RUNNER_TEMP/build
- name: Upload .ipa to App Center
uses: wzieba/AppCenter-Github-Action@v1
with:
appName: Callstack-dev/React-Native-Auth-Sample-App
appName: Callstack-dev/RN-iOS-OMH-Auth-Sample
group: Testers
token: ${{ secrets.APP_CENTER_TOKEN }}
file: ${{ env.SAMPLE_APP_PATH }}/app/build/outputs/apk/release/app-release.apk
file: $RUNNER_TEMP/build/SampleApp.ipa
notifyTesters: true
debug: true
gitReleaseNotes: true

build-docs:
runs-on: ubuntu-latest
# build-docs:
# runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
# - name: Setup Bun
# uses: oven-sh/setup-bun@v1
# with:
# bun-version: latest

- name: Install dependencies
run: bun install
# - name: Install dependencies
# run: bun install

- name: Build docs
run: |
cd docs
bun run build
# - name: Build docs
# run: |
# cd docs
# bun run build

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build
# - name: Upload Build Artifact
# uses: actions/upload-pages-artifact@v3
# with:
# path: docs/build

deploy-docs:
needs: build-docs
# deploy-docs:
# needs: build-docs

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
# permissions:
# pages: write # to deploy to Pages
# id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# # Deploy to the github-pages environment
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
# runs-on: ubuntu-latest

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# steps:
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4

0 comments on commit e89489a

Please sign in to comment.