diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..ed1db442 --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# reactnativecommunity/react-native-android:13.0 +BUILDER_IMAGE="reactnativecommunity/react-native-android@sha256:4ff9c9f80da57c72284900fcfdbd079183e735684c62d7fafd3df50fdb895453" +CONTAINER_NAME="blixt_builder_container" +BLIXT_PATH=/blixt + +docker run --rm -it --name $CONTAINER_NAME -v `pwd`:$BLIXT_PATH $BUILDER_IMAGE bash -c \ + 'echo -e "\n\n********************************\n*** Building Blixt...\n********************************\n" && \ + cd /blixt ; yarn install --frozen-lockfile && \ + cd /blixt/android ; ./gradlew app:assembleRelease && \ + + echo -e "\n\n********************************\n**** APKs and SHA256 Hashes\n********************************\n" && \ + cd /blixt && \ + for f in android/app/build/outputs/apk/release/*.apk; + do + RENAMED_FILENAME=$(echo $f | sed -e "s/app-/blixt-/" | sed -e "s/-release-unsigned//") + mv $f $RENAMED_FILENAME + sha256sum $RENAMED_FILENAME + done && \ + echo -e "\n" '; diff --git a/fetch_libraries.sh b/fetch_libraries.sh new file mode 100644 index 00000000..7192a3d5 --- /dev/null +++ b/fetch_libraries.sh @@ -0,0 +1,42 @@ +VERSION=v0.18.0-beta-blixt + +ANDROID_FILE=Lndmobile.aar + +ANDROID_SHA256='c0f8e77da00795a370ef2a1c5ba9d413707c52226c33c2ef1e272007c2f30149' + +FILE_PATH=https://github.com/hsjoberg/lnd/releases/download/$VERSION/ + +ANDROID_LINK=$FILE_PATH$ANDROID_FILE + +# test that curl and unzip are installed +if ! command -v curl &> /dev/null +then + echo "curl could not be found. Please install it and run the script again." + exit +fi + +if ! command -v unzip &> /dev/null +then + echo "unzip could not be found. Please install it and run the script again." + exit +fi + +########### +# Android # +########### + +if ! echo "$ANDROID_SHA256 android/lndmobile/$ANDROID_FILE" | sha256sum -c -; then + echo "Android library file missing or checksum failed" >&2 + + # delete old instance of library file + rm android/lndmobile/$ANDROID_FILE + + # download Android LND library file + curl -L $ANDROID_LINK > android/lndmobile/$ANDROID_FILE + + # check checksum + if ! echo "$ANDROID_SHA256 android/lndmobile/$ANDROID_FILE" | sha256sum -c -; then + echo "Android checksum failed" >&2 + exit 1 + fi +fi \ No newline at end of file diff --git a/package.json b/package.json index 8684a96a..ad28af99 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "gen-proto": "pbjs -t static-module -w es6 --force-long -o proto/lightning.js proto/*.proto proto/*/*.proto && pbts -o proto/lightning.d.ts proto/lightning.js", "build-tor-lib": "./build-tor", "prepare-release": "yarn install && cd ios && pod install && cd ../macos && pod install", - "android:build": "yarn install && ./build/fetch_libraries.sh && cd android && ./gradlew assembleChainmainnetNormalRelease", + "android:build": "yarn install && ./fetch_libraries.sh && cd android && ./gradlew assembleChainmainnetNormalRelease", "android:clean": "cd android && ./gradlew clean", "android:regtest-debug": "react-native run-android --mode chainregtestNormalDebug --appIdSuffix regtest.debug --main-activity MainActivity", "android:regtest": "react-native run-android --mode chainregtestNormalRelease --appIdSuffix regtest",