diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f5af0f7..8c39e833 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,6 +10,24 @@ debian-steps: &debian-steps - run: python3 ci/git-push jobs: + build-flatpak: + machine: + image: ubuntu-1604:201903-01 + environment: + - OCPN_TARGET: flatpak + steps: + - checkout + - restore_cache: + keys: + - fp-v1-{{ checksum "ci/circleci-build-flatpak.sh" }} + - run: ci/circleci-build-flatpak.sh + - save_cache: + key: fp-v1-{{ checksum "ci/circleci-build-flatpak.sh" }} + paths: + - /home/circleci/.local/share/flatpak/repo + - run: cd build; /bin/bash < upload.sh + - run: python3 ci/git-push + build-macos: macos: xcode: "11.0.0" @@ -81,6 +99,9 @@ workflows: version: 2 build_all: jobs: + - build-flatpak: + <<: *std-filters + - build-macos: <<: *std-filters diff --git a/ci/circleci-build-flatpak.sh b/ci/circleci-build-flatpak.sh new file mode 100755 index 00000000..4c9d4dd7 --- /dev/null +++ b/ci/circleci-build-flatpak.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# +# Build the flatpak artifacts. +# +set -e + +MANIFEST=$(cd flatpak; ls org.opencpn.OpenCPN.Plugin*yaml) +echo "Using manifest file: $MANIFEST" +set -x + +# Give the apt update daemons a chance to leave the scene while we build. +sudo systemctl stop apt-daily.service apt-daily.timer +sudo systemctl kill --kill-who=all apt-daily.service apt-daily-upgrade.service +sudo systemctl mask apt-daily.service apt-daily-upgrade.service +sudo systemctl daemon-reload + +# Install the flatpak PPA so we can access a usable flatpak version +# (not available on Ubuntu Xenial 16.04, the VM this runs on) +sudo add-apt-repository -y ppa:alexlarsson/flatpak +wget -q -O - https://dl.google.com/linux/linux_signing_key.pub \ + | sudo apt-key add - +sudo apt update + +# Install the dependencies: openpcn and the flatpak SDK. +sudo apt install build-essential flatpak-builder flatpak tar +flatpak remote-add --user --if-not-exists flathub \ + https://flathub.org/repo/flathub.flatpakrepo +flatpak install --user -y flathub org.opencpn.OpenCPN > /dev/null +flatpak install --user -y flathub org.freedesktop.Sdk//18.08 >/dev/null + +# Patch the runtime version so it matches the nightly builds' +sed -i '/^runtime-version/s/:.*/: stable/' flatpak/$MANIFEST + +# The flatpak checksumming needs python3: +pyenv local $(pyenv versions | sed 's/*//' | awk '{print $1}' | tail -1) +cp .python-version $HOME + +# Install a recent python, flatpak's is too old. +export PATH=$HOME/.local/bin:$PATH +python -m pip install --user cmake + +# Configure and build the plugin tarball and metadata. +mkdir build; cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j $(nproc) VERBOSE=1 flatpak + +# Restore patched file so the cache checksumming is ok. +git checkout ../flatpak/$MANIFEST + +# Wait for apt-daily to complete. apt-daily should not restart, it's masked. +# https://unix.stackexchange.com/questions/315502 +echo -n "Waiting for apt_daily lock..." +sudo flock /var/lib/apt/daily_lock echo done + +# Install cloudsmith, requiered by upload script +python3 -m pip install --user --upgrade pip +python3 -m pip install --user cloudsmith-cli + +# Required by git-push +python3 -m pip install --user cryptography + +# python install scripts in ~/.local/bin, teach upload.sh to use this in PATH +echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.uploadrc