From 05e0919a9b1e6dc8a257b5821d8d7dfba22da875 Mon Sep 17 00:00:00 2001 From: Jean Regisser Date: Thu, 30 Jan 2020 10:21:37 +0100 Subject: [PATCH] Android and iOS build on CircleCI (#815) --- .circleci/config.yml | 79 ++++++++++++++++++++++++++++++++ Dockerfile.androidbuild | 14 ------ Makefile | 2 +- cloudbuild-android.yaml | 10 ---- npm-android.sh | 15 ------ package.json | 4 +- scripts/publish-mobile-client.sh | 29 ++++++++++++ 7 files changed, 111 insertions(+), 42 deletions(-) delete mode 100644 Dockerfile.androidbuild delete mode 100644 cloudbuild-android.yaml delete mode 100644 npm-android.sh create mode 100755 scripts/publish-mobile-client.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 12a861ab83ea..4480103aea4b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,6 +62,68 @@ jobs: paths: - geth + android: + docker: + - image: celohq/android-client + user: circleci + working_directory: ~/repos/geth + steps: + - checkout + - run: + name: Compile android client + command: | + set -euo pipefail + # TODO(jeanregisser): Fix docker image so build works directly with circleci user + sudo chown -R circleci:circleci $HOME/.rustup $HOME/.cargo + export PATH=$PATH:$HOME/.cargo/bin + export NDK_VERSION=android-ndk-r19c + export ANDROID_NDK=/opt/android/${NDK_VERSION} + export ANDROID_HOME=/opt/android/sdk + make android + - persist_to_workspace: + root: ~/repos + paths: + - geth/build/bin/geth.aar + + ios: + macos: + xcode: "11.3.1" + working_directory: ~/repos/geth + steps: + - checkout + - run: + name: Setup Go language + command: HOMEBREW_NO_AUTO_UPDATE=1 brew install go@1.11 + - run: + name: Setup Rust language + command: | + set -euo pipefail + curl https://sh.rustup.rs -sSf | sh -s -- -y + export PATH=$PATH:$HOME/.cargo/bin + rustup install 1.37.0 + rustup default 1.37.0 + - run: + name: Compile ios client + command: | + set -euo pipefail + export PATH="/usr/local/opt/go@1.11/bin:$HOME/.cargo/bin:$PATH" + make ios + - persist_to_workspace: + root: ~/repos + paths: + - geth/build/bin/Geth.framework.tgz + - geth/vendor/github.com/celo-org/bls-zexe/bls/target/universal/release/libbls_zexe.a + - geth/vendor/github.com/celo-org/bls-zexe/bls/target/universal/release/libbls_snark.a + + publish-mobile-client: + docker: + - image: circleci/node:10 + working_directory: ~/repos/geth + steps: + - attach_workspace: + at: ~/repos + - run: ./scripts/publish-mobile-client.sh ${CIRCLE_SHA1} ${NPM_TOKEN_FOR_CELO_CLIENT} + end-to-end-monorepo-checkout: <<: *end-to-end-defaults working_directory: ~/repos/celo-monorepo @@ -168,6 +230,23 @@ workflows: jobs: - bls-zexe - lint + - android + - ios + - publish-mobile-client: + requires: + - android + - ios + # Makes sure tests are all green before publishing + # Though these are not using the mobile built binaries + # they should be a good indicator + - unit-tests + - end-to-end-transfer-test + - end-to-end-sync-test + - end-to-end-blockchain-parameters-test + - end-to-end-geth-governance-test + filters: + branches: + only: master - end-to-end-monorepo-checkout - unit-tests: requires: diff --git a/Dockerfile.androidbuild b/Dockerfile.androidbuild deleted file mode 100644 index 284d53f4f0dd..000000000000 --- a/Dockerfile.androidbuild +++ /dev/null @@ -1,14 +0,0 @@ -# This builds the android version and pushes it to NPM -FROM celohq/android-client - -ARG commit_sha -ARG NPM_TOKEN - -ENV NDK_VERSION=android-ndk-r19c -ENV ANDROID_NDK=/opt/android/${NDK_VERSION} -ENV ANDROID_HOME=/opt/android/sdk - -COPY . /go-ethereum -WORKDIR /go-ethereum - -RUN bash npm-android.sh $commit_sha $NPM_TOKEN diff --git a/Makefile b/Makefile index e4d7d1de2e64..fa2a75f09cd2 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ android: bls-zexe-android ios: bls-zexe-ios build/env.sh go run build/ci.go xcode --local - pushd "$(GOBIN)"; rm -rf Geth.framework.zip; zip -r9y Geth.framework.zip Geth.framework; popd + pushd "$(GOBIN)"; rm -rf Geth.framework.tgz; tar -czvf Geth.framework.tgz Geth.framework; popd @echo "Done building." @echo "Import \"$(GOBIN)/Geth.framework\" to use the library." diff --git a/cloudbuild-android.yaml b/cloudbuild-android.yaml deleted file mode 100644 index 98412ad368e5..000000000000 --- a/cloudbuild-android.yaml +++ /dev/null @@ -1,10 +0,0 @@ -secrets: -- kmsKeyName: projects/celo-testnet/locations/global/keyRings/celo-keyring/cryptoKeys/github-key - secretEnv: - NPM_TOKEN: CiQAW8JnkhGXb5SuIgpWBeDft/uw+35thzUbMAIQvM+gVl2Di5wSTgAZggEugqlAKFxv9XiJQspzW3f+pLeoQ2zFyA/bmXP8vUv0XB1HjKjfD8s273teZfF7202VnDFgP3I7Og/NAGLf29MBL5VW1mwPWahoaQ== -steps: -- name: 'gcr.io/cloud-builders/docker' - args: [ 'build', '--build-arg', 'commit_sha=$SHORT_SHA', '--build-arg', 'NPM_TOKEN', '-f', 'Dockerfile.androidbuild', '.' ] - secretEnv: ['NPM_TOKEN'] - waitFor: ["-"] -timeout: 2700s diff --git a/npm-android.sh b/npm-android.sh deleted file mode 100644 index 7312c9083262..000000000000 --- a/npm-android.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -make android || exit 1 - -rm README.md - -VERSION=$(npm show @celo/client version) -a=( ${VERSION//./ } ) -((a[2]++)) - -echo //registry.npmjs.org/:_authToken=$2 > ~/.npmrc -NEW_VERSION="${a[0]}.${a[1]}.${a[2]}" -npm -f --no-git-tag-version version $NEW_VERSION -PACKAGE=$(npm pack) -npm publish $PACKAGE --tag $1 --access public -npm dist-tag add @celo/client@$NEW_VERSION latest diff --git a/package.json b/package.json index 7a173c543e91..4ac60ce8be66 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,12 @@ "license": "LGPL-3.0", "files": [ "build/bin/geth.aar", - "build/bin/Geth.framework.zip", + "build/bin/Geth.framework.tgz", "CeloBlockchain.podspec", "crypto/bls/bls-zexe/bls/target/universal/release/libbls_zexe.a", "crypto/bls/bls-zexe/bls/target/universal/release/libbls_snark.a" ], "scripts": { - "postinstall": "rm -rf build/bin/Geth.framework && unzip build/bin/Geth.framework.zip -d build/bin && touch Empty.m && ln -sf build/bin/Geth.framework/Versions/A/Geth libGeth.a" + "postinstall": "rm -rf build/bin/Geth.framework && tar -xvf build/bin/Geth.framework.tgz -C build/bin && touch Empty.m && ln -sf build/bin/Geth.framework/Versions/A/Geth libGeth.a" } } diff --git a/scripts/publish-mobile-client.sh b/scripts/publish-mobile-client.sh new file mode 100755 index 000000000000..10299433f2c3 --- /dev/null +++ b/scripts/publish-mobile-client.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# +# Usage: ./scripts/publish-mobile-client.sh $COMMIT_SHA $NPM_TOKEN + +set -euo pipefail + +# Process args +commit_sha_short="${1:0:7}" +npm_token="${2:-}" + +package_name="$(node -p "require('./package.json').name")" + +version=$(npm show "$package_name" version) +# Bump minor version +a=( ${version//./ } ) +((a[2]++)) +new_version="${a[0]}.${a[1]}.${a[2]}" + +# Add npm token if provided +if [ -n "$npm_token" ]; then + echo "//registry.npmjs.org/:_authToken=$npm_token" > ~/.npmrc +fi + +# TODO: Create an appropriate README for NPM +rm README.md + +npm -f --no-git-tag-version version "$new_version" +npm publish --tag "$commit_sha_short" --access public +npm dist-tag add "$package_name@$new_version" latest