Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

[WIP] Automated iOS Build #147

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: iOS

env:
IOS_CERTIFICATES_REPO: 'ito-org/ios-certificates'
IOS_OUTPUT_FOLDER: './ios/build/ReactNativeApp'
IOS_PROVISIONING_PROFILE_GUID: 'D0DD9EFE-AAA2-468F-B7B8-493A2C4866BA'
EXPORT_OPTIONS_PLIST: './ios/exportOptionsDev.plist'

on: push

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
scheme: ['ReactNativeApp']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: ${{ env.IOS_CERTIFICATES_REPO }}
token: ${{ secrets.ACCESS_TOKEN }}
path: './ios-certificates'
- name: Install cocoapods
run: gem install cocoapods --pre
- name: Decrypt ios certificates
run: sh ./ci/decrypt-ios-certificates.sh
env:
IOS_CERTIFICATES_PASSPHRASE: ${{ secrets.IOS_CERTIFICATES_PASSPHRASE }}
- name: Prepare ios certificates
run: sh ./ci/prepare-ios-certificates.sh
env:
IOS_PROVISIONING_PROFILE_GUID: ${{ env.IOS_PROVISIONING_PROFILE_GUID }}
- name: Install npm
run: |
npm ci
- name: Install pods
run: |
pod install --project-directory=./ios
shell: bash

- name: Build archive
run: |
sh ./ci/ios-unlock-keychain.sh
xcodebuild -workspace ./ios/ReactNativeApp.xcworkspace \
archive \
-scheme ${{ matrix.scheme }} \
-archivePath ./ios/build/ReactNativeApp.xcarchive \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
env:
IOS_PROVISIONING_PROFILE_GUID: ${{ secrets.IOS_PROVISIONING_PROFILE_GUID }}
CODE_SIGN_IDENTITY: ''
CODE_SIGNING_REQUIRED: 'NO'
CODE_SIGNING_ALLOWED: 'NO'

- name: Build ipa
run: |
sh ./ci/ios-unlock-keychain.sh
xcodebuild -exportArchive \
-archivePath ./ios/build/ReactNativeApp.xcarchive \
-exportPath ${{ env.IOS_OUTPUT_FOLDER }} \
-exportOptionsPlist ${{ env.EXPORT_OPTIONS_PLIST }}

- name: Upload ipa artifact
uses: actions/upload-artifact@v1
with:
name: app-release.ipa
path: ${{ env.IOS_OUTPUT_FOLDER }}/ReactNativeApp.ipa


deploy:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v1
with:
name: app-release.ipa
path: .
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release:
draft: true
prerelease: true
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ReactNativeApp.ipa
asset_name: ito-app-${{ steps.get_version.outputs.VERSION }}.ipa
asset_content_type: application/zip
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ito React Native App

![Android Build](https://github.com/ito-org/react-native-app/workflows/Android/badge.svg)
![iOS](https://github.com/ito-org/react-native-app/workflows/iOS/badge.svg)
[![Android Downloads](https://img.shields.io/github/downloads/ito-org/react-native-app/total?color=%237dc6b6&logo=Android)](https://github.com/ito-org/react-native-app/releases/latest)
![License](https://img.shields.io/github/license/ito-org/react-native-app)

Expand Down
4 changes: 4 additions & 0 deletions ci/decrypt-ios-certificates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

gpg --quiet --batch --yes --decrypt --passphrase="$IOS_CERTIFICATES_PASSPHRASE" --output ./ios-certificates/dev-provisioning.mobileprovision ./ios-certificates/dev-provisioning.mobileprovision.gpg
gpg --quiet --batch --yes --decrypt --passphrase="$IOS_CERTIFICATES_PASSPHRASE" --output ./ios-certificates/dev-certificate.p12 ./ios-certificates/dev-certificate.p12.gpg
2 changes: 2 additions & 0 deletions ci/ios-unlock-keychain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
security unlock-keychain -p "" ~/Library/Keychains/build.keychain
15 changes: 15 additions & 0 deletions ci/prepare-ios-certificates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles

cp ./ios-Certificates/dev-provisioning.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/$IOS_PROVISIONING_PROFILE_GUID.mobileprovision

security create-keychain -p "" build.keychain
security import ./ios-certificates/dev-certificate.p12 -t agg -k ~/Library/Keychains/build.keychain -P "" -A

security list-keychains -s ~/Library/Keychains/build.keychain
security default-keychain -s ~/Library/Keychains/build.keychain
security unlock-keychain -p "" ~/Library/Keychains/build.keychain

# https://stackoverflow.com/questions/16550594/jenkins-xcode-build-works-codesign-fails/19550453#19550453
security set-key-partition-list -S apple-tool:,apple: -s -k "" ~/Library/Keychains/build.keychain
Loading