4
0

macos-app.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # LYNX SHARE for macOS (universal dmg), round 190qd (the 0.1.31 release). A universal build in ONE job compiled every
  2. # translation unit twice (arm64 + x86_64) on one runner, and the big ones (src/Main.cpp) took about 2 h per architecture
  3. # on Apple clang: 0.1.30's job ran 3 h 25 min, 0.1.31's went past 4 h, close to GitHub's 6 h job limit. So each
  4. # architecture now builds on its own runner, in parallel, and a small job merges them with lipo.
  5. #
  6. # version the package label (input, or CMakeLists.txt's version + the commit)
  7. # build (macos-15, matrix arm64 / x86_64) CMake + Ninja, one architecture each; the LYNX.app goes on as an artifact
  8. # universal (macos-15) lipo -create of every Mach-O file of the two apps into one universal LYNX.app, self-test and
  9. # demo project on it (native arm64), scripts/package-macos.sh (ad-hoc signs the merged bundle) ->
  10. # LYNX-<label>-macos-universal.dmg
  11. # attach (workflow_dispatch with a tag only) attaches the dmg to that tag's GitHub release and adds its line to the
  12. # release's SHA256SUMS.txt (the in-app updater checks every download against it)
  13. #
  14. # release.yml calls it (workflow_call); a manual run (workflow_dispatch) builds `ref` (a tag: the dmg goes to its release).
  15. name: macOS app
  16. on:
  17. workflow_dispatch:
  18. inputs:
  19. ref:
  20. description: 'tag or commit to build (a tag v*: the dmg is attached to its release)'
  21. type: string
  22. required: true
  23. workflow_call:
  24. inputs:
  25. label:
  26. description: 'package label (release.yml passes its own)'
  27. type: string
  28. default: ''
  29. permissions:
  30. contents: read
  31. env:
  32. JUCE_VERSION: 8.0.4
  33. JUCE_SHA256: 0effe9823a6fd8a4f98e5c08be7d308350e417b2d15dcf34011e778fefbbf005
  34. jobs:
  35. version:
  36. name: Version
  37. runs-on: ubuntu-24.04
  38. outputs:
  39. label: ${{ steps.version.outputs.label }}
  40. ref: ${{ steps.version.outputs.ref }}
  41. steps:
  42. - uses: actions/checkout@v5
  43. with:
  44. ref: ${{ inputs.ref || github.ref }}
  45. - name: Label
  46. id: version
  47. shell: bash
  48. env:
  49. INPUT_LABEL: ${{ inputs.label }}
  50. INPUT_REF: ${{ inputs.ref }}
  51. run: |
  52. version="$(sed -n 's/^project(LYNX VERSION \([0-9]*\.[0-9]*\.[0-9]*\(\.[0-9]*\)\{0,1\}\).*/\1/p' CMakeLists.txt)"
  53. [[ -n "$version" ]] || { echo "::error::no version in CMakeLists.txt"; exit 1; }
  54. sha="$(git rev-parse HEAD)"
  55. if [[ -n "$INPUT_LABEL" ]]; then label="$INPUT_LABEL"
  56. elif [[ "$INPUT_REF" == v* ]]; then label="${INPUT_REF#v}"
  57. else label="$version-${sha::7}"; fi
  58. echo "label=$label" >> "$GITHUB_OUTPUT"
  59. echo "ref=$sha" >> "$GITHUB_OUTPUT"
  60. echo "LYNX macOS $label ($sha)"
  61. build:
  62. name: macOS (${{ matrix.arch }})
  63. needs: version
  64. runs-on: macos-15
  65. timeout-minutes: 300
  66. strategy:
  67. matrix:
  68. arch: [arm64, x86_64]
  69. steps:
  70. - uses: actions/checkout@v5
  71. with:
  72. ref: ${{ needs.version.outputs.ref }}
  73. - name: Build dependencies
  74. run: brew list ninja > /dev/null 2>&1 || brew install ninja
  75. - name: JUCE (checksum verified)
  76. run: |
  77. curl -fsSL -o juce.tar.gz "https://github.com/juce-framework/JUCE/archive/refs/tags/$JUCE_VERSION.tar.gz"
  78. echo "$JUCE_SHA256 juce.tar.gz" | shasum -a 256 -c -
  79. mkdir -p "$RUNNER_TEMP/juce" && tar xzf juce.tar.gz -C "$RUNNER_TEMP/juce" --strip-components 1 && rm juce.tar.gz
  80. - name: Build (${{ matrix.arch }})
  81. run: |
  82. cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DFETCHCONTENT_SOURCE_DIR_JUCE="$RUNNER_TEMP/juce" \
  83. -DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}"
  84. cmake --build build --target LYNX -- -k 0
  85. lipo -info build/LYNX_artefacts/Release/LYNX.app/Contents/MacOS/LYNX
  86. # (a tar keeps the bundle's symbolic links and modes through the artifact)
  87. tar -C build/LYNX_artefacts/Release -cf "LYNX-app-${{ matrix.arch }}.tar" LYNX.app
  88. - uses: actions/upload-artifact@v7
  89. with:
  90. name: macos-app-${{ matrix.arch }}
  91. path: LYNX-app-${{ matrix.arch }}.tar
  92. if-no-files-found: error
  93. retention-days: 3
  94. universal:
  95. name: macOS (universal dmg)
  96. needs: [version, build]
  97. runs-on: macos-15
  98. timeout-minutes: 60
  99. env:
  100. LABEL: ${{ needs.version.outputs.label }}
  101. steps:
  102. - uses: actions/checkout@v5
  103. with:
  104. ref: ${{ needs.version.outputs.ref }}
  105. - uses: actions/download-artifact@v8
  106. with:
  107. pattern: macos-app-*
  108. path: apps
  109. merge-multiple: true
  110. - name: Merge the two apps (lipo)
  111. run: |
  112. mkdir -p apps/arm64 apps/x86_64 merged
  113. tar -C apps/arm64 -xf apps/LYNX-app-arm64.tar
  114. tar -C apps/x86_64 -xf apps/LYNX-app-x86_64.tar
  115. cp -R apps/arm64/LYNX.app merged/LYNX.app
  116. n=0
  117. while IFS= read -r -d '' f; do
  118. rel="${f#apps/arm64/}"
  119. if file -b "$f" | grep -q 'Mach-O'; then
  120. [[ -f "apps/x86_64/$rel" ]] || { echo "::error::$rel has no x86_64 twin"; exit 1; }
  121. lipo -create "$f" "apps/x86_64/$rel" -output "merged/$rel"
  122. n=$((n + 1))
  123. fi
  124. done < <(find apps/arm64/LYNX.app -type f -print0)
  125. echo "merged $n Mach-O files"
  126. lipo -info merged/LYNX.app/Contents/MacOS/LYNX
  127. lipo -info merged/LYNX.app/Contents/MacOS/LYNX | grep -q 'x86_64 arm64\|arm64 x86_64'
  128. - name: Self-test and demo project
  129. run: |
  130. bin=merged/LYNX.app/Contents/MacOS/LYNX
  131. "$bin" --selftest "$PWD/selftest.txt" "$PWD/selftest-demo.lynx" || true
  132. cat selftest.txt
  133. grep -q '^result=OK' selftest.txt
  134. "$bin" --showcase "$PWD/Demo.lynx" || true
  135. test -s Demo.lynx
  136. - name: Package
  137. run: ./scripts/package-macos.sh merged/LYNX.app "$LABEL" dist Demo.lynx
  138. - name: Upload package
  139. uses: actions/upload-artifact@v7
  140. with:
  141. name: LYNX-${{ env.LABEL }}-macos-universal
  142. path: dist/*
  143. if-no-files-found: error
  144. attach:
  145. name: Attach to the release
  146. needs: [version, universal]
  147. if: ${{ github.event_name == 'workflow_dispatch' && startsWith(inputs.ref, 'v') }}
  148. runs-on: ubuntu-24.04
  149. permissions:
  150. contents: write
  151. env:
  152. LABEL: ${{ needs.version.outputs.label }}
  153. GH_TOKEN: ${{ github.token }}
  154. GH_REPO: ${{ github.repository }}
  155. TAG: ${{ inputs.ref }}
  156. steps:
  157. - uses: actions/download-artifact@v8
  158. with:
  159. name: LYNX-${{ env.LABEL }}-macos-universal
  160. path: dist
  161. - name: Upload the dmg and update SHA256SUMS.txt
  162. run: |
  163. cd dist
  164. ls -la
  165. gh release download "$TAG" -p SHA256SUMS.txt -D old
  166. grep -v -- '-macos-universal\.dmg$' old/SHA256SUMS.txt > SHA256SUMS.txt || true
  167. sha256sum -- *.dmg >> SHA256SUMS.txt
  168. cat SHA256SUMS.txt
  169. gh release upload "$TAG" ./*.dmg SHA256SUMS.txt --clobber