From 6c3c2849fabd270d12b1e1fbfb789ac3528bbf4e Mon Sep 17 00:00:00 2001 From: iTrooz Date: Wed, 11 Oct 2023 16:17:52 +0200 Subject: [PATCH] build: build appimage using docker instead of github CI (#1358) --- .github/workflows/build.yml | 65 +++++++--------------------- dist/AppImageBuilder.yml | 2 +- dist/appimage/Dockerfile | 85 +++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 51 deletions(-) create mode 100644 dist/appimage/Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53be2c993..e6e6dc746 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -332,76 +332,41 @@ jobs: runs-on: ubuntu-22.04 name: ⬇️ AppImage steps: - - name: 🧰 Checkout uses: actions/checkout@v3 with: submodules: recursive - - name: 📜 Setup ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: appimage-ccache-${{ github.run_id }} - restore-keys: appimage-ccache - max-size: 1G - - - name: 📜 Restore CMakeCache + - name: 📁 Restore docker /cache uses: actions/cache@v3 with: - path: | - build-appimage/CMakeCache.txt - key: appimage-cmakecache-${{ hashFiles('**/CMakeLists.txt') }} + path: cache + key: appimage-ccache-${{ github.run_id }} + restore-keys: appimage-cache + + - name: 🐳 Inject /cache into docker + uses: reproducible-containers/buildkit-cache-dance@v2.1.2 + with: + cache-source: cache + cache-target: /cache - - name: ⬇️ Install dependencies + - name: 🛠️ Build using docker run: | - sudo apt update - sudo bash dist/get_deps_debian.sh + docker buildx build . -f dist/appimage/Dockerfile --progress=plain --build-arg "BUILD_TYPE=$BUILD_TYPE" \ + --build-arg "GIT_COMMIT_HASH=$GITHUB_SHA" --build-arg "GIT_BRANCH=${GITHUB_REF##*/}" --output out - sudo apt install -y python3-pip python3-setuptools desktop-file-utils libgdk-pixbuf2.0-dev fuse ninja-build - sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool - sudo chmod +x /usr/local/bin/appimagetool - sudo pip3 install git+https://github.com/iTrooz/appimage-builder@dpkg-package-versions - - - name: 📜 Set version variable - run: | - echo "IMHEX_VERSION=`cat VERSION`" >> $GITHUB_ENV - - # AppImage cmake build - - name: 🛠️ Build - run: | - mkdir -p build-appimage - cd build-appimage - CC=gcc-12 CXX=g++-12 cmake -G "Ninja" \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DCMAKE_INSTALL_PREFIX="/usr" \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DIMHEX_PATTERNS_PULL_MASTER=ON \ - -DIMHEX_COMMIT_HASH_SHORT="${GITHUB_SHA::7}" \ - -DIMHEX_COMMIT_HASH_LONG="${GITHUB_SHA}" \ - -DIMHEX_COMMIT_BRANCH="${GITHUB_REF##*/}" \ - -DIMHEX_ENABLE_LTO=ON \ - -DIMHEX_PLUGINS_IN_SHARE=ON \ - .. - DESTDIR=AppDir ninja install - - - name: 📦 Bundle AppImage - run: | - cd build-appimage - export VERSION=${{env.IMHEX_VERSION}} - appimage-builder --recipe ../dist/AppImageBuilder.yml - name: ⬆️ Upload AppImage uses: actions/upload-artifact@v3 with: name: Linux AppImage x86_64 - path: 'build-appimage/*.AppImage' + path: 'out/*.AppImage' - name: ⬆️ Upload AppImage zsync uses: actions/upload-artifact@v3 with: name: Linux AppImage zsync x86_64 - path: 'build-appimage/*.AppImage.zsync' + path: 'out/*.AppImage.zsync' # ArchLinux build archlinux-build: diff --git a/dist/AppImageBuilder.yml b/dist/AppImageBuilder.yml index fa51bb7b3..4f9eb6a7b 100644 --- a/dist/AppImageBuilder.yml +++ b/dist/AppImageBuilder.yml @@ -20,7 +20,7 @@ AppDir: - sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates universe - sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy multiverse - sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates multiverse - - sourceline: deb http://.archive.ubuntu.com/ubuntu/ jammy-backports main restricted + - sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse - sourceline: deb http://security.ubuntu.com/ubuntu jammy-security main restricted - sourceline: deb http://security.ubuntu.com/ubuntu jammy-security universe diff --git a/dist/appimage/Dockerfile b/dist/appimage/Dockerfile new file mode 100644 index 000000000..8330299c5 --- /dev/null +++ b/dist/appimage/Dockerfile @@ -0,0 +1,85 @@ +FROM ubuntu:22.04 as build + +# Used to invalidate layer cache but not mount cache +# See https://github.com/moby/moby/issues/41715#issuecomment-733976493 +ARG UNIQUEKEY 1 + +COPY dist/get_deps_debian.sh /tmp +RUN --mount=type=cache,target=/var/apt/cache <