Skip to content

Commit

Permalink
Fix #115: Share configurations between PowerAuth instances (#143)
Browse files Browse the repository at this point in the history
* Split CI build into separate jobs
* Use the same nodejs version as Github Action
  • Loading branch information
hvge committed Nov 7, 2022
1 parent 27c22fc commit 7a9b999
Show file tree
Hide file tree
Showing 9 changed files with 1,049 additions and 1,255 deletions.
58 changes: 52 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: build library

on:
push:
Expand All @@ -10,19 +10,65 @@ on:
- cron: '25 6 * * *'

jobs:
buildnrun:
name: Build iOS and Android library
build-android:
name: Build Android library
runs-on: macos-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup NPM tools
run: npm install -g pod-install && npm install -g react-native && npm install -g typescript
- name: Build native Android libraries
run: bash scripts/build-library.sh android

build-ios:
name: Build iOS library
runs-on: macos-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup NPM tools
run: npm install -g pod-install && npm install -g react-native && npm install -g typescript
- name: Build native iOS libraries
run: bash scripts/build-library.sh ios

build-tsc:
name: Compile typescript
runs-on: macos-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup NPM tools
run: npm install -g pod-install && npm install -g react-native && npm install -g typescript
- name: Build native libraries
run: sh scripts/build-library.sh
- name: Compile sources
run: bash scripts/build-library.sh tsc
22 changes: 22 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,25 @@ dependencies {
implementation 'com.facebook.react:react-native:+'
api "com.wultra.android.powerauth:powerauth-sdk:1.7.5"
}

allprojects {
repositories {
exclusiveContent {
// Fix for https://github.com/facebook/react-native/issues/35210
//
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
// NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
url "$rootDir/../node_modules/react-native/android"
}
}
}
}
}
149 changes: 101 additions & 48 deletions scripts/build-library.sh
Original file line number Diff line number Diff line change
@@ -1,69 +1,124 @@
#!/bin/bash

set -e # stop sript when error occures
set -u # stop when undefined variable is used
#set -x # print all execution (good for debugging)
TOP=$(dirname $0)
source "$TOP/common-functions.sh"
SRC="${TOP}/.."

DO_TSC=1
DO_ANDROID=1
DO_IOS=1

if [ ! -z $1 ]; then
case $1 in
android)
DO_TSC=0
DO_ANDROID=1
DO_IOS=0
;;
ios)
DO_TSC=0
DO_ANDROID=0
DO_IOS=1
;;
tsc | typescript)
DO_TSC=1
DO_ANDROID=0
DO_IOS=0
;;
*)
FAILURE "Unknown build target $1" ;;
esac
fi

LOG_LINE
LOG 'Installing dependencies'
LOG_LINE

echo '------------------------------------------------------------'
echo 'Installing dependencies'
echo '------------------------------------------------------------'
export NPM_TOKEN="DUMMY" # dummy variable to silence npm error

TOP=$(dirname $0)

# jump to top-project-folder
pushd "${TOP}/.."
PUSH_DIR "${SRC}"

# instal npm dependencies
npm i

echo '------------------------------------------------------------'
echo 'Building iOS platform'
echo '------------------------------------------------------------'
if [ x$DO_IOS == x1 ]; then
LOG_LINE
LOG 'Building iOS platform'
LOG_LINE

npx pod-install

PUSH_DIR ios

LOG_LINE
LOG 'Compiling iOS Release'
LOG_LINE

xcrun xcodebuild \
-workspace "PowerAuth.xcworkspace" \
-scheme "PowerAuth" \
-configuration "Release" \
-sdk "iphonesimulator" \
-arch x86_64 \
build

LOG_LINE
LOG 'Compiling iOS Debug'
LOG_LINE

xcrun xcodebuild \
-workspace "PowerAuth.xcworkspace" \
-scheme "PowerAuth" \
-configuration "Debug" \
-sdk "iphonesimulator" \
-arch x86_64 \
build

POP_DIR

fi # DO_IOS

if [ x$DO_ANDROID == x1 ]; then
LOG_LINE
LOG 'Building Android platform'
LOG_LINE


PUSH_DIR android

./gradlew clean build

POP_DIR

npx pod-install
fi # DO_ANDROID

pushd ios
if [ x$DO_TSC == x1 ]; then
LOG_LINE
LOG 'Building library'
LOG_LINE

echo '------------------------------------------------------------'
echo 'Compiling iOS Release'
echo '------------------------------------------------------------'
tsc --build

xcrun xcodebuild \
-workspace "PowerAuth.xcworkspace" \
-scheme "PowerAuth" \
-configuration "Release" \
-sdk "iphonesimulator" \
-arch x86_64 \
build
PUSH_DIR testapp

echo '------------------------------------------------------------'
echo 'Compiling iOS Debug'
echo '------------------------------------------------------------'
LOG_LINE
LOG 'Updating testapp dependencies'
LOG_LINE

xcrun xcodebuild \
-workspace "PowerAuth.xcworkspace" \
-scheme "PowerAuth" \
-configuration "Debug" \
-sdk "iphonesimulator" \
-arch x86_64 \
build
"${TOP}/update-apps.sh"

popd
LOG_LINE
LOG 'Building testapp'
LOG_LINE

echo '------------------------------------------------------------'
echo 'Building Android platform'
echo '------------------------------------------------------------'
tsc --build

pushd android
POP_DIR

./gradlew clean build
fi # DO_TSC

echo '------------------------------------------------------------'
echo 'Building Typescript'
echo '------------------------------------------------------------'
popd
tsc --build
POP_DIR

# THIS IS TEMPORARY DISABLED - FOR SOME REASON, GIT STATUS IS DIFFERENT IN PODS THAN IN LOCAL ENV.
# check if the git status is clean (there should be no changs)
Expand All @@ -76,6 +131,4 @@ tsc --build
# exit 1
# fi

echo '------------------------------------------------------------'
echo 'SUCCESS'
echo ''
EXIT_SUCCESS
22 changes: 14 additions & 8 deletions scripts/update-apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ REQUIRE_COMMAND "npm"

LIB='react-native-powerauth-mobile-sdk'

DO_TEST=1
DO_RUN=0
DO_TEST=1 # apply for testapp
DO_RUN=0 # start platform apps
DO_PODS=0 # do pod install in project

case $1 in
test | testapp)
DO_TEST=1 ;;
run | -r)
DO_RUN=1 ;;
pods | --cp)
DO_PODS=1 ;;
*)
DO_TEST=1 ;;
esac
Expand Down Expand Up @@ -59,13 +63,15 @@ function UPDATE_DEPENDENCIES

POP_DIR

LOG_LINE
LOG 'Updating CocoaPods...'
LOG_LINE
if [ x$DO_PODS == x1 ]; then
LOG_LINE
LOG 'Updating CocoaPods...'
LOG_LINE

PUSH_DIR "${SRC}/${APP_NAME}/ios"
pod install
POP_DIR
PUSH_DIR "${SRC}/${APP_NAME}/ios"
pod install
POP_DIR
fi

if [ x$DO_RUN == x1 ]; then
PUSH_DIR "${SRC}/${APP_NAME}"
Expand Down
Loading

0 comments on commit 7a9b999

Please sign in to comment.