From 2ffba35d45278830c83bb524acbe7fc8e7e6e88e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 9 Dec 2023 03:31:18 +0900 Subject: [PATCH] Build a macOS DMG in a GitHub Action Signed-off-by: Dirk Hohndel --- .github/workflows/mac.yml | 61 ++++++++++++-------------------- packaging/macosx/make-package.sh | 22 +++++------- scripts/build.sh | 16 ++++----- 3 files changed, 39 insertions(+), 60 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index cadc28513..bcceaa657 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -9,68 +9,51 @@ on: jobs: buildMac: - runs-on: macOS-latest + runs-on: macOS-11 steps: - name: checkout sources uses: actions/checkout@v1 - name: setup Homebrew - run: brew install autoconf automake libtool xz hidapi libusb libxml2 libxslt libzip openssl pkg-config libgit2 libssh2 libjpg libpng libmtp + run: brew install autoconf automake libtool xz hidapi libusb libxml2 libxslt libzip openssl pkg-config libgit2 libssh2 libjpg libpng libmtp create-dmg - name: set our Qt build run: | - mkdir -p Qt/5.13.0 - curl --output Qt-5.13.0-mac.tar.xz https://f002.backblazeb2.com/file/Subsurface-Travis/Qt-5.13.0-mac.tar.xz - tar -xJ -C Qt/5.13.0 -f Qt-5.13.0-mac.tar.xz - - name: build Subsurface-mobile - env: - SUBSURFACE_REPO_PATH: ${{ github.workspace }} - run: | - cd ${GITHUB_WORKSPACE}/.. - export QT_ROOT=${GITHUB_WORKSPACE}/Qt/5.13.0/clang_64 - export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins - export PATH=$QT_ROOT/bin:$PATH - export CMAKE_PREFIX_PATH=$QT_ROOT/lib/cmake - DIR=$(pwd) - git config --global user.email "ci@subsurface-divelog.org" - git config --global user.name "Subsurface CI" - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH} - git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer - # first build Subsurface-mobile to ensure this didn't get broken - bash -e -x ./subsurface/scripts/build.sh -mobile - - - name: test mobile build - run: | - echo "------------------------------------" - echo "run tests for mobile build" - export QT_ROOT=${GITHUB_WORKSPACE}/Qt/5.13.0/clang_64 - export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins - cd ${GITHUB_WORKSPACE}/build-mobile/tests - # ./TestGitStorage -v2 - make check - + curl --output ssrf-Qt-5.15.2-mac.tar.xz https://f002.backblazeb2.com/file/Subsurface-Travis/ssrf-Qt5.15.2.tar.xz + tar -xJf ssrf-Qt-5.15.2-mac.tar.xz - name: build Subsurface run: | cd ${GITHUB_WORKSPACE}/.. - export QT_ROOT=${GITHUB_WORKSPACE}/Qt/5.13.0/clang_64 + export QT_ROOT=${GITHUB_WORKSPACE}/Qt5.15.2/5.15.2/clang_64 export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins export PATH=$QT_ROOT/bin:$PATH export CMAKE_PREFIX_PATH=$QT_ROOT/lib/cmake DIR=$(pwd) - # now Subsurface with WebKit - bash -e -x ./subsurface/scripts/build.sh -desktop -build-with-webkit -release + # now build Subsurface with WebKit, using the generic build script + bash -e -x ./subsurface/scripts/build.sh -desktop -build-with-webkit -release -build-deps -ftdi - cd ${GITHUB_WORKSPACE}/build + echo "finished initial build of Subsurface" - # build export-html to make sure that didn't get broken - make export-html + # make sure we have FTDI enabled for the package + cd subsurface/build + FTDI=$(grep FTDISUPPORT:BOOL CMakeCache.txt | grep ON) + if [ "$FTDI" != "FTDISUPPORT:BOOL=ON" ] ; then + cmake -D FTDISUPPORT:BOOL=ON . + fi + echo "run the packaging script" + bash -e -x ../packaging/macos/make-package.sh + IMG=$(grep ^created: ../trigger-daily.log | tail -1 | cut -b10-) + echo "Created $IMG" - name: test desktop build run: | + # build export-html to make sure that didn't get broken + cd ${GITHUB_WORKSPACE}/build + make export-html echo "------------------------------------" echo "run tests for desktop build" export QT_ROOT=${GITHUB_WORKSPACE}/Qt/5.13.0/clang_64 export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins - cd ${GITHUB_WORKSPACE}/build/tests + cd tests # ./TestGitStorage -v2 make check diff --git a/packaging/macosx/make-package.sh b/packaging/macosx/make-package.sh index aec1ad761..6a1eedfe5 100755 --- a/packaging/macosx/make-package.sh +++ b/packaging/macosx/make-package.sh @@ -7,17 +7,7 @@ # find the directory above the sources - typically ~/src DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../.. && pwd ) -# install location of create-dmg -# by default we assume it's next to subsurface in ~/src/yoursway-create-dmg -DMGCREATE=${DIR}/yoursway-create-dmg/create-dmg -if [ ! -x $DMGCREATE ] ; then - # well, this app changed its github name, so it may be in a different directory now - DMGCREATE=${DIR}/create-dmg/create-dmg - if [ ! -x $DMGCREATE ] ; then - echo "Can't find working create-dmg, aborting" - exit 1 - fi -fi +DMGCREATE=create-dmg # same git version magic as in the Makefile # for the naming of volume and dmg we want the 3 digits of the full version number @@ -42,7 +32,7 @@ OLDER_MAC_CMAKE="-DCMAKE_OSX_DEPLOYMENT_TARGET=${BASESDK} -DCMAKE_OSX_SYSROOT=${ export PKG_CONFIG_PATH=${DIR}/install-root/lib/pkgconfig:$PKG_CONFIG_PATH cmake $OLDER_MAC_CMAKE . -LIBRARY_PATH=${DIR}/install-root/lib make -j8 +LIBRARY_PATH=${DIR}/install-root/lib make -j LIBRARY_PATH=${DIR}/install-root/lib make install # now adjust a few references that macdeployqt appears to miss @@ -93,6 +83,10 @@ done if [ "$1" = "-nodmg" ] ; then exit 0 +elif [ "$1" = "-sign" ] ; then + SIGN=1 +else + SIGN=0 fi # copy things into staging so we can create a nice DMG @@ -100,7 +94,9 @@ rm -rf ./staging mkdir ./staging cp -a ./Subsurface.app ./staging -sh ${DIR}/subsurface/packaging/macosx/sign +if [ "$SIGN" = "1" ] ; then + sh ${DIR}/subsurface/packaging/macosx/sign +fi if [ -f ./Subsurface-$VERSION.dmg ]; then rm ./Subsurface-$VERSION.dmg.bak diff --git a/scripts/build.sh b/scripts/build.sh index df26ca3da..5c6778487 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -137,6 +137,10 @@ while [[ $# -gt 0 ]] ; do BUILD_DESKTOP="1" BUILD_DOWNLOADER="1" ;; + -ftdi) + # make sure we include the user space FTDI drivers + FTDI="1" + ;; -create-appdir) # we are building an AppImage as by product CREATE_APPDIR="1" @@ -147,7 +151,7 @@ while [[ $# -gt 0 ]] ; do ;; *) echo "Unknown command line argument $arg" - echo "Usage: build.sh [-no-bt] [-quick] [-build-deps] [-fat-build] [-src-dir ] [-build-prefix ] [-build-with-webkit] [-build-with-map] [-mobile] [-desktop] [-downloader] [-both] [-all] [-create-appdir] [-release]" + echo "Usage: build.sh [-no-bt] [-quick] [-build-deps] [-fat-build] [-src-dir ] [-build-prefix ] [-build-with-webkit] [-build-with-map] [-mobile] [-desktop] [-downloader] [-both] [-all] [-ftdi] [-create-appdir] [-release]" exit 1 ;; esac @@ -572,13 +576,6 @@ if [ "$QUICK" != "1" ] && [ "$BUILD_DESKTOP$BUILD_MOBILE" != "" ] && ( [[ $QT_VE else $QMAKE "INCLUDEPATH=$INSTALL_ROOT/include" ../googlemaps.pro fi - # on Travis the compiler doesn't support c++1z, yet qmake adds that flag; - # since things compile fine with c++11, let's just hack that away - # similarly, don't use -Wdata-time - if [ "$TRAVIS" = "true" ] ; then - mv Makefile Makefile.bak - cat Makefile.bak | sed -e 's/std=c++1z/std=c++11/g ; s/-Wdate-time//' > Makefile - fi make -j4 if [ "$PLATFORM" = Darwin ] && [[ $QT_VERSION == 6* ]] && [[ $ARCHS == *" "* ]] ; then # we can't build fat binaries directly here, so let's do it in two steps @@ -612,6 +609,9 @@ for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do else EXTRA_OPTS="-DNO_USERMANUAL=ON -DNO_PRINTING=ON" fi + if [ "$FTDI" = "1" ] ; then + EXTRA_OPTSi="$EXTRA_OPTS -DFTDISUPPORT" + fi if [ "$BUILD_WITH_QT6" = "1" ] ; then EXTRA_OPTS="$EXTRA_OPTS -DBUILD_WITH_QT6=ON" fi