commit f06cecb04d89489957f8c16580b4840dd9910867
parent 5486665f4330c53c6162189917db1dbb8fff3574
Author: Iván Ávalos <avalos@disroot.org>
Date: Thu, 27 Jun 2024 19:40:49 -0600
[ci] Setup APK deployment to taler.net/files
Diffstat:
4 files changed, 233 insertions(+), 141 deletions(-)
diff --git a/contrib/ci/Containerfile b/contrib/ci/Containerfile
@@ -2,7 +2,22 @@ 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
+# Deployment to F-droid nightly
+ENV FDROID_REPO_KEY /inputs/fdroid-repo-key.txt
+ENV NIGHTLY_KEYSTORE_PATH /inputs/taler-nightly.keystore
+ENV NIGHTLY_KEYSTORE_ALIAS androiddebugkey
+ENV NIGHTLY_KEYSTORE_PASS android
+
+# Deployment to taler.net/files
+ENV SCP_SSH_KEY /inputs/wallet.taler.net
+ENV SCP_DEST avalos@gv.taler.net:/var/www/files
+
+# Install fdroidserver and other tools
+RUN apt update && apt-get -qy install --no-install-recommends \
+ python3-pip \
+ openssh-client \
+ rsync
+RUN python3 -m pip install --upgrade pip wheel setuptools
+RUN python3 -m pip install git+https://gitlab.com/fdroid/fdroidserver.git
WORKDIR /workdir
diff --git a/contrib/ci/jobs/1-wallet-deploy/deploy.sh b/contrib/ci/jobs/1-wallet-deploy/deploy.sh
@@ -2,45 +2,69 @@
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
-
-# Test and build the APK
-./gradlew :wallet:check :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 DEBUG_KEYSTORE
-export CI=
-export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo"
-export CI_PROJECT_PATH="gnu-taler/fdroid-repo"
-export GITLAB_USER_NAME="$(git log -1 --pretty=format:'%an')"
-export GITLAB_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
-
-fdroid nightly -v --archive-older 6
+APK_PATH="wallet/build/outputs/apk/nightly/release/wallet-nightly-release-unsigned.apk"
+LINT_PATH="wallet/build/reports/lint-results-fdroidDebug.html"
+
+
+function build_apk {
+ [[ ! -f "${NIGHTLY_KEYSTORE_PATH}" ]] && return 1
+ echo "Building APK ..."
+
+ # Test and build the APK
+ ./gradlew :wallet:check :wallet:assembleNightlyRelease
+
+ # Sign the APK
+ jarsigner -keystore "${NIGHTLY_KEYSTORE_PATH}" \
+ -storepass "${NIGHTLY_KEYSTORE_PASS}" \
+ "${APK_PATH}" "${NIGHTLY_KEYSTORE_ALIAS}"
+
+ # Copy the APK and lint report to artifacts folder
+ mkdir -p "${ARTIFACT_PATH}"
+ cp "${APK_PATH}" "${ARTIFACT_PATH}"/wallet-nightly-debug.apk
+ cp "${LINT_PATH}" "${ARTIFACT_PATH}"
+}
+
+
+function deploy_apk {
+ [[ ! -f "${SCP_SSH_KEY}" ]] && return 0
+ echo "Deploying APK to taler.net/files ..."
+
+ # Deploy APK to taler.net/files/wallet
+ scp -i "${SCP_SSH_KEY}" \
+ -o StrictHostKeyChecking=no \
+ -o UserKnownHostsFile=/dev/null \
+ "${APK_PATH}" \
+ "${SCP_DEST}"/wallet/wallet-nightly-debug-$(date -u +%s).apk
+}
+
+
+function deploy_fdroid {
+ [[ ! -f "${FDROID_REPO_KEY}" ]] && return 0
+ echo "Deploying APK to F-droid nightly ..."
+
+ # Copy keystore where SDK can find it
+ cp "${NIGHTLY_KEYSTORE_PATH}" /root/.android/debug.keystore
+
+ # Rename APK, so fdroid nightly accepts it (looks for *-debug.apk)
+ cp "${APK_PATH}"/*.apk wallet-debug.apk
+
+ fdroid --version
+
+ set +x
+ export DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY")
+ set -x
+
+ # Deploy APK to nightly repository
+ export CI=
+ export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo"
+ export CI_PROJECT_PATH="gnu-taler/fdroid-repo"
+ export GITLAB_USER_NAME="$(git log -1 --pretty=format:'%an')"
+ export GITLAB_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
+
+ fdroid nightly -v --archive-older 6
+}
+
+
+build_apk
+deploy_apk
+# deploy_fdroid
diff --git a/contrib/ci/jobs/2-cashier-deploy/deploy.sh b/contrib/ci/jobs/2-cashier-deploy/deploy.sh
@@ -2,54 +2,79 @@
set -exuo pipefail
ARTIFACT_PATH="/artifacts/taler-android/${CI_COMMIT_REF}/cashier"
-APK_PATH="cashier/build/outputs/apk/release"
+APK_PATH="cashier/build/outputs/apk/release/cashier-release-unsigned.apk"
+LINT_PATH="cashier/build/reports/lint-results-debug.html"
-# Ensure that keys exist
-[[ ! -f "${FDROID_REPO_KEY}" ]] && exit -1
-[[ ! -f "${NIGHTLY_KEYSTORE}" ]] && exit -1
+export versionCode=$(date '+%s')
-set +x
-DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY")
-set -x
+function build_apk {
+ [[ ! -f "${NIGHTLY_KEYSTORE_PATH}" ]] && return 1
+ echo "Building APK ..."
-# 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
-# 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
+ sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," cashier/build.gradle
-# 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
-
-# Test and build the APK
-./gradlew :cashier:test :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 DEBUG_KEYSTORE
-export CI=
-export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo"
-export CI_PROJECT_PATH="gnu-taler/fdroid-repo"
-export GITLAB_USER_NAME="$(git log -1 --pretty=format:'%an')"
-export GITLAB_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
-fdroid nightly -v --archive-older 6
+ # Set nightly application ID
+ sed -i "s,^\(\s*applicationId\) \"*[a-z\.].*\",\1 \"net.taler.cashier.nightly\"," cashier/build.gradle
+
+ # Test and build the APK
+ ./gradlew :cashier:check :cashier:assembleRelease
+
+ # Sign the APK
+ jarsigner -keystore "${NIGHTLY_KEYSTORE_PATH}" \
+ -storepass "${NIGHTLY_KEYSTORE_PASS}" \
+ "${APK_PATH}" "${NIGHTLY_KEYSTORE_ALIAS}"
+
+ # Copy the APK and lint report to artifacts folder
+ mkdir -p "${ARTIFACT_PATH}"
+ cp "${APK_PATH}" "${ARTIFACT_PATH}"/cashier-debug.apk
+ cp "${LINT_PATH}" "${ARTIFACT_PATH}"
+}
+
+
+function deploy_apk {
+ [[ ! -f "${SCP_SSH_KEY}" ]] && return 0
+ echo "Deploying APK to taler.net/files ..."
+
+ # Deploy APK to taler.net/files/cashier
+ scp -i "${SCP_SSH_KEY}" \
+ -o StrictHostKeyChecking=no \
+ -o UserKnownHostsFile=/dev/null \
+ "${APK_PATH}" \
+ "${SCP_DEST}"/cashier/cashier-nightly-debug-${versionCode}.apk
+}
+
+
+function deploy_fdroid {
+ [[ ! -f "${FDROID_REPO_KEY}" ]] && return 0
+ echo "Deploying APK to F-droid nightly ..."
+
+ # Copy keystore where SDK can find it
+ cp "${NIGHTLY_KEYSTORE}" /root/.android/debug.keystore
+
+ # Rename APK, so fdroid nightly accepts it (looks for *-debug.apk)
+ cp "${APK_PATH}"/*.apk cashier-debug.apk
+
+ fdroid --version
+
+ set +x
+ export DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY")
+ set -x
+
+ # Deploy APK to nightly repository
+ export CI=
+ export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo"
+ export CI_PROJECT_PATH="gnu-taler/fdroid-repo"
+ export GITLAB_USER_NAME="$(git log -1 --pretty=format:'%an')"
+ export GITLAB_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
+
+ fdroid nightly -v --archive-older 6
+}
+
+
+build_apk
+deploy_apk
+# deploy_fdroid
diff --git a/contrib/ci/jobs/3-merchant-terminal-deploy/deploy.sh b/contrib/ci/jobs/3-merchant-terminal-deploy/deploy.sh
@@ -1,59 +1,87 @@
#!/bin/bash
set -exuo pipefail
-ARTIFACT_PATH="/artifacts/taler-android/${CI_COMMIT_REF}/merchant-terminal"
-APK_PATH="merchant-terminal/build/outputs/apk/release"
+ARTIFACT_PATH_LIB="/artifacts/taler-android/${CI_COMMIT_REF}/merchant-lib"
+ARTIFACT_PATH_POS="/artifacts/taler-android/${CI_COMMIT_REF}/merchant-terminal"
+APK_PATH="merchant-terminal/build/outputs/apk/release/merchant-terminal-release-unsigned.apk"
+LINT_PATH_LIB="merchant-lib/build/reports/lint-results-debug.html"
+LINT_PATH_POS="merchant-terminal/build/reports/lint-results-debug.html"
-# Ensure that keys exist
-[[ ! -f "${FDROID_REPO_KEY}" ]] && exit -1
-[[ ! -f "${NIGHTLY_KEYSTORE}" ]] && exit -1
+export versionCode=$(date '+%s')
-set +x
-DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY")
-set -x
+function build_apk {
+ [[ ! -f "${NIGHTLY_KEYSTORE_PATH}" ]] && return 1
+ echo "Building APK ..."
-# 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
-# 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
+ sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," merchant-terminal/build.gradle
-# 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
-
-# Test and build the APK
-./gradlew :merchant-lib:check :merchant-terminal:check :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 DEBUG_KEYSTORE
-export CI=
-export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo"
-export CI_PROJECT_PATH="gnu-taler/fdroid-repo"
-export GITLAB_USER_NAME="$(git log -1 --pretty=format:'%an')"
-export GITLAB_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
-fdroid nightly -v --archive-older 6
+ # 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
+
+ # Test and build the APK
+ ./gradlew :merchant-lib:check :merchant-terminal:check :merchant-terminal:assembleRelease
+
+ # Sign the APK
+ jarsigner -keystore "${NIGHTLY_KEYSTORE_PATH}" \
+ -storepass "${NIGHTLY_KEYSTORE_PASS}" \
+ "${APK_PATH}" "${NIGHTLY_KEYSTORE_ALIAS}"
+
+ # Copy the APK and lint reports to artifacts folder
+ mkdir -p "${ARTIFACT_PATH_POS}"
+ mkdir -p "${ARTIFACT_PATH_LIB}"
+ cp "${APK_PATH}" "${ARTIFACT_PATH_POS}"/merchant-terminal-debug.apk
+ cp "${LINT_PATH_LIB}" "${ARTIFACT_PATH_LIB}"
+ cp "${LINT_PATH_POS}" "${ARTIFACT_PATH_POS}"
+}
+
+
+function deploy_apk {
+ [[ ! -f "${SCP_SSH_KEY}" ]] && return 0
+ echo "Deploying APK to taler.net/files ..."
+
+ # Deploy APK to taler.net/files/pos
+ scp -i "${SCP_SSH_KEY}" \
+ -o StrictHostKeyChecking=no \
+ -o UserKnownHostsFile=/dev/null \
+ "${APK_PATH}" \
+ "${SCP_DEST}"/merchant-terminal/merchant-terminal-nightly-debug-${versionCode}.apk
+}
+
+
+function deploy_fdroid {
+ [[ ! -f "${FDROID_REPO_KEY}" ]] && return 0
+ echo "Deploying APK to F-droid nightly ..."
+
+ # Copy keystore where SDK can find it
+ cp "${NIGHTLY_KEYSTORE_PATH}" /root/.android/debug.keystore
+
+ # Rename APK, so fdroid nightly accepts it (looks for *-debug.apk)
+ cp "${APK_PATH}"/*.apk merchant-terminal-debug.apk
+
+ fdroid --version
+
+ set +x
+ export DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY")
+ set -x
+
+ # Deploy APK to nightly repository
+ export DEBUG_KEYSTORE
+ export CI=
+ export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo"
+ export CI_PROJECT_PATH="gnu-taler/fdroid-repo"
+ export GITLAB_USER_NAME="$(git log -1 --pretty=format:'%an')"
+ export GITLAB_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
+ fdroid nightly -v --archive-older 6
+}
+
+build_apk
+deploy_apk
+# deploy_fdroid