Skip to content

Build API Example

Build API Example #89

Workflow file for this run

name: Build API Example
on:
workflow_dispatch:
jobs:
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
- name: SetupExample
run: |
yarn example install --frozen-lockfile
- name: Modify APP ID
run: |
sed "s/localAppId = '\(.*\)'/localAppId = '${{ secrets.APP_ID }}'/g" agora.config.ts > tmp
mv tmp agora.config.ts
working-directory: example/src/config
- name: Gradle build
run: |
./gradlew :app:assembleRelease
working-directory: example/android
- uses: actions/upload-artifact@v3
with:
name: AgoraRtcNgExample
path: |
example/android/app/build/outputs/apk/release/*.apk
build-ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
- uses: actions/cache@v3
with:
path: |
**/Pods
key: ${{ runner.os }}-pods-ng-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-ng
- uses: hendrikmuhs/[email protected]
with:
max-size: 1024M
key: ${{ runner.os }}-ccache-ng
restore-keys: |
${{ runner.os }}-ccache-ng
- name: SetupExample
run: |
yarn example install --frozen-lockfile
yarn example pods
- name: Modify APP ID
run: |
sed "s/localAppId = '\(.*\)'/localAppId = '${{ secrets.APP_ID }}'/g" agora.config.ts > tmp
mv tmp agora.config.ts
working-directory: example/src/config
- 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: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/${{ secrets.BUILD_PROVISION_PROFILE_UUID }}.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $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: Fastlane build
env:
CC: clang
CXX: clang++
CLANG: clang
CLANGPLUSPLUS: clang++
LD: clang
LDPLUSPLUS: clang++
CCACHE_SLOPPINESS: clang_index_store,file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,pch_defines,modules,system_headers,time_macros
CCACHE_FILECLONE: true
CCACHE_DEPEND: true
CCACHE_INODECACHE: true
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
fastlane gym --export_method "development" --export_options "{\"compileBitcode\":false}"
working-directory: example/ios
- uses: actions/upload-artifact@v3
with:
name: AgoraRtcNgExample
path: |
example/ios/*.ipa
- uses: actions/upload-artifact@v3
with:
name: AgoraRtcNgExampleSymbol
path: |
example/ios/*.dSYM.zip
notification:
runs-on: ubuntu-latest
needs: [ build-android, build-ios ]
steps:
- run: |
curl -X POST "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${{ secrets.WECHAT_KEY }}" -d '{"msgtype":"text","text":{"content":"ReactNative:\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}}'