From 2a21b6c142830a024dae5ea9998edbd8cd86e38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 5 Oct 2020 14:53:20 +0200 Subject: [PATCH] fix availability of INFURA_TOKEN for Android build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The env variable `INFURA_TOKEN` is used at build time of JS bundle, not the final APK file. We never passed the `secretsFile` to the derivation for JS bundle so it never saw the `INFURA_TOKEN`. Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.android | 2 +- ci/Jenkinsfile.combined | 2 +- ci/Jenkinsfile.ios | 2 +- ci/Jenkinsfile.nix-cache | 2 +- ci/tools/Jenkinsfile.fastlane-clean | 2 +- ci/tools/Jenkinsfile.playstore-meta | 2 +- nix/mobile/android/jsbundle/default.nix | 15 ++++++++++++++- nix/mobile/android/release.nix | 5 ++++- 8 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ci/Jenkinsfile.android b/ci/Jenkinsfile.android index 864aff7dee..500abe89aa 100644 --- a/ci/Jenkinsfile.android +++ b/ci/Jenkinsfile.android @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.3' +library 'status-react-jenkins@v1.2.5' pipeline { agent { label 'linux' } diff --git a/ci/Jenkinsfile.combined b/ci/Jenkinsfile.combined index 4c39383301..59be5cf573 100644 --- a/ci/Jenkinsfile.combined +++ b/ci/Jenkinsfile.combined @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.3' +library 'status-react-jenkins@v1.2.5' pipeline { agent { label 'linux' } diff --git a/ci/Jenkinsfile.ios b/ci/Jenkinsfile.ios index f49e139dc1..8b07607379 100644 --- a/ci/Jenkinsfile.ios +++ b/ci/Jenkinsfile.ios @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.3' +library 'status-react-jenkins@v1.2.5' pipeline { agent { label 'macos-xcode-11.5' } diff --git a/ci/Jenkinsfile.nix-cache b/ci/Jenkinsfile.nix-cache index 8d6dd0162e..62b442bc8e 100644 --- a/ci/Jenkinsfile.nix-cache +++ b/ci/Jenkinsfile.nix-cache @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.3' +library 'status-react-jenkins@v1.2.5' pipeline { agent { label params.AGENT_LABEL } diff --git a/ci/tools/Jenkinsfile.fastlane-clean b/ci/tools/Jenkinsfile.fastlane-clean index 5631a6aaec..7dad559c7e 100644 --- a/ci/tools/Jenkinsfile.fastlane-clean +++ b/ci/tools/Jenkinsfile.fastlane-clean @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.3' +library 'status-react-jenkins@v1.2.5' pipeline { agent { label 'macos' } diff --git a/ci/tools/Jenkinsfile.playstore-meta b/ci/tools/Jenkinsfile.playstore-meta index 6f23437373..a3ca213ceb 100644 --- a/ci/tools/Jenkinsfile.playstore-meta +++ b/ci/tools/Jenkinsfile.playstore-meta @@ -1,4 +1,4 @@ -library 'status-react-jenkins@v1.2.3' +library 'status-react-jenkins@v1.2.5' pipeline { agent { label 'linux' } diff --git a/nix/mobile/android/jsbundle/default.nix b/nix/mobile/android/jsbundle/default.nix index 59d690c992..8aaec0a160 100644 --- a/nix/mobile/android/jsbundle/default.nix +++ b/nix/mobile/android/jsbundle/default.nix @@ -4,6 +4,9 @@ { stdenv, lib, deps, pkgs }: +# Path to the file containing secret environment variables +{ secretsFile ? "" }: + stdenv.mkDerivation { name = "status-react-build-jsbundle-android"; src = @@ -36,8 +39,18 @@ stdenv.mkDerivation { }; }; buildInputs = with pkgs; [ clojure nodejs bash git openjdk]; + phases = [ + "unpackPhase" "secretsPhase" "patchPhase" + "configurePhase" "buildPhase" "installPhase" + ]; + + # For optional INFURA_TOKEN variable + secretsPhase = if (secretsFile != "") then '' + source "${secretsFile}" + '' else '' + echo "No secrets provided!" + ''; - phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase" ]; # Patching shadow-cljs.edn so it uses the local maven repo of dependencies provided by Nix patchPhase = let anchor = ''{:source-paths ["src" "test/cljs"]''; diff --git a/nix/mobile/android/release.nix b/nix/mobile/android/release.nix index 25ea23a9fd..cd8cb48d0e 100644 --- a/nix/mobile/android/release.nix +++ b/nix/mobile/android/release.nix @@ -19,6 +19,9 @@ let toLower optionalString stringLength assertMsg getConfig makeLibraryPath assertEnvVarSet elem; + # Pass secretsFile for INFURA_TOKEN to jsbundle build + builtJsBundle = jsbundle { inherit secretsFile; }; + buildType = getConfig "build-type" "release"; buildNumber = getConfig "build-number" 9999; gradleOpts = getConfig "android.gradle-opts" null; @@ -98,7 +101,7 @@ in stdenv.mkDerivation rec { cp -bf ./${envFileName} ./.env # Copy index.js and app/ input files - cp -ra --no-preserve=ownership ${jsbundle}/* ./ + cp -ra --no-preserve=ownership ${builtJsBundle}/* ./ # Copy android/ directory mkdir -p ./android/build