|
| 1 | +name: macOS workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths-ignore: |
| 9 | + - .github/workflows/docker.yml |
| 10 | + - .github/workflows/linux.yml |
| 11 | + - .github/workflows/windows.yml |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths-ignore: |
| 16 | + - .github/workflows/docker.yml |
| 17 | + - .github/workflows/linux.yml |
| 18 | + - .github/workflows/windows.yml |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + runs-on: ${{ matrix.runner.name }} |
| 23 | + name: build (${{ matrix.config.type }}, ${{ matrix.runner.arch }}) |
| 24 | + strategy: |
| 25 | + max-parallel: 1 |
| 26 | + matrix: |
| 27 | + runner: |
| 28 | + - name: macos-15-intel # github-hosted runner name |
| 29 | + packages: qtbase qtimageformats quazip exiv2 ffmpeg wget |
| 30 | + arch: intel |
| 31 | + arch_flags: |
| 32 | + homebrew-opt: "/usr/local/opt" # root of qt_dir |
| 33 | + |
| 34 | + - name: macos-15 |
| 35 | + packages: qtbase qtimageformats quazip exiv2 ffmpeg wget |
| 36 | + arch: arm64 |
| 37 | + arch_flags: |
| 38 | + homebrew-opt: "/opt/homebrew/opt" |
| 39 | + |
| 40 | + config: |
| 41 | + - type: full |
| 42 | + packages: extra-cmake-modules karchive jpeg-xl libraw libde265 jxrlib libavif |
| 43 | + flags: "" |
| 44 | + kimageformats: true # compile kimageformat-plugins |
| 45 | + opencv: true # compile a minimal opencv |
| 46 | + portable: true # build portable folder |
| 47 | + artifacts: true # upload artifacts |
| 48 | + release: true # TODO: publish release |
| 49 | + |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + with: |
| 53 | + fetch-depth: 0 # ensure full history for git rev-parse |
| 54 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 55 | + |
| 56 | + - name: Get System Info |
| 57 | + id: get_info |
| 58 | + run: | |
| 59 | + COMPILER_ID=$(echo $(c++ --version) $(realpath $(xcrun --show-sdk-path))) |
| 60 | + SCRIPTS_ID=$(cat docker/*env docker/*.sh docker/*.diff | sha256) |
| 61 | + OPENCV_KEY=$(echo $COMPILER_ID $OPENCV_ID | sha256) |
| 62 | + KIF_KEY=$(echo $COMPILER_ID $SCRIPTS_ID | sha256) |
| 63 | + echo "Compiler: $COMPILER_ID" |
| 64 | + echo "Scripts: $SCRIPTS_ID" |
| 65 | + echo "OpenCV Cache Key: $OPENCV_KEY" |
| 66 | + echo "kimageformats Cache Key: $KIF_KEY" |
| 67 | + echo "OPENCV_KEY=${OPENCV_KEY}" >> $GITHUB_OUTPUT |
| 68 | + echo "KIF_KEY=${KIF_KEY}" >> $GITHUB_OUTPUT |
| 69 | +
|
| 70 | + - name: Setup Cache |
| 71 | + run: | |
| 72 | + # we must install things to /opt for packaging script to work, but cache@v4 won't write there |
| 73 | + # note this location is hardcoded to docker/macos.env |
| 74 | + sudo mkdir /opt/opencv2 /opt/kimageformats |
| 75 | + sudo chown $USER:$(id -gn) /opt/opencv2 /opt/kimageformats |
| 76 | +
|
| 77 | + - name: Install Packages |
| 78 | + run: | |
| 79 | + brew install --quiet --force-bottle ${{ matrix.runner.packages }} ${{ matrix.config.packages }} |
| 80 | +
|
| 81 | + - name: Cache opencv |
| 82 | + id: cache_opencv |
| 83 | + if: matrix.config.opencv |
| 84 | + uses: actions/cache@v4 |
| 85 | + with: |
| 86 | + path: /opt/opencv2 |
| 87 | + key: ${{ runner.os }}-opencv-${{ steps.get_info.outputs.OPENCV_KEY }} |
| 88 | + |
| 89 | + - name: Build opencv |
| 90 | + if: matrix.config.opencv && steps.cache_opencv.outputs.cache-hit != 'true' |
| 91 | + shell: bash |
| 92 | + run: | |
| 93 | + cd ${GITHUB_WORKSPACE}/docker |
| 94 | + shopt -s expand_aliases |
| 95 | + source macos.env |
| 96 | + ./build-opencv.sh |
| 97 | +
|
| 98 | + - name: Cache kimageformats |
| 99 | + id: cache_kimageformats |
| 100 | + if: matrix.config.kimageformats |
| 101 | + uses: actions/cache@v4 |
| 102 | + with: |
| 103 | + path: /opt/kimageformats |
| 104 | + key: ${{ runner.os }}-kimageformats-${{ steps.get_info.outputs.KIF_KEY }} |
| 105 | + |
| 106 | + - name: Build kimageformats |
| 107 | + if: matrix.config.kimageformats && steps.cache_kimageformats.outputs.cache-hit != 'true' |
| 108 | + shell: bash |
| 109 | + run: | |
| 110 | + cd ${GITHUB_WORKSPACE}/docker |
| 111 | + shopt -s expand_aliases |
| 112 | + source macos.env |
| 113 | + ./build-kimageformats.sh |
| 114 | +
|
| 115 | + - name: Configure |
| 116 | + shell: bash |
| 117 | + run: | |
| 118 | + cd ${GITHUB_WORKSPACE} |
| 119 | + shopt -s expand_aliases |
| 120 | + source docker/macos.env |
| 121 | + qmake6 |
| 122 | + make _mac/git.h |
| 123 | +
|
| 124 | + - name: Get Build Version |
| 125 | + id: get_version |
| 126 | + run: | |
| 127 | + cd ${GITHUB_WORKSPACE}/ |
| 128 | + ARCH=$(uname -m) |
| 129 | + OS="$(sw_vers -productName)-$(sw_vers -productVersion)" |
| 130 | + SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha || github.sha }}) |
| 131 | + VERSION=$(cat _mac/git.h | grep CBIRD_VERSION | sed 's/[^0-9\.]*//g') |
| 132 | + echo "VERSION=${VERSION}-${SHA}-${OS}-${ARCH}" >> $GITHUB_OUTPUT |
| 133 | +
|
| 134 | + - name: Build |
| 135 | + run: | |
| 136 | + cd ${GITHUB_WORKSPACE}/ |
| 137 | + make -j$(nproc) |
| 138 | +
|
| 139 | + - name: Make Portable Bundle |
| 140 | + if: matrix.config.portable |
| 141 | + run: | |
| 142 | + cd ${GITHUB_WORKSPACE}/ |
| 143 | + make portable |
| 144 | +
|
| 145 | + - name: Upload Artifacts |
| 146 | + if: matrix.config.artifacts |
| 147 | + uses: actions/upload-artifact@v4 |
| 148 | + with: |
| 149 | + name: "cbird-${{ steps.get_version.outputs.VERSION }}-${{ matrix.config.type }}" |
| 150 | + path: _mac/cbird-mac |
| 151 | + retention-days: 30 |
0 commit comments