Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Rework Gitlab #782

Merged
merged 13 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 15 additions & 46 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,26 @@
stages:
- test
- build
variables:
GIT_DEPTH: "3"
SIMPLECOV: "true"
RUST_BACKTRACE: "1"
RUSTFLAGS: ""
CARGOFLAGS: ""
cache:
untracked: true

variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 100

default:
cache: {}

android-test:
stage: test
image: parity/android-sdk
only:
- master
- /^[0-9]+$/
# testing Android build on this branch
- tbaut-without-version
script:
- curl -sL https://deb.nodesource.com/setup_8.x | bash -
- apt-get install -y nodejs
- npm install -g yarn
- npm install
- npm run test
android-build-release:
stage: build
image: paritytech/parity-signer
tags:
- linux-docker

android-build:
stage: build
image: parity/android-sdk
only:
- beta
- tags
- stable
- triggers
- master
script:
- curl -sL https://deb.nodesource.com/setup_8.x | bash -
- apt-get install -y nodejs
- echo "ndk.dir=/usr/local/android-ndk-r16b" > android/local.properties
- echo "sdk.dir=/opt/android-sdk" >> android/local.properties
- npm install -g yarn
- bash ./setup_linux.sh
- bash ./gen_key.sh
- cd android && ./gradlew assembleRelease
- pwd
- ls
tags:
- linux-docker
- /^[0-9]+$/
- mp-gitlab-build
artifacts:
paths:
- ./android/app/build/outputs/apk/release/app-release.apk

- signer-app-release-signed.apk
script: |
cat "$KEYSTORE_DATA" | base64 -d > /tmp/gitlab-ci.keystore
wc /tmp/gitlab-ci.keystore
./scripts/build-release.sh /tmp/gitlab-ci.keystore "$KEYSTORE_ALIAS" "$KEYSTORE_PASS"
26 changes: 16 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
FROM parity/parity-android
FROM rust
MAINTAINER Parity Technologies <admin@parity.io>

WORKDIR /build

RUN apt-get install -y nodejs
RUN mkdir -p /opt/android-sdk && cd /opt/android-sdk && wget -q https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && unzip -q *tools*linux*.zip && rm *tools*linux*.zip
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN apt-get update
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
RUN apt-get install -y oracle-java8-installer
RUN yes | /opt/android-sdk/tools/bin/sdkmanager --licenses || true
RUN su -c 'curl -sL https://deb.nodesource.com/setup_14.x | bash -'
RUN apt-get update -y; apt-get install -y openjdk-11-jdk-headless wget curl unzip zipalign nodejs
RUN curl https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip > /tmp/cli-tools.zip
RUN unzip /tmp/cli-tools.zip -d /opt
RUN yes | ANDROID_SDK_ROOT=/opt/cmdline-tools/bin/ /opt/cmdline-tools/bin/sdkmanager --licenses --sdk_root=/opt/cmdline-tools/bin/
RUN npm install -g react-native-cli yarn
RUN curl https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip > /tmp/ndk.zip
RUN unzip /tmp/ndk.zip -d /opt
ENV NDK_HOME /opt/android-ndk-r21e/
ENV ANDROID_SDK_ROOT /opt/cmdline-tools/bin/

WORKDIR /tmp/scripts
COPY scripts /tmp/scripts/
RUN bash /tmp/scripts/init.sh
WORKDIR /build

# cleanup
RUN apt-get autoremove -y
Expand Down
18 changes: 18 additions & 0 deletions scripts/build-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

keystore="$(readlink -f "$1")"
keyalias=$2
keypass_arg="${3:+-storepass $3}"

set -e
echo "[+] Building rust components"
"$(dirname "${0}")"/build.sh android
echo "[+] Moving to android directory to build app..."
yarn install
pushd "$(dirname "${0}")"/../android
echo "[+] Running Gradle"
./gradlew assembleRelease
echo "[+] Build complete! Signing bundle"
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore "$keystore" $keypass_arg app/build/outputs/apk/release/app-release-unsigned.apk "$keyalias"
zipalign -p 4 app/build/outputs/apk/release/app-release-unsigned.apk ../signer-app-release-signed.apk
popd
9 changes: 5 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
set -e

source ./scripts/variables.sh
. "$(dirname "${0}")/variables.sh"

cd ./rust/signer
cd "$(dirname "${0}")/../rust/signer"

if [ $1 == "android" ]
if [ "$1" == "android" ]
then

# Build android
Expand Down Expand Up @@ -55,7 +56,7 @@ if [ $1 == "android" ]

fi

if [ $1 == "ios" ]
if [ "$1" == "ios" ]
then

# Build iOS
Expand Down
2 changes: 1 addition & 1 deletion scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

source ./scripts/variables.sh
source ./variables.sh

cargo install cargo-lipo

Expand Down