From c1bfded4a76fbb9a9b607bedeae63b128dbe4cab Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Sun, 21 Jan 2024 01:07:33 +1300 Subject: [PATCH] CICD: Add GitHub Action to build the Windows (MXE) Builder Docker Image. Add a GitHub action that builds the docker image to run builds for the Windows (MXE) version of Subsurface. Also update the MXE image Dockerfile to the latest version of MXE, and add a patch to use a current version of mdbtools. Configure GitHub actions that do not build docker images to not trigger on changes to the contents of `scripts/docker/`. Signed-off-by: Michael Keller --- .github/workflows/android.yml | 4 + .github/workflows/fedora-copr-build.yml | 2 + .github/workflows/ios.yml | 4 + .github/workflows/linux-fedora-qt6.yml | 4 + .github/workflows/linux-focal-5.12.yml | 4 + .github/workflows/linux-jammy-5.15.yml | 4 + .github/workflows/linux-snap.yml | 4 + .github/workflows/linux-trusty-5.12.yml | 4 + .github/workflows/mac.yml | 4 + .github/workflows/post-releasenotes.yml | 2 + .github/workflows/ubuntu-launchpad-build.yml | 2 + .github/workflows/windows-mxe-dockerimage.yml | 36 ++++++++ .github/workflows/windows.yml | 4 + scripts/docker/mxe-build-container/Dockerfile | 89 +++++++++++-------- .../mxe-build-container/build-container.sh | 2 +- .../mdbtools_version.patch | 52 +++++++++++ .../docker/mxe-build-container/settings.mk | 4 +- 17 files changed, 186 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/windows-mxe-dockerimage.yml mode change 100644 => 100755 scripts/docker/mxe-build-container/build-container.sh create mode 100644 scripts/docker/mxe-build-container/mdbtools_version.patch diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 477c5120f..35f9dca3a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,9 +1,13 @@ name: Android on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/fedora-copr-build.yml b/.github/workflows/fedora-copr-build.yml index 30e29989f..044113f28 100644 --- a/.github/workflows/fedora-copr-build.yml +++ b/.github/workflows/fedora-copr-build.yml @@ -1,6 +1,8 @@ name: Fedora Copr Build on: push: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index dc2af03fa..0cf45103f 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -1,9 +1,13 @@ name: iOS on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/linux-fedora-qt6.yml b/.github/workflows/linux-fedora-qt6.yml index a17e90e49..00ef3e250 100644 --- a/.github/workflows/linux-fedora-qt6.yml +++ b/.github/workflows/linux-fedora-qt6.yml @@ -1,9 +1,13 @@ name: Fedora 35 / Qt 6-- on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/linux-focal-5.12.yml b/.github/workflows/linux-focal-5.12.yml index 0ff14b896..02cdee9ed 100644 --- a/.github/workflows/linux-focal-5.12.yml +++ b/.github/workflows/linux-focal-5.12.yml @@ -1,9 +1,13 @@ name: Ubuntu 20.04 / Qt 5.12-- on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/linux-jammy-5.15.yml b/.github/workflows/linux-jammy-5.15.yml index 140e40b61..f904126ef 100644 --- a/.github/workflows/linux-jammy-5.15.yml +++ b/.github/workflows/linux-jammy-5.15.yml @@ -1,9 +1,13 @@ name: Ubuntu 22.04 / Qt 5.15-- on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/linux-snap.yml b/.github/workflows/linux-snap.yml index a174c87bd..d0ee53435 100644 --- a/.github/workflows/linux-snap.yml +++ b/.github/workflows/linux-snap.yml @@ -2,9 +2,13 @@ name: Linux Snap on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/linux-trusty-5.12.yml b/.github/workflows/linux-trusty-5.12.yml index 8ce661cb5..163734bd4 100644 --- a/.github/workflows/linux-trusty-5.12.yml +++ b/.github/workflows/linux-trusty-5.12.yml @@ -1,9 +1,13 @@ name: Ubuntu 14.04 / Qt 5.12 for AppImage-- on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 29d19fdcd..073919f42 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -1,9 +1,13 @@ name: Mac on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/post-releasenotes.yml b/.github/workflows/post-releasenotes.yml index bf21dff55..6df55f8dd 100644 --- a/.github/workflows/post-releasenotes.yml +++ b/.github/workflows/post-releasenotes.yml @@ -1,6 +1,8 @@ name: Post Release on: push: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/ubuntu-launchpad-build.yml b/.github/workflows/ubuntu-launchpad-build.yml index 0fd97bf03..ba1f9cfdc 100644 --- a/.github/workflows/ubuntu-launchpad-build.yml +++ b/.github/workflows/ubuntu-launchpad-build.yml @@ -1,6 +1,8 @@ name: Ubuntu Launchpad Build on: push: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/.github/workflows/windows-mxe-dockerimage.yml b/.github/workflows/windows-mxe-dockerimage.yml new file mode 100644 index 000000000..9b6d00144 --- /dev/null +++ b/.github/workflows/windows-mxe-dockerimage.yml @@ -0,0 +1,36 @@ +name: Windows (MXE) Docker Image + +on: + push: + paths: + - scripts/docker/mxe-build-container/** + - .github/workflows/windows-mxe-dockerimage.yml + +jobs: + windows-mxe: + runs-on: ubuntu-latest + env: + VERSION: ${{ '3.1.0' }} # 'official' images should have a dot-zero version + mxe_sha: 'c0bfefc57a00fdf6cb5278263e21a478e47b0bf5' + + steps: + - uses: actions/checkout@v1 + + - name: Build the name for the docker image + id: build_name + run: | + v=${{ env.VERSION }} + b=${{ github.ref }} # -BRANCH suffix, unless the branch is master + b=${b/refs\/heads\//} + b=${b,,} # the name needs to be all lower case + if [ $b = "master" ] ; then b="" ; else b="-$b" ; fi + echo "NAME=${{ github.repository_owner }}/mxe-build${b}:${v}" >> $GITHUB_OUTPUT + + - name: Build and Publish Linux Docker image to Dockerhub + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: ${{ steps.build_name.outputs.NAME }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + workdir: './scripts/docker/mxe-build-container/' + buildargs: mxe_sha diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 9fdf86b65..b9ade928d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,9 +1,13 @@ name: Windows on: push: + paths-ignore: + - scripts/docker/** branches: - master pull_request: + paths-ignore: + - scripts/docker/** branches: - master diff --git a/scripts/docker/mxe-build-container/Dockerfile b/scripts/docker/mxe-build-container/Dockerfile index ebe24d0a0..2f5a0a382 100644 --- a/scripts/docker/mxe-build-container/Dockerfile +++ b/scripts/docker/mxe-build-container/Dockerfile @@ -1,77 +1,94 @@ # Build the image using the --build-arg option, e.g.: # docker build -t boret/myimage:0.1 --build-arg=mxe_sha=123ABC456 . -# -# Start from Ubuntu -From ubuntu:22.04 +FROM ubuntu:22.04 as base -# very often master is broken, so we pass in a known good SHA -ARG mxe_sha=master -ENV _ver=${mxe_sha} - -# update and set up the packages we need for this cross build -RUN apt-get update && apt-get upgrade -y && \ -DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ +# update and set up the packages we need for the build +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ autoconf \ automake \ autopoint \ bash \ binutils \ - bison \ bzip2 \ ca-certificates \ - flex \ g++ \ g++-multilib \ gettext \ git \ - gperf \ intltool \ - libc6-dev-i386 \ - libgdk-pixbuf2.0-dev \ libltdl-dev \ libssl-dev \ libtool \ libtool-bin \ - libxml-parser-perl \ make \ openssl \ p7zip-full \ patch \ perl \ pkg-config \ - python3 \ - python3-mako \ - ruby \ sed \ unzip \ wget \ + lzip && \ + apt-get clean + + +FROM base as build + +# set up the packages we need additionally for this cross build +RUN apt-get install -y \ + bison \ + flex \ + gperf \ + libc6-dev-i386 \ + libgdk-pixbuf2.0-dev \ + libxml-parser-perl \ + python3 \ + python3-mako \ + python-is-python3 \ + ruby \ xz-utils \ - lzip \ scons +# very often master is broken, so we pass in a known good SHA +ARG mxe_sha=master +ENV _ver=${mxe_sha} + +WORKDIR /win + # checkout MXE at the right version -RUN mkdir -p /win -RUN cd /win ; git clone https://github.com/mxe/mxe ; \ - cd mxe ; \ - git checkout ${_ver} ; +RUN git clone https://github.com/mxe/mxe && \ + cd mxe && \ + git checkout ${_ver} + +WORKDIR /win/mxe + +# Move the settings into place to build everything that we need +ADD settings.mk . # Patch the qtconnectivity build to explicilty enable native-win32-bluetooth and ensure another # backend is not picked -ADD qtconnectivity-1.patch /win/mxe/src/qtconnectivity-1.patch +ADD qtconnectivity-1.patch src/ + +ADD mdbtools_version.patch . +RUN patch -p1 < mdbtools_version.patch 2>&1 | tee mxe-patch.log -# Move the settings into place to build everything that we need # separate download from build so that we can redo the build -ADD settings.mk /win/mxe/settings.mk -RUN cd /usr/bin ; ln -s -f python3 python -RUN cd /win/mxe ; \ - make -j 6 download 2>&1 | tee mxe-build.log -RUN cd /win/mxe ; \ - make -j 6 2>&1 | tee -a mxe-build.log ; +RUN make -j download 2>&1 | tee mxe-build.log + +RUN make -j 2>&1 | tee -a mxe-build.log # for some reason smtk2ssrf needs a static build of mdbtools -RUN cd /win/mxe ; \ - make MXE_TARGETS=x86_64-w64-mingw32.static glib mdbtools -j 6 2>&1 | tee -a mxe-build.log ; +RUN make MXE_TARGETS=x86_64-w64-mingw32.static glib mdbtools -j 2>&1 | tee -a mxe-build.log -RUN apt-get remove -y bison flex gperf libc6-dev-i386 libgdk-pixbuf2.0-dev libxml-parser-perl python ruby xz-utils scons && rm -rf /var/lib/apt/lists/* -RUN rm -rf /win/mxe/pkg /win/mxe/log /win/mxe/docs +RUN rm -rf pkg log docs + + +FROM base as final + +WORKDIR /win + +COPY --from=build /win/mxe mxe diff --git a/scripts/docker/mxe-build-container/build-container.sh b/scripts/docker/mxe-build-container/build-container.sh old mode 100644 new mode 100755 index dcfcc1ecb..1909459ca --- a/scripts/docker/mxe-build-container/build-container.sh +++ b/scripts/docker/mxe-build-container/build-container.sh @@ -3,7 +3,7 @@ set -x set -e # known good MXE sha -MXE_SHA="0d21cf2e31d4e6c0" +MXE_SHA="c0bfefc57a00fdf6cb5278263e21a478e47b0bf5" SCRIPTPATH=$(dirname $0) # version of the docker image diff --git a/scripts/docker/mxe-build-container/mdbtools_version.patch b/scripts/docker/mxe-build-container/mdbtools_version.patch new file mode 100644 index 000000000..98fa6112d --- /dev/null +++ b/scripts/docker/mxe-build-container/mdbtools_version.patch @@ -0,0 +1,52 @@ +# Temporary patch to apply to MXE's src/mdbtools.mk file while building docker +# image, until it's applied upstream at github's MXE repo. + + +diff --git a/src/mdbtools.mk b/src/mdbtools.mk +index 42d303c2..d9d0f557 100644 +--- a/src/mdbtools.mk ++++ b/src/mdbtools.mk +@@ -1,19 +1,17 @@ + # This file is part of MXE. See LICENSE.md for licensing information. + + PKG := mdbtools +-$(PKG)_WEBSITE := https://sourceforge.net/projects/mdbtools/ ++$(PKG)_WEBSITE := https://github.com/mdbtools/mdbtools + $(PKG)_IGNORE := +-$(PKG)_VERSION := 0.7.1 +-$(PKG)_CHECKSUM := 4eac1bce55066a38d9ea6c52a8e8ecc101b79afe75118ecc16852990472c4721 +-$(PKG)_SUBDIR := brianb-mdbtools-f8ce1cc +-$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz +-$(PKG)_URL := https://github.com/brianb/$(PKG)/tarball/$($(PKG)_VERSION)/$($(PKG)_FILE) ++$(PKG)_VERSION := 1.0.0 ++$(PKG)_CHECKSUM := 3446e1d71abdeb98d41e252777e67e1909b186496fda59f98f67032f7fbcd955 ++$(PKG)_GH_CONF := mdbtools/mdbtools/releases, v + $(PKG)_DEPS := cc glib + + define $(PKG)_UPDATE +- $(WGET) -q -O- 'https://github.com/brianb/mdbtools/tags' | \ +- grep '