Skip to content

Commit

Permalink
Release signing
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesa2 committed Dec 31, 2020
1 parent 119a5f7 commit 0d38c50
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/Android-CI-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
java-version: 1.8
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.0
- name: Decrypt keystore
run: ./signing/decrypt.sh
env:
CRYPT_PASS: ${{ secrets.CRYPT_PASS }}
- name: Build project
run: ./gradlew clean build
env:
Expand All @@ -33,3 +37,5 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.ref }}
- name: cleanup keystore
run: ./signing/cleanup.sh
8 changes: 8 additions & 0 deletions .github/workflows/Android-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
# with:
# name: MediaPipe-Screenshots
# path: applications/screenshots/adb/
- name: cleanup keystore
run: ./signing/cleanup.sh
Check:
name: Check
runs-on: ubuntu-latest
Expand All @@ -65,8 +67,14 @@ jobs:
java-version: 1.8
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.0
- name: Decrypt keystore
run: ./signing/decrypt.sh
env:
CRYPT_PASS: ${{ secrets.CRYPT_PASS }}
- name: Code checks
run: ./gradlew check
- name: cleanup keystore
run: ./signing/cleanup.sh
- name: Archive Lint report
uses: actions/[email protected]
if: ${{ always() }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ build
captures
.externalNativeBuild
.cxx

*.keystore
60 changes: 60 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,57 @@ android {
targetSdkVersion 29
versionCode getGitCommitCount()
versionName getTag()
buildConfigField "String", 'GIT_USER', "\"" + getGitUser() + "\""
buildConfigField "String", 'GIT_REPOSITORY', "\"" + getGitRepository() + "\""
buildConfigField "String", 'VERSION', "\"" + versionName + "\""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
storeFile file('../signing/release.keystore')
storePassword System.getenv("KEYSTORE_PASS")
keyAlias System.getenv("ALIAS_NAME")
keyPassword System.getenv("ALIAS_PASS")
}
debug {
storePassword "android"
keyPassword "android"
keyAlias "androiddebugkey"
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
if (System.getenv("CI_SERVER")) { // gitlab
println "I run on Gitlab and use RELEASE signing"
signingConfig signingConfigs.release
} else if (file('../signing/release.keystore').exists()) {
if (System.getenv("KEYSTORE_PASS") == null || System.getenv("ALIAS_NAME") == null || System.getenv("ALIAS_PASS") == null) {
println "I run somewhere else and I use DEBUG signing because variables are not set !"
signingConfig signingConfigs.debug
} else {
println "I run somewhere else and I use RELEASE signing"
signingConfig signingConfigs.release
}
} else {
println "I run somewhere else and I use debug signing"
signingConfig signingConfigs.debug
}
}
debug {
if (System.getenv("CI") == "true") { // Github action
signingConfig signingConfigs.release
} else {
signingConfig signingConfigs.debug
}
applicationIdSuffix ".debug"
}
}

compileOptions {
targetCompatibility = 1.8
sourceCompatibility = 1.8
Expand All @@ -40,4 +82,22 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
}

static def getGitOriginRemote() {
def process = "git remote -v".execute()
def values = process.text.toString().trim().split("\\r\\n|\\n|\\r")

def found = values.find { it.startsWith("origin") && it.endsWith("(push)") }
return found.replace("origin", "").replace("(push)", "").replace(".git", "").trim()
}

static def getGitUser() {
def token = getGitOriginRemote().split("/")
return token[3]
}

static def getGitRepository() {
def token = getGitOriginRemote().split("/")
return token[4]
}
3 changes: 3 additions & 0 deletions signing/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

find . -name '*.keystore' |xargs rm
26 changes: 26 additions & 0 deletions signing/decrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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

pushd signing

# to encrypt
#openssl aes-256-cbc -a -salt -k "$CRYPT_PASS" -in release.keystore -out release.keystore.enc

# 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
openssl aes-256-cbc -a -d -md md5 -k "$CRYPT_PASS" -in release.keystore.enc -out release.keystore

popd 1>/dev/null
48 changes: 48 additions & 0 deletions signing/release.keystore.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
U2FsdGVkX19m4xKlexyJ628fHsOMqPPEyTqUzYmYG1ORUhA/Tu4a07bHlaaGW4Ve
DhddCllbQFN6o3Zc1VhrNrPQB9FJg/aTBbsPEBK++uxveqDWKESlPei9eN5FCtQ+
spWYG1Gy0lVjTnHCdlnImleUy+5wElS/+2Q/jAMg3I+H/Rb2SSVW9B/k28nQUtxs
4OZqt7CubNOw6yo4kbhNk87wgPS3ZcbRb6YHWwruKtXN4JaH73LvsMaYZTPk04Fm
2dhDvY7l+CtlEGQ1ck1GeP7ly6MgYVfZSDEUEowjc54iWd2512TWEluIPcdSxqLt
CWswRuhIbplJCboShykJZx7lTxhtJ5QJcG7M8XpxP3cfOz4ID4exS0z2w0b+7N5Y
U6UDMEpIaok6vt8/B5j4azwPvef7rLXFF+Ng/SHTILwzAbRtuxz8UHSnOYPwoWcA
mtuGKYeRs6GHcetc4Td59D8kCokyP3Tmvh5aVMPHm3writtWS1utcME4sBQAVX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