commit fb45bb2ad93fbb15882c4d16cee542cd78bb5a69 parent 868f47ffab3dd38d63df7ec73ca21f43cae74bd3 Author: Iván Ávalos <avalos@disroot.org> Date: Tue, 18 Jun 2024 16:42:14 -0600 Switch nightly deployment to Buildbot CI Diffstat:
17 files changed, 186 insertions(+), 103 deletions(-)
diff --git a/cashier/.gitlab-ci.yml b/cashier/.gitlab-ci.yml @@ -13,35 +13,3 @@ cashier_test: paths: - cashier/build/reports/lint-results.html expire_in: 1 week - -cashier_deploy_nightly: - stage: deploy - resource_group: deploy_nightly - only: - refs: - - master - changes: - - cashier/**/* - needs: ["cashier_test"] - script: - # Ensure that key exists - - test -z "$DEBUG_KEYSTORE" && exit 0 - # Rename nightly app - - sed -i - 's,<string name="app_name">.*</string>,<string name="app_name">Cashier Nightly</string>,' - cashier/src/main/res/values*/strings.xml - # Set time-based version code - - export versionCode=$(date '+%s') - - sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," cashier/build.gradle - # Set nightly application ID - - sed -i "s,^\(\s*applicationId\) \"*[a-z\.].*\",\1 \"net.taler.cashier.nightly\"," cashier/build.gradle - # Build the APK - - ./gradlew :cashier:assembleRelease - # Rename APK, so fdroid nightly accepts it (looks for *-debug.apk) - - mv cashier/build/outputs/apk/release/*.apk cashier-debug.apk - # install fdroidserver and dependencies for nightly publishing - - apt update && apt-get -qy install --no-install-recommends fdroidserver openssh-client - # backport fix from https://gitlab.com/fdroid/fdroidserver/-/merge_requests/1078 - - sed -e '/common.apk_strip_v1_signatures/ s/^#*/#/' -i /usr/lib/python3/dist-packages/fdroidserver/nightly.py - - fdroid --version - - CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo" CI_PROJECT_PATH="gnu-taler/fdroid-repo" fdroid nightly -v diff --git a/contrib/ci/Containerfile b/contrib/ci/Containerfile @@ -2,4 +2,7 @@ FROM docker.io/briar/ci-image-android:latest ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64 +ENV FDROID_REPO_KEY /inputs/fdroid-repo-key.txt +ENV NIGHTLY_KEYSTORE /inputs/taler-nightly.keystore + WORKDIR /workdir diff --git a/contrib/ci/ci.sh b/contrib/ci/ci.sh @@ -12,21 +12,27 @@ CONTAINER_BUILD=$((grep CONTAINER_BUILD contrib/ci/jobs/${JOB_NAME}/config.ini | echo "${JOB_CONTAINER}" if [ "${CONTAINER_BUILD}" = "True" ] ; then - "${OCI_RUNTIME}" build \ - --arch "${JOB_ARCH}" \ - -t "${JOB_CONTAINER}" \ - -f contrib/ci/Containerfile . + "${OCI_RUNTIME}" build \ + --arch "${JOB_ARCH}" \ + -t "${JOB_CONTAINER}" \ + -f contrib/ci/Containerfile . fi +mkdir -p "${PWD}/inputs" +mkdir -p "${PWD}/artifacts" + "${OCI_RUNTIME}" run \ - --rm \ - -ti \ - --arch "${JOB_ARCH}" \ - --env CI_COMMIT_REF="$(git rev-parse HEAD)" \ - --volume "${PWD}":/workdir \ - --workdir /workdir \ - "${JOB_CONTAINER}" \ - contrib/ci/jobs/"${JOB_NAME}"/job.sh + --rm \ + -ti \ + --arch "${JOB_ARCH}" \ + --env CI_COMMIT_REF="$(git rev-parse HEAD)" \ + --volume "${PWD}":/workdir \ + --volume "${PWD}/inputs:/inputs:ro" \ + --volume "${PWD}/artifacts:/artifacts" \ + --workdir /workdir \ + --network host \ + "${JOB_CONTAINER}" \ + contrib/ci/jobs/"${JOB_NAME}"/job.sh top_dir=$(dirname "${BASH_SOURCE[0]}") diff --git a/contrib/ci/jobs/1-merchant-lib-test/job.sh b/contrib/ci/jobs/1-wallet-test/job.sh diff --git a/contrib/ci/jobs/2-wallet-test/test.sh b/contrib/ci/jobs/1-wallet-test/test.sh diff --git a/contrib/ci/jobs/2-wallet-deploy/deploy.sh b/contrib/ci/jobs/2-wallet-deploy/deploy.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -exuo pipefail + +ARTIFACT_PATH="/artifacts/taler-android/${CI_COMMIT_REF}/wallet" +APK_PATH="wallet/build/outputs/apk/nightly/release" + +# Ensure that keys exist +[[ ! -f "${FDROID_REPO_KEY}" ]] && exit -1 +[[ ! -f "${NIGHTLY_KEYSTORE}" ]] && exit -1 + +set +x +DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY") +set -x + +# Copy keystore where SDK can find it +cp "${NIGHTLY_KEYSTORE}" /root/.android/debug.keystore + +# Build the APK +#./gradlew :wallet:assembleNightlyRelease + +# Copy the APK to artifacts folder +mkdir -p "${ARTIFACT_PATH}" +cp "${APK_PATH}"/*.apk "${ARTIFACT_PATH}" + +# Rename APK, so fdroid nightly accepts it (looks for *-debug.apk) +cp "${APK_PATH}"/*.apk wallet-debug.apk + +# Install fdroidserver and dependencies +apt update +apt-get -qy install --no-install-recommends \ + python3-pip \ + openssh-client \ + rsync +python3 -m pip install --upgrade pip wheel setuptools +python3 -m pip install git+https://gitlab.com/fdroid/fdroidserver.git +fdroid --version + +# Deploy APK to nightly repository +export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo" +export CI_PROJECT_PATH="gnu-taler/fdroid-repo" +fdroid nightly -v --archive-older 6 diff --git a/contrib/ci/jobs/2-wallet-deploy/job.sh b/contrib/ci/jobs/2-wallet-deploy/job.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -exuo pipefail + +job_dir=$(dirname "${BASH_SOURCE[0]}") + +"${job_dir}"/deploy.sh diff --git a/contrib/ci/jobs/4-cashier-deploy/deploy.sh b/contrib/ci/jobs/4-cashier-deploy/deploy.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -exuo pipefail + +ARTIFACT_PATH="/artifacts/taler-android/${CI_COMMIT_REF}/cashier" +APK_PATH="cashier/build/outputs/apk/release" + +# Ensure that keys exist +[[ ! -f "${FDROID_REPO_KEY}" ]] && exit -1 +[[ ! -f "${NIGHTLY_KEYSTORE}" ]] && exit -1 + +set +x +DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY") +set -x + +# Copy keystore where SDK can find it +cp "${NIGHTLY_KEYSTORE}" /root/.android/debug.keystore + +# Rename nightly app +sed -i 's,<string name="app_name">.*</string>,<string name="app_name">Cashier Nightly</string>,' cashier/src/main/res/values*/strings.xml + +# Set time-based version code +export versionCode=$(date '+%s') +sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," cashier/build.gradle + +# Set nightly application ID +sed -i "s,^\(\s*applicationId\) \"*[a-z\.].*\",\1 \"net.taler.cashier.nightly\"," cashier/build.gradle + +# Build the APK +./gradlew :cashier:assembleRelease + +# Copy the APK to artifacts folder +mkdir -p "${ARTIFACT_PATH}" +cp "${APK_PATH}"/*.apk "${ARTIFACT_PATH}" + +# Rename APK, so fdroid nightly accepts it (looks for *-debug.apk) +cp "${APK_PATH}"/*.apk cashier-debug.apk + +# Install fdroidserver and dependencies +apt update +apt-get -qy install --no-install-recommends \ + python3-pip \ + openssh-client \ + rsync +python3 -m pip install --upgrade pip wheel setuptools +python3 -m pip install git+https://gitlab.com/fdroid/fdroidserver.git +fdroid --version + +# Deploy APK to nightly repository +export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo" +export CI_PROJECT_PATH="gnu-taler/fdroid-repo" +fdroid nightly -v --archive-older 6 diff --git a/contrib/ci/jobs/4-cashier-deploy/job.sh b/contrib/ci/jobs/4-cashier-deploy/job.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -exuo pipefail + +job_dir=$(dirname "${BASH_SOURCE[0]}") + +"${job_dir}"/deploy.sh diff --git a/contrib/ci/jobs/2-wallet-test/job.sh b/contrib/ci/jobs/5-merchant-lib-test/job.sh diff --git a/contrib/ci/jobs/1-merchant-lib-test/test.sh b/contrib/ci/jobs/5-merchant-lib-test/test.sh diff --git a/contrib/ci/jobs/4-merchant-terminal-test/job.sh b/contrib/ci/jobs/6-merchant-terminal-test/job.sh diff --git a/contrib/ci/jobs/4-merchant-terminal-test/test.sh b/contrib/ci/jobs/6-merchant-terminal-test/test.sh diff --git a/contrib/ci/jobs/7-merchant-terminal-deploy/deploy.sh b/contrib/ci/jobs/7-merchant-terminal-deploy/deploy.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -exuo pipefail + +ARTIFACT_PATH="/artifacts/taler-android/${CI_COMMIT_REF}/merchant-terminal" +APK_PATH="merchant-terminal/build/outputs/apk/release" + +# Ensure that keys exist +[[ ! -f "${FDROID_REPO_KEY}" ]] && exit -1 +[[ ! -f "${NIGHTLY_KEYSTORE}" ]] && exit -1 + +set +x +DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY") +set -x + +# Copy keystore where SDK can find it +cp "${NIGHTLY_KEYSTORE}" /root/.android/debug.keystore + +# Rename nightly app +sed -i 's,<string name="app_name">.*</string>,<string name="app_name">Merchant PoS Nightly</string>,' merchant-terminal/src/main/res/values*/strings.xml + +# Set time-based version code +export versionCode=$(date '+%s') +sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," merchant-terminal/build.gradle + +# Add commit to version name +export versionName=$(git rev-parse --short=7 HEAD) +sed -i "s,^\(\s*versionName\ *\"[0-9].*\)\",\1 ($versionName)\"," merchant-terminal/build.gradle + +# Set nightly application ID +sed -i "s,^\(\s*applicationId\) \"*[a-z\.].*\",\1 \"net.taler.merchantpos.nightly\"," merchant-terminal/build.gradle + +# Build the APK +./gradlew :merchant-terminal:assembleRelease + +# Copy the APK to artifacts folder +mkdir -p "${ARTIFACT_PATH}" +cp "${APK_PATH}"/*.apk "${ARTIFACT_PATH}" + +# Rename APK, so fdroid nightly accepts it (looks for *-debug.apk) +cp "${APK_PATH}"/*.apk merchant-terminal-debug.apk + +# Install fdroidserver and dependencies +apt update +apt-get -qy install --no-install-recommends \ + python3-pip \ + openssh-client \ + rsync +python3 -m pip install --upgrade pip wheel setuptools +python3 -m pip install git+https://gitlab.com/fdroid/fdroidserver.git +fdroid --version + +# Deploy APK to nightly repository +export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo" +export CI_PROJECT_PATH="gnu-taler/fdroid-repo" +fdroid nightly -v --archive-older 6 diff --git a/contrib/ci/jobs/7-merchant-terminal-deploy/job.sh b/contrib/ci/jobs/7-merchant-terminal-deploy/job.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -exuo pipefail + +job_dir=$(dirname "${BASH_SOURCE[0]}") + +"${job_dir}"/deploy.sh diff --git a/merchant-terminal/.gitlab-ci.yml b/merchant-terminal/.gitlab-ci.yml @@ -12,39 +12,3 @@ merchant_test: paths: - merchant-terminal/build/reports/lint-results.html expire_in: 1 week - -merchant_deploy_nightly: - stage: deploy - resource_group: deploy_nightly - only: - refs: - - master - changes: - - merchant-terminal/**/* - - merchant-lib/**/* - needs: ["merchant_test"] - script: - # Ensure that key exists - - test -z "$DEBUG_KEYSTORE" && exit 0 - # Rename nightly app - - sed -i - 's,<string name="app_name">.*</string>,<string name="app_name">Merchant PoS Nightly</string>,' - merchant-terminal/src/main/res/values*/strings.xml - # Set time-based version code - - export versionCode=$(date '+%s') - - sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," merchant-terminal/build.gradle - # Add commit to version name - - export versionName=$(git rev-parse --short=7 HEAD) - - sed -i "s,^\(\s*versionName\ *\"[0-9].*\)\",\1 ($versionName)\"," merchant-terminal/build.gradle - # Set nightly application ID - - sed -i "s,^\(\s*applicationId\) \"*[a-z\.].*\",\1 \"net.taler.merchantpos.nightly\"," merchant-terminal/build.gradle - # Build the APK - - ./gradlew :merchant-terminal:assembleRelease - # Rename APK, so fdroid nightly accepts it (looks for *-debug.apk) - - mv merchant-terminal/build/outputs/apk/release/*.apk merchant-terminal-debug.apk - # install fdroidserver and dependencies for nightly publishing - - apt update && apt-get -qy install --no-install-recommends fdroidserver openssh-client - # backport fix from https://gitlab.com/fdroid/fdroidserver/-/merge_requests/1078 - - sed -e '/common.apk_strip_v1_signatures/ s/^#*/#/' -i /usr/lib/python3/dist-packages/fdroidserver/nightly.py - - fdroid --version - - CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo" CI_PROJECT_PATH="gnu-taler/fdroid-repo" fdroid nightly -v diff --git a/wallet/.gitlab-ci.yml b/wallet/.gitlab-ci.yml @@ -11,26 +11,3 @@ wallet_test: paths: - wallet/build/reports/lint-results.html expire_in: 1 week - -wallet_deploy_nightly: - stage: deploy - resource_group: deploy_nightly - only: - changes: - - wallet/**/* - refs: - - master - needs: ["wallet_test"] - script: - # Ensure that key exists - - test -z "$DEBUG_KEYSTORE" && exit 0 - # Build the APK - - ./gradlew :wallet:assembleNightlyRelease - # Rename APK, so fdroid nightly accepts it (looks for *-debug.apk) - - mv wallet/build/outputs/apk/nightly/release/*.apk wallet-debug.apk - # install fdroidserver and dependencies for nightly publishing - - apt update && apt-get -qy install --no-install-recommends python3-pip openssh-client rsync - - python3 -m pip install --upgrade pip wheel setuptools - - python3 -m pip install git+https://gitlab.com/fdroid/fdroidserver.git - - fdroid --version - - CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo" CI_PROJECT_PATH="gnu-taler/fdroid-repo" fdroid nightly -v --archive-older 6