From 1b1bf6b261f18ceca060426331197585b856690d Mon Sep 17 00:00:00 2001 From: Alya Sirko Date: Fri, 9 Sep 2022 20:40:05 +0300 Subject: [PATCH] new podman-based pipeline --- .drone.yml | 1 + ci.sh | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.drone.yml b/.drone.yml index f694c546..872bca02 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,6 +22,7 @@ steps: - name: Prepare commands: - ln -s /var/lib/drone-runner-exec/.local $HOME/.local + - podman volume exists src || podman volume rm -f src - podman volume exists src || podman volume create src - git archive --format=tar HEAD | podman volume import src - diff --git a/ci.sh b/ci.sh index a44c64c1..3ca01bda 100755 --- a/ci.sh +++ b/ci.sh @@ -2,6 +2,11 @@ set -o errexit -o pipefail -o noclobber -o nounset -x CONTAINER_IMAGE="localhost/flutter-build-env" +APP_NAME="pro.kherel.selfprivacy" +APP_VERSION_FULL="$(yq '.version' pubspec.yaml)" +APP_SEMVER="$(printf $APP_VERSION_FULL | cut -d '+' -f1)" +APP_BUILD_ID="$(printf $APP_VERSION_FULL | cut -d '+' -f2)" + OPTS=$(getopt -o "" --long "build-linux,build-apk,sign-apk-standalone,sign-apk-fdroid,package-linux-appimage,package-linux-flatpak,package-linux-archive" -- "$@") eval set -- "$OPTS" @@ -10,7 +15,7 @@ usage () { } podman_offline () { - podman run --rm -v "src:/var/lib/builder/src:U" -v "/var/lib/drone-runner-exec/fdroid:/var/lib/builder/repo:U" -v "/var/lib/drone-runner-exec/fdroid-keystore:/var/lib/builder/repo/fdroid-keystore:U" -v "/var/lib/drone-runner-exec/standalone-keystore:/var/lib/builder/repo/standalone-keystore:U" --env FDROID_KEYSTORE_PASS="$FDROID_KEYSTORE_PASS" --env STANDALONE_KEYSTORE_PASS="$STANDALONE_KEYSTORE_PASS" --network=none --workdir $1 "$CONTAINER_IMAGE" $2 + podman run --rm -v "src:/var/lib/builder/src:U" -v "/var/lib/drone-runner-exec/fdroid:/var/lib/builder/fdroid:U" -v "/var/lib/drone-runner-exec/fdroid-keystore:/var/lib/builder/fdroid/fdroid-keystore:U" -v "/var/lib/drone-runner-exec/standalone-keystore:/var/lib/builder/fdroid/standalone-keystore:U" --env FDROID_KEYSTORE_PASS="$FDROID_KEYSTORE_PASS" --env STANDALONE_KEYSTORE_PASS="$STANDALONE_KEYSTORE_PASS" --network=none --workdir $1 "$CONTAINER_IMAGE" $2 } podman_online () { @@ -19,22 +24,23 @@ podman_online () { build_linux () { podman_offline "/var/lib/builder/src" "flutter pub get --offline" - podman_offline "/var/lib/builder/src" "flutter build linux -v" + podman_offline "/var/lib/builder/src" "flutter build linux" } build_apk () { podman_offline "/var/lib/builder/src" "flutter pub get --offline" - podman_offline "/var/lib/builder/src" "flutter build apk -v" + podman_offline "/var/lib/builder/src" "flutter build apk" } sign_apk_standalone () { - podman_offline "/var/lib/builder/repo" "cp /var/lib/builder/src/build/app/outputs/flutter-apk/app-release.apk ." - podman_offline "/var/lib/builder/repo" "zipalign -f -v 4 app-release.apk standalone_app-release.apk" - podman_offline "/var/lib/builder/repo" "apksigner sign --ks /var/lib/builder/repo/standalone-keystore --ks-key-alias standalone --ks-pass env:STANDALONE_KEYSTORE_PASS standalone_app-release.apk" + podman_offline "/var/lib/builder/fdroid" "zipalign -f -v 4 ../src/build/app/outputs/flutter-apk/app-release.apk standalone_$APP_NAME-$APP_SEMVER.apk" + podman_offline "/var/lib/builder/fdroid" "apksigner sign --ks standalone-keystore --ks-key-alias standalone --ks-pass env:STANDALONE_KEYSTORE_PASS standalone_$APP_NAME-$APP_SEMVER.apk" } sign_apk_fdroid () { - podman_offline "/var/lib/builder/repo" "cp /var/lib/builder/src/build/app/outputs/flutter-apk/app-release.apk unsigned/" + podman_offline "/var/lib/builder/fdroid" "if [[ ! -f repo/$APP_NAME_$APP_BUILD_ID.apk ]]; then cp ../src/build/app/outputs/flutter-apk/app-release.apk unsigned; fi" + podman_offline "/var/lib/builder/fdroid" "fdroid publish" + podman_offline "/var/lib/builder/fdroid" "fdroid update" } package_linux_appimage () { @@ -43,11 +49,11 @@ package_linux_appimage () { package_linux_flatpak () { podman_online "/var/lib/builder/src" "flatpak-builder --disable-rofiles-fuse --force-clean --repo=flatpak-repo flatpak-build flatpak.yml" - podman_online "/var/lib/builder/src" "flatpak build-bundle flatpak-repo selfprivacy.flatpak pro.kherel.selfprivacy" + podman_online "/var/lib/builder/src" "flatpak build-bundle flatpak-repo $APP_NAME-$APP_SEMVER.flatpak pro.kherel.selfprivacy" } package_linux_archive () { - podman_online "/var/lib/builder/src" "tar -C build/linux/x64/release/bundle -vacf selfprivacy.tar.zstd ." + podman_online "/var/lib/builder/src" "tar -C build/linux/x64/release/bundle -vacf $APP_NAME-$APP_SEMVER.tar.zstd ." } while true; do