From cb294e5a804b2a90da0e2ebf3b816c58512d2b60 Mon Sep 17 00:00:00 2001 From: axi92 Date: Wed, 31 Jul 2024 08:34:13 +0200 Subject: [PATCH] build: workflow for android build (#7) Signed-off-by: axi92 Co-authored-by: codepushr <1425202+codepushr@users.noreply.github.com> --- .github/workflows/android.yml | 35 +++++++++++++++++++++++ .gitignore | 2 +- README.md | 10 ++++++- android/build.gradle | 2 +- example/android/app/build.gradle | 21 ++++++++++++-- example/android/local.properties.template | 5 ++++ 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/android.yml create mode 100644 example/android/local.properties.template diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..d1bf0a2 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,35 @@ +name: Android +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: Setup Nodejs + uses: actions/setup-node@v4 + with: + node-version: '22' + - run: | + corepack yarn + cd example && yarn install + + - name: Build android example app + run: yarn build:android + env: + GH_USERNAME: ${{ vars.USERNAME }} + # PAT has read:packages permissions + GH_TOKEN: ${{ secrets.TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 62ba82b..1b38f2f 100644 --- a/.gitignore +++ b/.gitignore @@ -139,4 +139,4 @@ example/android/app/build/ example/vendor/ example/android/.idea/ example/android/local.properties - +android/build diff --git a/README.md b/README.md index 80ffedb..ffd5899 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ The EVVA React-Native Module is a collection of tools to work with electronical ## Requirements + Java 17+ + Android SDK + Xcode 15+ react-native < 0.74.3 iOS 15.0+ Android 10+ (API level 29) @@ -26,6 +29,11 @@ The EVVA React-Native Module is a collection of tools to work with electronical ``` yarn add ``` + +### Setup Github auth to load package + +Create a copy of [local.properties.template](example/android/local.properties.template) and rename it to local.properties in the same directory. Paste your github username and [classic PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) + ### IOS Add the following to your Podfile: @@ -115,4 +123,4 @@ AbrevvaBle.disengage( isPermanentRelease: '', timeout: 10_000 ); -``` \ No newline at end of file +``` diff --git a/android/build.gradle b/android/build.gradle index b3558b8..f0df3a4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -100,7 +100,7 @@ dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation group: "com.evva.xesar", name: "abrevva-sdk-android", version: "1.0.15" + implementation group: "com.evva.xesar", name: "abrevva-sdk-android", version: "1.0.19" } diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 7f8cc4f..5a29035 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -109,13 +109,30 @@ android { } } +Properties properties = new Properties() +try { + def propertiesFile = new File(rootProject.rootDir, "local.properties") + if (propertiesFile.exists()) { + properties.load(new FileInputStream(propertiesFile)) + println("Properties loaded successfully.") + } else { + println("local.properties file does not exist.") + } +} catch (Exception e) { + println("Failed to load properties: ${e.message}") +} + repositories { google() mavenCentral() mavenLocal() maven { - name = "evva-maven" - url = url = uri("https://maven.pkg.github.com/evva-sfw/abrevva-sdk-android") + name = 'evva-maven' + url = uri('https://maven.pkg.github.com/evva-sfw/abrevva-sdk-android') + credentials { + username = properties.getProperty('github.username') ?: System.getenv('GH_USERNAME') + password = properties.getProperty('github.token') ?: System.getenv('GH_TOKEN') + } } } diff --git a/example/android/local.properties.template b/example/android/local.properties.template new file mode 100644 index 0000000..c606ccc --- /dev/null +++ b/example/android/local.properties.template @@ -0,0 +1,5 @@ +# Github only let you load packages with authentication. +# How to create a github token with read permissions on packages is explained here: +# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-to-github-packages +github.username= +github.token= \ No newline at end of file