Skip to content

Commit

Permalink
actions: restart building and releasing (fixes #1828) (#1825)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Jan 26, 2024
1 parent 4776d69 commit 08bcb33
Show file tree
Hide file tree
Showing 15 changed files with 368 additions and 232 deletions.
41 changes: 26 additions & 15 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
name: Android Check CI
name: treehouses remote build test

on:
push:
branches:
- '*'
- '!master'

#on:
# workflow_dispatch:
# inputs:

jobs:
build:
runs-on: ubuntu-latest

env:
ANDROID_NDK_VERSION: "21.3.6528147"
BUILD_TOOLS_VERSION: "30.0.2"

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- name: setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 1.8
- name: Install NDK
run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT}
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew assembleDebug
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
- name: install NDK
run: |
set -x
echo "ANDROID_HOME is set to: ${ANDROID_HOME}"
echo "ANDROID_SDK_ROOT is set to: ${ANDROID_SDK_ROOT}"
echo "ANDROID_NDK_VERSION is set to: ${ANDROID_NDK_VERSION}"
echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${ANDROID_NDK_VERSION}" --sdk_root=${ANDROID_SDK_ROOT} 2>&1
if [ $? -ne 0 ]; then
echo "SDK Manager command failed"
exit 1
fi
set +x
chmod +x ./gradlew
- name: build debug as test
run: ./gradlew assembleDebug
161 changes: 105 additions & 56 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,142 @@
name: Release And Update
name: treehouses remote release

on:
push:
branches:
- 'master'

#on:
# workflow_dispatch:
# inputs:
workflow_dispatch:

jobs:
apk:
name: Release APK
runs-on: ubuntu-latest
env:
ANDROID_NDK_VERSION: "21.3.6528147"
BUILD_TOOLS_VERSION: "34.0.0"
steps:
- name: run number with offset
id: build_id
id: version
env:
NUM: ${{ github.run_number }}
run: echo "::set-output name=id::$(($NUM+6050))"

- name: Checkout code
uses: actions/checkout@v2

- name: Use Java8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: checkout repository code
uses: actions/checkout@v4

- name: Install NDK
run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT}
- name: set more env
run: echo "BRANCHNAME="${GITHUB_REF##*/} >> $GITHUB_ENV

- name: Make gradlew executable
run: chmod +x ./gradlew
- name: setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'

- name: Generate APK
run: ./gradlew build
- name: install NDK
run: |
set -x
echo "ANDROID_HOME is set to: ${ANDROID_HOME}"
echo "ANDROID_SDK_ROOT is set to: ${ANDROID_SDK_ROOT}"
echo "ANDROID_NDK_VERSION is set to: ${ANDROID_NDK_VERSION}"
echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${ANDROID_NDK_VERSION}" --sdk_root=${ANDROID_SDK_ROOT} 2>&1
if [ $? -ne 0 ]; then
echo "SDK Manager command failed"
exit 1
fi
set +x
chmod +x ./gradlew
- name: List APK
run: ls app/build/outputs/apk
- name: build release APK and AAB
run: |
./gradlew assembleRelease bundleRelease
ls -alR app/build/outputs
mkdir -p sign
cp app/build/outputs/bundle/release/app-release.aab sign/.
cp app/build/outputs/apk/release/remote-${{ steps.version.outputs.id }}.apk sign/app-release-unsigned.apk
ls -al sign
- name: Android Sign
uses: Tlaster/android-[email protected]
- name: sign release APK and AAB
uses: dogi/sign-android-[email protected]
with:
releaseDirectory: app/build/outputs/apk/release
releaseDirectory: sign
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
output: build/release/signed
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "30.0.2"

- name: Move Files to release

- name: copy builds to output and generate sha256
run: |
cp app/build/outputs/mapping/release/mapping.txt build/release/signed/mapping.txt
cp app/build/outputs/apk/debug/* build/release/signed/
mv build/release/signed/remote-${{ steps.build_id.outputs.id }}-signed.apk build/release/signed/remote.apk
sha256sum build/release/signed/remote.apk > build/release/signed/remote.apk.sha256
- name: Mobile Security Framework
mkdir -p output
cp sign/app-release-unsigned-signed.apk output/remote.apk
cp sign/app-release.aab output/remote.aab
sha256sum output/remote.apk > output/remote.apk.sha256
sha256sum output/remote.aab > output/remote.aab.sha256
ls -alR output
# - name: publish AAB to playstore
# if: github.ref == 'refs/heads/master'
# uses: r0adkll/[email protected]
# with:
# serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
# packageName: io.treehouses.remote
# releaseFiles: output/remote.aab
# track: internal
# releaseName: "${{ env.ANDROID_VERSION_CODE }} (${{ env.ANDROID_VERSION_NAME }})"
# status: completed

# - name: mobile security framework
# run: |
# docker pull opensecurity/mobile-security-framework-mobsf
# docker run -itd -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest
# cd output
# ls -al
# wget http://localhost:8000/api_docs
# MOBSF_API_KEY=$(grep 'Api Key' api_docs)
# echo MOBSF_API_KEY
# MOBSF_API_KEY=${MOBSF_API_KEY:42:64}
# echo MOBSF_API_KEY
# rm api_docs
# HASH=$(md5sum remote.apk)
# HASH=${HASH:0:32}
# curl -F "[email protected]" http://localhost:8000/api/v1/upload -H "Authorization:$MOBSF_API_KEY"
# curl -X POST --url http://localhost:8000/api/v1/scan --data "scan_type=apk&file_name=remote.apk&hash=$HASH" -H "Authorization:$MOBSF_API_KEY"
# curl -X POST --url http://localhost:8000/api/v1/download_pdf --data "hash=$HASH" -H "Authorization:$MOBSF_API_KEY" --output remote-${{ steps.version.outputs.id }}.pdf
# ls -al

- name: rename APK and AAB with version and branch for artifact
if: github.ref != 'refs/heads/master'
run: |
docker pull opensecurity/mobile-security-framework-mobsf
docker run -itd -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest
cd build/release/signed/
ls -al
wget http://localhost:8000/api_docs
MOBSF_API_KEY=$(grep 'REST API Key' api_docs)
MOBSF_API_KEY=${MOBSF_API_KEY:42:64}
rm api_docs
HASH=$(md5sum remote.apk)
HASH=${HASH:0:32}
curl -F "[email protected]" http://localhost:8000/api/v1/upload -H "Authorization:$MOBSF_API_KEY"
curl -X POST --url http://localhost:8000/api/v1/scan --data "scan_type=apk&file_name=remote.apk&hash=$HASH" -H "Authorization:$MOBSF_API_KEY"
curl -X POST --url http://localhost:8000/api/v1/download_pdf --data "hash=$HASH" -H "Authorization:$MOBSF_API_KEY" --output ${{ steps.build_id.outputs.id }}-security-scan.pdf
ls -al
mv output/remote.apk output/remote-${{ steps.version.outputs.id }}-${{ env.BRANCHNAME }}.apk
mv output/remote.apk.sha256 output/remote-${{ steps.version.outputs.id }}-${{ env.BRANCHNAME }}.apk.sha256
mv output/remote.aab output/remote-${{ steps.version.outputs.id }}-${{ env.BRANCHNAME }}.aab
mv output/remote.aab.sha256 output/remote-${{ steps.version.outputs.id }}-${{ env.BRANCHNAME }}.aab.sha256
#mv output/remote-${{ steps.version.outputs.id }}.pdf output/remote-${{ steps.version.outputs.id }}-${{ env.BRANCHNAME }}.pdf
#cp app/build/outputs/mapping/release/mapping.txt output/mapping.txt
ls -alR output
- name: upload APK and AAB as build artifact
if: github.ref != 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: remote-${{ steps.version.outputs.id }}-${{ env.BRANCHNAME }}
path: output/*
retention-days: 9

- name: Upload binaries to release
- name: release APK and AAB on GitHub
if: github.ref == 'refs/heads/master'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/release/signed/*
tag: v${{ steps.build_id.outputs.id }}
file: output/*
tag: v${{ steps.version.outputs.id }}
overwrite: true
file_glob: true

- name: Send Message
- name: send success message to discord
if: github.ref == 'refs/heads/master'
run: |
sudo npm install -g @treehouses/cli
export gitter_channel="${{ secrets.CHANNEL }}"
echo "https://github.com/treehouses/remote/releases/tag/v${{ steps.build_id.outputs.id }}"
treehouses feedback "new remote app: https://github.com/treehouses/remote/releases/tag/v${{ steps.build_id.outputs.id }}"
export discord_channel="${{ secrets.CHANNEL }}"
echo "https://github.com/treehouses/remote/releases/tag/v${{ steps.version.outputs.id }}"
treehouses feedback "new remote app: https://github.com/treehouses/remote/releases/tag/v${{ steps.version.outputs.id }}"
15 changes: 8 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ def appVersionCode = (System.env.GITHUB_RUN_NUMBER ? Integer.valueOf(System.env.
def appVersionName = (System.env.GITHUB_RUN_NUMBER ? Integer.valueOf(System.env.GITHUB_RUN_NUMBER) + 6050: "1.0.0") + ""

android {
compileSdkVersion 29
namespace 'io.treehouses.remote'
compileSdkVersion 34
defaultConfig {
applicationId "io.treehouses.remote"
minSdkVersion 15
targetSdkVersion 29
targetSdkVersion 34
ndkVersion '21.3.6528147'
multiDexEnabled true
versionCode appVersionCode
Expand Down Expand Up @@ -38,15 +39,15 @@ android {
// }

}
lintOptions {
lint {
abortOnError false
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
sourceCompatibility = '17'
targetCompatibility = '17'
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
}

Expand Down Expand Up @@ -110,4 +111,4 @@ repositories {

android.sourceSets.all {
java.srcDir("src/$name/kotlin")
}
}
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.treehouses.remote">
xmlns:tools="http://schemas.android.com/tools">
<!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Expand Down Expand Up @@ -34,7 +33,8 @@
<activity android:name=".IntroActivity" />
<activity
android:name=".SplashScreenActivity"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class ViewHolderSSHAllKeyRow(private val binding: RowKeyBinding, private val lis
menu?.children?.forEach { it.setOnMenuItemClickListener(this) }
}

override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
override fun onMenuItemClick(item: MenuItem): Boolean {
when (item.itemId) {
R.id.copy_public -> listener.onCopyPub(adapterPosition)
R.id.delete_key -> listener.onDelete(adapterPosition)
R.id.send_key -> listener.onSendToRaspberry(adapterPosition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class TerminalKeyListener(tm: TerminalManager?,
} else false
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences,
key: String) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?,
key: String?) {
if (PreferenceConstants.KEYMODE == key || PreferenceConstants.SHIFT_FKEYS == key || PreferenceConstants.CTRL_FKEYS == key || PreferenceConstants.VOLUME_FONT == key || PreferenceConstants.STICKY_MODIFIERS == key) {
updatePrefs()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ class TerminalManager : Service(), BridgeDisconnectedListener, OnSharedPreferenc
/* (non-Javadoc)
* @see android.content.SharedPreferences.OnSharedPreferenceChangeListener#onSharedPreferenceChanged(android.content.SharedPreferences, java.lang.String)
*/
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences,
key: String) {
if (PreferenceConstants.BUMPY_ARROWS == key) wantKeyVibration = sharedPreferences.getBoolean(PreferenceConstants.BUMPY_ARROWS, true)
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?,
key: String?) {
if (PreferenceConstants.BUMPY_ARROWS == key) wantKeyVibration = sharedPreferences!!.getBoolean(PreferenceConstants.BUMPY_ARROWS, true)
else if (PreferenceConstants.WIFI_LOCK == key) { } else if (PreferenceConstants.MEMKEYS == key) savingKeys = prefs!!.getBoolean(PreferenceConstants.MEMKEYS, true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ class TerminalView(context: Context, bridge: TerminalBridge, pager: TerminalView
* This should only handle scrolling when terminalTextViewOverlay is `null`, but
* we need to handle the page up/down gesture if it's enabled.
*/
override fun onScroll(e1: MotionEvent, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
override fun onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
// activate consider if within x tolerance
val touchSlop = ViewConfiguration.get(this@TerminalView.context).scaledTouchSlop
if (Math.abs(e1.x - e2.x) < touchSlop * 4) {
if (Math.abs(e1!!.x - e2.x) < touchSlop * 4) {
// estimate how many rows we have scrolled through
// accumulate distance that doesn't trigger immediate scroll
totalY += distanceY
Expand Down Expand Up @@ -346,7 +346,7 @@ class TerminalView(context: Context, bridge: TerminalBridge, pager: TerminalView
return super.onSingleTapConfirmed(e)
}

override fun onDoubleTap(e: MotionEvent?): Boolean {
override fun onDoubleTap(e: MotionEvent): Boolean {
try {
bridge.transport?.write(0x09)
bridge.tryKeyVibrate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ open class SSHConsole : DerivedSSHConsole(), BridgeDisconnectedListener {
return true
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item == null) return false
return when (item.itemId) {
android.R.id.home -> {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.6.21'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
Loading

0 comments on commit 08bcb33

Please sign in to comment.