Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-build with app sign #739

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Android

on: [push, workflow_dispatch]

jobs:
build:
name: Build APK
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '11' # only 11 works for this project

- name: Setup Node.js
uses: actions/setup-node@v1
with:

node-version: 18.x


- name: Install Cordova
run: npm install -g cordova

- name: Install yarn
run: npm install -g yarn

- name: Install app dependencies
run: yarn setup

- name: Configure the platform
run: yarn clean

# - name: Add Android platform
# run: cordova platform add android

- name: Build Android dev apk
run: yarn build android paid dev

- name: Build Android prod aab
run: yarn build android paid prod

- name: Sign
run: |
sudo chmod 777 ./sign.sh
./sign.sh

- name: Upload dev APK
uses: actions/upload-artifact@v3
with:
name: app-dev
path: ./*.apk

- name: Upload release bundle
uses: actions/upload-artifact@v3
with:
name: app-release
path: ./*.aab
29 changes: 29 additions & 0 deletions .github/workflows/del_old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Delete old workflow runs
on:
workflow_dispatch:
inputs:
days:
description: 'Number of days.'
required: true
default: 30
minimum_runs:
description: 'The minimum runs to keep for each workflow.'
required: true
default: 6
delete_workflow_pattern:
description: 'The name of the workflow. if not set then it will target all workflows.'
required: false

jobs:
del_runs:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: ${{ github.event.inputs.days }}
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
Binary file added acode.keystore
Binary file not shown.
2 changes: 1 addition & 1 deletion build-extras.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ext.cdvCompileSdkVersion = 31
ext.cdvCompileSdkVersion = 33

configurations {
all {
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<preference name="BackgroundColor" value="0xFF313131" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="android-minSdkVersion" value="22" />
<preference name="android-targetSdkVersion" value="31" />
<preference name="android-targetSdkVersion" value="33" />
<preference name="AndroidLaunchMode" value="singleTask" />
<preference name="prerendered-icon" value="false" />
<preference name="androidxEnabled" value="true" />
Expand Down
30 changes: 30 additions & 0 deletions sign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

## convert aab bundle to APK

# grab tool for conversion
if [ ! -f bundletool-all-1.13.1.jar ]; then
wget https://github.com/google/bundletool/releases/download/1.13.1/bundletool-all-1.13.1.jar
fi

# generate signature
if [ ! -f acode.keystore ]; then
# keytool -genkey -v -keystore acode.keystore -alias acode -keyalg RSA -keysize 2048 -validity 10000 -storepasswd acode123 -keypasswd acode123
keytool -genkey -alias acode \
-keyalg RSA -keystore acode.keystore \
-dname "CN=Mark Smith, OU=JavaSoft, O=Sun, L=Cupertino, S=California, C=US" \
-validity 36500 \
-keysize 4096 \
-storepass password -keypass password
fi

# cleanup if needed
rm -rf *.apks toc.pb

# convert to apk
for aab in *.aab; do
java -jar "bundletool-all-1.13.1.jar" build-apks --bundle=$aab --mode=universal --output="${aab%.*}.apks" --ks=acode.keystore --ks-pass=pass:password --ks-key-alias=acode --key-pass=pass:password

# extract apk
unzip ${aab%.*}.apks
mv -v universal.apk ${aab%.*}.apk
done
2 changes: 1 addition & 1 deletion src/plugins/system/utils/changeProvider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
changeProvider(reset) {
changeProvider(reset=true) {
const fs = require('fs');
const path = require('path');

Expand Down
55 changes: 55 additions & 0 deletions utils/rename.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const path = require('path');
const fs = require('fs');
const { promisify } = require('util');
const exec = promisify(require('child_process').exec);

(async () => {
const platformsDir = path.resolve(__dirname, '../platforms/');
const configpath = path.resolve(__dirname, '../config.xml');
const APK_PATH = platformsDir + "/android/app/build/outputs/apk/debug/app-debug.apk";
const AAB_PATH = platformsDir + "/android/app/build/outputs/bundle/release/app-release.aab";
const ID_PAID = 'com.foxdebug.acode';
const ID_FREE = 'com.foxdebug.acodefree';
const CONFIG_VERSION = /<widget.* version="([0-9.]+)"/;
const arg = process.argv[2];
const arg2 = process.argv[3];

try {
let config = fs.readFileSync(configpath, 'utf-8');
let platforms = fs.readdirSync(platformsDir);
let name, id, version, build, artifact, ext, target;

try{
version = CONFIG_VERSION.exec(config)[1];
} catch (error) {
version = '0.0.0';
}

if (arg[0] === 'd') {
build = '_debug';
artifact = APK_PATH;
ext = '.apk';
} else if (arg[0] === 'p') {
build = '';
artifact = AAB_PATH;
ext = '.aab';
}

if (arg2 === 'free') {
id = ID_FREE;
} else {
id = ID_PAID;
}

name = '../' + id + '_' + version + build + ext;
target = path.resolve(__dirname, name);

console.log(artifact + " -> " + target);
fs.rename(artifact, target, () => {});

process.exit(0);
} catch (error) {
console.error(error);
process.exit(1);
}
})();
7 changes: 5 additions & 2 deletions utils/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ script1="node ./utils/config.js $mode $app"
script2="webpack --progress --mode $webpackmode "
script3="node ./utils/loadStyles.js"
script4="cordova build $platform $cordovamode"
script5="node ./utils/rename.js $mode $app"
eval "
echo \"${RED}$script1${NC}\";
$script1;
Expand All @@ -42,5 +43,7 @@ $script2&&
echo \"${RED}$script3${NC}\";
$script3;
echo \"${RED}$script4${NC}\";
$script4
"
$script4;
echo \"${RED}$script5${NC}\";
$script5
"
3 changes: 2 additions & 1 deletion utils/scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ fi

eval "
cordova platform rm $platform_rm;
cordova platform add $platform_add
cordova platform add $platform_add;
cordova plugin add cordova-plugin-file
"