Skip to content

Commit

Permalink
Merge pull request #35 from Montelibero/sign-android-artifacts
Browse files Browse the repository at this point in the history
Sign android artifacts
  • Loading branch information
bulbigood authored Mar 22, 2024
2 parents 40aad93 + 61468fe commit 6d830f6
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 21 deletions.
50 changes: 40 additions & 10 deletions .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@ jobs:
npm install
npm run prebuild:electron
- name: Build project artifacts (iOS)
- name: Install project platform (iOS)
run: |
cd cordova
npm install
npm run install:ios
npm run prebuild:ios
- name: Build artifacts
run: |
cd cordova
npm run build:ios
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Solar.app
path: /Users/runner/work/mtl_solar/mtl_solar/cordova/platforms/ios/build/emulator/Solar.app
name: MTL_Solar_ios.app
path: ${{ github.workspace }}/cordova/platforms/ios/build/emulator/Montelibero Solar.app
compression-level: 0

build-android:
runs-on: macos-latest
Expand Down Expand Up @@ -62,15 +68,39 @@ jobs:
npm install
npm run prebuild:electron
- name: Build project artifacts (Android)
- name: Install project platform (Android)
run: |
cd cordova
npm install
npm run install:android
npm run build:android
npm run prebuild:android
- name: Upload artifacts
uses: actions/upload-artifact@v2
- name: Build artifacts
env:
KEYSTORE_LOCATION: ${{ github.workspace }}/android.keystore
ENCRYPTED_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }}
KEYSTORE_GPG_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_GPG_PASS }}
KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASS }}
SIGNINGKEY_ALIAS: android
SIGNINGKEY_PASSWORD: ${{ secrets.ANDROID_SIGNINGKEY_PASS }}
run: | # decrypting keystore from secrets to a file is safe because the resulting file is encrypted as well
ENCRYPTED_KEYSTORE_LOCATION="$KEYSTORE_LOCATION".asc
echo "$ENCRYPTED_KEYSTORE" > "$ENCRYPTED_KEYSTORE_LOCATION"
gpg -d --passphrase "$KEYSTORE_GPG_PASSWORD" --batch "$ENCRYPTED_KEYSTORE_LOCATION" > "$KEYSTORE_LOCATION"
cd cordova
PACKAGE_TYPE=bundle npm run build:android:signed:auto
PACKAGE_TYPE=apk npm run build:android:signed:auto
- name: Upload .apk artifact
uses: actions/upload-artifact@v4
with:
name: MTL_Solar_android.apk
path: ${{ github.workspace }}/cordova/platforms/android/app/build/outputs/apk/release/app-release.apk
compression-level: 0

- name: Upload .aab artifact
uses: actions/upload-artifact@v4
with:
name: app-debug.apk
path: /Users/runner/work/mtl_solar/mtl_solar/cordova/platforms/android/app/build/outputs/apk/debug/app-debug.apk
name: MTL_Solar_android.aab
path: ${{ github.workspace }}/cordova/platforms/android/app/build/outputs/bundle/release/app-release.aab
compression-level: 0
10 changes: 8 additions & 2 deletions cordova/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ You can now select a device from the dropdown in the upper-left corner and run t
Follow the setup of the development builds but instead of `npm run dev:android/ios` use:

```
# Android
npm run prebuild:android
npm run build:android
# iOS
npm run prebuild:ios
npm run build:ios
```

Expand All @@ -91,10 +96,11 @@ KEYSTORE_LOCATION=/location/of/my.keystore
SIGNINGKEY_ALIAS=AliasOfMyKey
```

Run the following npm script to start the build process of the signed apk.
Specify PACKAGE_TYPE (apk, bundle) and run the following npm script to start the build process of the signed apk.

```
npm run build:android:signed
npm run prebuild:android
PACKAGE_TYPE=apk npm run build:android:signed:manual
```

Enter the passwords for keystore and key when prompted. The location of the generated .apk file will appear in the output log once the build process succeeds.
Expand Down
2 changes: 1 addition & 1 deletion cordova/config/config.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="org.montelibero.solar" version="$PACKAGE_VERSION" android-versionCode="$ANDROID_VERSIONCODE" ios-CFBundleVersion="$IOS_BUNDLE_VERSION" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<name>Montelibero Solar</name>
<name short="MTL Solar">Montelibero Solar</name>
<description>
Wallet for the Stellar payment network by Montelibero.
</description>
Expand Down
20 changes: 18 additions & 2 deletions cordova/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions cordova/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-local-notification": {},
"cordova-plugin-androidx-adapter": {}
"cordova-plugin-androidx-adapter": {},
"cordova-plugin-proguard": {}
}
},
"dependencies": {
Expand All @@ -54,6 +55,7 @@
"cordova-ios": "^6.1.1",
"cordova-plugin-androidx-adapter": "^1.1.3",
"cordova-plugin-customurlscheme": "github:bytelabsco/Custom-URL-scheme",
"cordova-plugin-proguard": "^2.2.0",
"cordova-plugin-secure-storage": "github:satoshipay/cordova-plugin-secure-storage",
"dotenv-cli": "^2.0.0",
"json": "^10.0.0",
Expand All @@ -66,9 +68,10 @@
"remove:ios": "cordova platform rm ios",
"prebuild:android": "rm -rf ../dist/ && NODE_ENV=production PLATFORM=android ../node_modules/.bin/parcel build ../src/index.prod-android.njk --out-dir ../dist --public-url=./ --detailed-report --no-source-maps --no-cache && ./scripts/create-config-from-template.sh prod android",
"prebuild:ios": "rm -rf ../dist/ && NODE_ENV=production PLATFORM=ios ../node_modules/.bin/parcel build ../src/index.prod-ios.njk --out-dir ../dist --public-url=./ --detailed-report --no-source-maps --no-cache && ./scripts/create-config-from-template.sh prod ios",
"build:android": "npm run prebuild:android && dotenv -- cordova build android",
"build:android:signed": "npm run prebuild:android && source ./scripts/signing-env-android.sh && dotenv -- cordova build android --release -- --keystore=$KEYSTORE_LOCATION --storePassword=$KEYSTORE_PASSWORD --alias=$SIGNINGKEY_ALIAS --password=$SIGNINGKEY_PASSWORD --packageType=apk",
"build:ios": "npm run prebuild:ios && cordova build ios --buildConfig=build.ios.json",
"build:android": "dotenv -- cordova build android",
"build:android:signed:manual": "source ./scripts/signing-env-android.sh && dotenv -- cordova build android --release -- --keystore=$KEYSTORE_LOCATION --storePassword=$KEYSTORE_PASSWORD --alias=$SIGNINGKEY_ALIAS --password=$SIGNINGKEY_PASSWORD --packageType=$PACKAGE_TYPE",
"build:android:signed:auto": "cordova build android --release -- --keystore=$KEYSTORE_LOCATION --storePassword=$KEYSTORE_PASSWORD --alias=$SIGNINGKEY_ALIAS --password=$SIGNINGKEY_PASSWORD --packageType=$PACKAGE_TYPE",
"build:ios": "cordova build ios --buildConfig=build.ios.json",
"dev:android": "run-p dev:bundle:android dev:cordova:android",
"dev:ios": "run-p dev:bundle:ios dev:cordova:ios",
"dev:bundle:android": "PLATFORM=android NODE_ENV=development ../node_modules/.bin/parcel serve ../src/index.dev.njk -p 1234 --out-dir ../dist",
Expand Down
5 changes: 3 additions & 2 deletions cordova/scripts/create-config-from-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ if [ -f "../config/$TEMPLATE_FILE" ]; then

export HTML_ENTRYPOINT="index.$ENVIRONMENT-$PLATFORM.html"
export PACKAGE_VERSION="$(cat ../../package.json | ../node_modules/.bin/json version)"
export ANDROID_VERSIONCODE="$(date +%s)"
export IOS_BUNDLE_VERSION="$PACKAGE_VERSION.$(date +%s)"
aligned_build_version=$(($(TZ=UTC date +%s)-1708020000))
export ANDROID_VERSIONCODE="$aligned_build_version"
export IOS_BUNDLE_VERSION="$PACKAGE_VERSION.$aligned_build_version"

if [ "$PACKAGE_VERSION" == "" ]; then
echo "Error: Could not read app version." 1>&2
Expand Down
Binary file modified fastlane/metadata/android/en-US/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6d830f6

Please sign in to comment.