Skip to content

Commit

Permalink
Reproducible builds (#1055)
Browse files Browse the repository at this point in the history
* Simplre reproducible builds

* clone the branch you're reproducing

* fix branch/tag argument taking + use master as default

* be able to execute build.sh more than once

* Simplifiying process

* Updating rn-nodeify to 10.3.0 to avoid issue

* Deleting compile and Dockerfile as they're not used anymore

* Updated simplified build script and README file with instructions to build

* Simplify / beautify build script

* Commenting out the singning process for release in build.gradle

* Build and sign every apk

* Cut apk location up to current location for easy location of files

* Remove signing code

* Delete unused variables

* Updated instructions

* README: update reproducible instructions

* build.sh: lock in Docker image version

reactnativecommunity/react-native-android:5.4

Co-authored-by: Evan Kaloudis <[email protected]>
  • Loading branch information
ktecho and kaloudis authored Aug 24, 2022
1 parent 37d6f6f commit 924f424
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ Zeus is proud to be integrated on the following platforms:
3. `cd ios && pod install`
4. open `ios/zeus.xcworkspace` in Xcode and hit Run. NOTE: if you're using an M1 mac, you may need to right click Xcode > get info > check `Open using Rosetta` before opening `zeus.xcworkspace`.

## Reproducible builds

Reproducible builds are available for Android only right now. You'll need Docker installed to be able to build the app this way:

1. Clone Zeus git for the branch/tag that you want to build. For example: `git clone --depth 1 --branch v0.6.6 https://github.com/ZeusLN/zeus.git`
You can also remove the `--branch v0.6.6` parameter to build APKs for `master`.
2. Change to the zeus directory: `cd zeus`
3. Execute the build script: `./build.sh`
4. If everything goes well, the script will print a list of all the generated APK files and MD5 for each one of them: armv7, armv8, x86, x86_64, universal. The equivalent to the one provided in the web page is the one ending in 'universal'. You can compare MD5s with the ones provided on the [GitHub releases page](https://github.com/ZeusLN/zeus/releases)
5. Download the oficial apk from [GitHub releases page](https://github.com/ZeusLN/zeus/releases) or from the [Zeus homepage](https://zeusln.app/): `wget https://zeusln.app/zeus-v0.6.6.apk`
6. Compare both APKs with a suitable utility like `diffoscope`, `apksigcopier` or by running `diff --brief --recursive ./unpacked_oficial_apk ./unpacked_built_apk`. You should only get differences for the certificates used to sign the official APK

If you want to install the APK built this way onto your own smartphone, you'll need to sign it yourself (see next section). Note that the first time you install a build made using this procedure, you'll need to uninstall your current version of Zeus and then install the one built here because certificates will not match. You'll lose your connection details and you'll need to reconfigure Zeus again to connect to your nodes.

### Signing APKs

1. Install signing utilities: `apt-get install -y apksigner`
2. Create your certificate, if you haven't done so already. If you already have the certificate from previous builds, it's advised that you use the same one so you are able to upgrade from one APK to the next one without reinstalling first: `keytool -genkeypair -alias zeus -keystore zeus.pfx -v -storetype PKCS12 -keyalg RSA -keysize 2048 -storepass your_keystore_password -keypass your_key_password -validity 10000 -dname "cn=Unknown, ou=Unknown, o=Unknown, c=Unknown"`
3. Sign the chosen APK file using this command: `java -jar /usr/bin/apksigner sign -v --ks zeus.pfx --ks-key-alias zeus --ks-pass pass:your_keystore_password --key-pass pass:your_key_password zeus-universal.apk`
4. Copy the signed APK to your smartphone and install it by tapping over the file. If you get an error, you'll have to uninstall your currently installed version of Zeus first. Note that you'll lose your connections and you'll need to reconfigure Zeus again to connect to your node.

## Contributing

Please be sure to run `npm run tsc` to check for type errors, `npm run test` to run all tests, and `npm run prettier` to run the prettier
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ android {
shrinkResources true
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
//signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
Expand Down
20 changes: 20 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
BUILDER_IMAGE="reactnativecommunity/react-native-android:5.4"
CONTAINER_NAME="zeus_builder_container"
ZEUS_PATH=/olympus/zeus

docker run --rm --name $CONTAINER_NAME -v `pwd`:$ZEUS_PATH $BUILDER_IMAGE bash -c \
'echo -e "\n\n********************************\n*** Building Zeus...\n********************************\n" && \
cd /olympus/zeus ; yarn install && \
cd /olympus/zeus/android ; ./gradlew assembleRelease && \
echo -e "\n\n********************************\n**** APKs and MD5\n********************************\n" && \
cd /olympus/zeus && \
for f in android/app/build/outputs/apk/release/*.apk;
do
RENAMED_FILENAME=$(echo $f | sed -e "s/app-/zeus-/" | sed -e "s/-release-unsigned//")
mv $f $RENAMED_FILENAME
md5sum $RENAMED_FILENAME
done && \
echo -e "\n" ';

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"metro-react-native-babel-preset": "0.67.0",
"prettier": "2.4.1",
"react-test-renderer": "16.6.3",
"rn-nodeify": "10.2.0",
"rn-nodeify": "10.3.0",
"typescript": "3.7.5"
},
"react-native": {
Expand Down

0 comments on commit 924f424

Please sign in to comment.