Skip to content

Commit

Permalink
Fix release
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesa2 committed Apr 2, 2024
1 parent 6f26a3b commit 41d02fa
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 20 deletions.
44 changes: 28 additions & 16 deletions .github/workflows/Android-CI-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,54 @@ on:
- '*'

jobs:
release:
build:
name: Publish release ${{ github.ref }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install JDK ${{ matrix.java_version }}
uses: actions/setup-java@v4
with:
distribution: 'adopt'
distribution: "adopt"
java-version: 17

- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.4

- name: Build project
run: ./gradlew assembleRelease
env:
VERSION: ${{ github.ref }}

- name: Get the version
- name: Find Tag
id: tagger
uses: jimschubert/query-tag-action@v2
with:
skip-unshallow: 'true'
abbrev: false
commit-ish: HEAD
- name: Install Android SDK
uses: hannesa2/action-android/install-sdk@0.1.4.10
- name: Decrypt keystore
run: ./signing/decrypt.sh
env:
CRYPT_PASS: ${{ secrets.CRYPT_PASS }}
- name: Build project
run: ./gradlew clean assembleRelease
env:
TAG_VERSION: ${{steps.tagger.outputs.tag}}
CRYPT_PASS: ${{ secrets.CRYPT_PASS }}
KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }}
ALIAS_NAME: ${{ secrets.ALIAS_NAME }}
ALIAS_PASS: ${{ secrets.ALIAS_PASS }}
ARCORE_KEY: ${{ secrets.ARCORE_KEY }}
releaseKey: ${{ secrets.releaseKey }}
- name: cleanup keystore
run: ./signing/cleanup.sh

- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{steps.tagger.outputs.tag}}
name: ${{steps.tagger.outputs.tag}}
generate_release_notes: true
files: RxAudioLib/build/outputs/aar/*-release.aar
prerelease: false
name: ${{steps.tagger.outputs.tag}}
files: |
./app/build/outputs/apk/release/*.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 8 additions & 2 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ jobs:
java-version: ${{ matrix.java_version }}
- uses: gradle/wrapper-validation-action@v2
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.4
uses: hannesa2/action-android/install-sdk@0.1.4.10
- name: Decrypt keystore
run: ./signing/decrypt.sh
env:
CRYPT_PASS: ${{ secrets.CRYPT_PASS }}
- name: Build project
run: ./gradlew build
# - name: Run tests
# run: ./gradlew test
# - name: Run instrumentation tests
# uses: malinskiy/action-android/emulator-run-cmd@release/0.1.4
# uses: hannesa2/action-android/emulator-run-cmd@0.1.4.10
# with:
# cmd: ./gradlew cAT
# api: 21
Expand All @@ -48,3 +52,5 @@ jobs:
with:
name: Lint-report
path: app/build/reports/lint-results*.html
- name: cleanup keystore
run: ./signing/cleanup.sh
55 changes: 53 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

def keystorePropertiesFile = rootProject.file("signing/keystore.properties");
def keystoreProperties = new Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
namespace 'isomora.com.greendoctor'
defaultConfig {
applicationId "isomora.com.greendoctor"
minSdkVersion 26
Expand All @@ -26,14 +33,58 @@ android {
buildFeatures {
viewBinding = true
}
namespace 'isomora.com.greendoctor'
androidResources {
noCompress 'tflite'
}
signingConfigs {
debugCI {
storeFile file('../signing/debug.keystore')
storePassword "android"
keyPassword "android"
keyAlias "androiddebugkey"
}
release {
storeFile file('../signing/release.keystore')
storePassword keystoreProperties.getProperty('storePassword')
keyAlias keystoreProperties.getProperty('keyAlias')
keyPassword keystoreProperties.getProperty('keyPassword')
}
}
buildTypes {
debug {
if (System.getenv("CI") == "true") { // Github action
println "I run on Gitlab and use for debug the RELEASE signing"
signingConfig signingConfigs.release
}
}
release {
signingConfig signingConfigs.release
if (System.getenv("CI_SERVER")) { // gitlab
println "I run on Gitlab and use RELEASE signing"
signingConfig signingConfigs.release
} else if (System.getenv("CI") == "true") { // Github
println "I run on Github and use RELEASE signing"
signingConfig signingConfigs.release
} else if (file('../signing/release-key.keystore').exists()) {
if (System.getenv("KEYSTORE_PASS") == null || System.getenv("ALIAS_PASS") == null) {
println "I run somewhere else and I use DEBUG signing because variables are not set !"
signingConfig signingConfigs.debugCI
} else {
println "I use RELEASE signing"
signingConfig signingConfigs.release
}
} else {
println "I run somewhere else and I use debug signing"
signingConfig signingConfigs.debugCI
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'org.tensorflow:tensorflow-lite:2.15.0'
Expand Down
4 changes: 4 additions & 0 deletions signing/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

find . -name '*.keystore' |xargs rm
find . -name '*.properties' |xargs rm
Binary file added signing/debug.keystore.enc
Binary file not shown.
45 changes: 45 additions & 0 deletions signing/decrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

pwd

if [[ -z "$CRYPT_PASS" ]]
then
read -sp 'Password: ' CRYPT_PASS
if [[ -z "$CRYPT_PASS" ]]
then
echo "\$CRYPT_PASS Still empty"
exit 1
fi
else
echo "\$CRYPT_PASS available"
fi

openssl version

pushd signing

# to encrypt
#openssl aes-256-cbc -salt -pbkdf2 -k "$CRYPT_PASS" -in ./signing/release.keystore -out ./signing/release.keystore.enc
#openssl aes-256-cbc -salt -pbkdf2 -k "$CRYPT_PASS" -in ~/.android/debug.keystore -out ./signing/debug.keystore.enc
#openssl aes-256-cbc -salt -pbkdf2 -k "$CRYPT_PASS" -in ./app/google-services.json -out ./app/google-services.json.enc
#openssl aes-256-cbc -salt -pbkdf2 -k "$CRYPT_PASS" -in ./signing/Surveilance-playstore.json -out ./signing/Surveilance-playstore.json.enc
#openssl aes-256-cbc -salt -pbkdf2 -k "$CRYPT_PASS" -in ./signing/keystore.properties -out ./signing/keystore.properties.enc

# shellcheck disable=SC2038
find . -name "*.keystore.enc" | xargs ls -la

# Ubuntu 18.04 (openssl 1.1.0g+) needs -md md5
# https://askubuntu.com/questions/1067762/unable-to-decrypt-text-files-with-openssl-on-ubuntu-18-04/1076708
echo release.keystore
openssl aes-256-cbc -d -pbkdf2 -k "$CRYPT_PASS" -in release.keystore.enc -out release.keystore
echo debug.keystore
openssl aes-256-cbc -d -pbkdf2 -k "$CRYPT_PASS" -in debug.keystore.enc -out debug.keystore

#echo google-services.json
#openssl aes-256-cbc -d -pbkdf2 -k "$CRYPT_PASS" -in ../app/google-services.json.enc -out ../app/google-services.json
#echo Surveilance-playstore.json
#openssl aes-256-cbc -d -pbkdf2 -k "$CRYPT_PASS" -in Surveilance-playstore.json.enc -out Surveilance-playstore.json
echo keystore.properties
openssl aes-256-cbc -d -pbkdf2 -k "$CRYPT_PASS" -in keystore.properties.enc -out keystore.properties

popd 1>/dev/null
Binary file added signing/keystore.properties.enc
Binary file not shown.
Binary file added signing/release.keystore.enc
Binary file not shown.

0 comments on commit 41d02fa

Please sign in to comment.