diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
| commit | 059831534c7e884f0a607ed86b582fd00d821731 (patch) | |
| tree | 76bcb67a78f8aa2654fd34c2ad801a62136b0170 /.github/workflows/build-macos.yml | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to '.github/workflows/build-macos.yml')
| -rw-r--r-- | .github/workflows/build-macos.yml | 1540 |
1 files changed, 793 insertions, 747 deletions
diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 295ab743..274270d3 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -1,5 +1,8 @@ name: Build macOS +permissions: + contents: read + on: workflow_call: inputs: @@ -11,7 +14,7 @@ on: description: "Hamlib branch to build" required: false type: string - default: "4.7.1" + default: "4.7.2" arch: description: "Target architecture (arm64 or x86_64)" required: true @@ -24,6 +27,16 @@ on: description: "macOS deployment target version" required: true type: string + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + save_ccache: + description: "Persist compiler objects from a trusted develop build" + required: false + type: boolean + default: false release_channel: description: "Build release channel: DEVEL, RC, or GA" required: false @@ -34,74 +47,239 @@ on: required: false type: string default: "" + signing_mode: + description: "Package signing policy: validation or distribution" + required: false + type: string + default: "validation" + apple_team_id: + description: "Expected Apple Developer Team ID for distribution signing" + required: false + type: string + default: "" + application_certificate_sha1: + description: "Expected Developer ID Application certificate SHA-1" + required: false + type: string + default: "" + installer_certificate_sha1: + description: "Expected Developer ID Installer certificate SHA-1" + required: false + type: string + default: "" + secrets: + DEVELOPER_ID_CERTIFICATE_P12: + description: "Base64-encoded Developer ID Application PKCS#12" + required: false + DEVELOPER_ID_CERTIFICATE_PASSWORD: + description: "Password for the Application PKCS#12" + required: false + DEVELOPER_ID_INSTALLER_P12: + description: "Base64-encoded Developer ID Installer PKCS#12" + required: false + DEVELOPER_ID_INSTALLER_PASSWORD: + description: "Password for the Installer PKCS#12" + required: false + APP_STORE_CONNECT_KEY_ID: + description: "App Store Connect API key ID" + required: false + APP_STORE_CONNECT_ISSUER_ID: + description: "App Store Connect API issuer ID" + required: false + APP_STORE_CONNECT_PRIVATE_KEY_P8_BASE64: + description: "Base64-encoded App Store Connect API private key" + required: false + # Standalone dispatch builds one architecture. Derive its runner and deployment + # target from that architecture so unsupported tuples cannot be selected. + workflow_dispatch: + inputs: + version: + description: "WSJT-X version string (artifact + package names)" + required: false + type: string + default: "3.2.0-devel" + hamlib_branch: + description: "Hamlib branch to build" + required: false + type: string + default: "4.7.2" + arch: + description: "Target architecture" + required: false + type: choice + options: + - arm64 + - x86_64 + default: "arm64" + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + save_ccache: + description: "Persist compiler objects when dispatching on develop" + required: false + type: boolean + default: true + release_channel: + description: "Build release channel" + required: false + type: choice + options: + - DEVEL + - RC + - GA + default: "DEVEL" + rc_number: + description: "Release candidate number when release_channel is RC" + required: false + type: string + default: "" + signing_mode: + description: "Package signing policy" + required: false + type: choice + options: + - validation + - distribution + default: validation + apple_team_id: + description: "Expected Apple Developer Team ID (distribution only)" + required: false + type: string + default: "" + application_certificate_sha1: + description: "Expected Developer ID Application certificate SHA-1" + required: false + type: string + default: "" + installer_certificate_sha1: + description: "Expected Developer ID Installer certificate SHA-1" + required: false + type: string + default: "" jobs: build: - runs-on: ${{ inputs.runner }} + # runs-on cannot reference job-level env, so keep this expression and RUNNER + # aligned. RUNNER also keeps cache keys consistent across both triggers. + runs-on: ${{ inputs.runner || (inputs.arch == 'x86_64' && 'macos-15-intel' || 'macos-15') }} + timeout-minutes: 45 + env: + RUNNER: ${{ inputs.runner || (inputs.arch == 'x86_64' && 'macos-15-intel' || 'macos-15') }} + DEPLOYMENT_TARGET: ${{ inputs.deployment_target || (inputs.arch == 'x86_64' && '10.13' || '11.0') }} + VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + SIGNING_MODE: ${{ inputs.signing_mode }} + ARCH: ${{ inputs.arch }} + BOOST_VERSION: 1.85.0 + BOOST_SOURCE_SHA256: 7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - name: Resolve source revision - id: source_revision - run: | - source_revision="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}" - if [ -z "$source_revision" ]; then - source_revision="$(git rev-parse HEAD)" - fi - echo "sha=${source_revision}" >> "$GITHUB_OUTPUT" + - name: Validate workflow inputs + env: + WSJTX_VERSION: ${{ inputs.version }} + run: .github/scripts/validate-ci-inputs.sh - name: Verify macOS build tuple run: | - case "${{ inputs.arch }}:${{ inputs.runner }}:${{ inputs.deployment_target }}" in + case "${ARCH}:${RUNNER}:${DEPLOYMENT_TARGET}" in arm64:macos-15:11.0|x86_64:macos-15-intel:10.13) - echo "Using supported macOS build tuple: ${{ inputs.arch }} on ${{ inputs.runner }} targeting ${{ inputs.deployment_target }}" + echo "Using supported macOS build tuple: ${ARCH} on ${RUNNER} targeting ${DEPLOYMENT_TARGET}" ;; *) - echo "::error::Unsupported macOS build tuple: arch=${{ inputs.arch }}, runner=${{ inputs.runner }}, deployment_target=${{ inputs.deployment_target }}" - echo "::error::Use arm64:macos-15:11.0 or x86_64:macos-15-intel:10.13. Do not use macos-latest for release artifacts." + echo "::error::Unsupported macOS build tuple: arch=${ARCH}, runner=${RUNNER}, deployment_target=${DEPLOYMENT_TARGET}" + echo "::error::Use arm64:macos-15:11.0 or x86_64:macos-15-intel:10.13 for deployable macOS artifacts." exit 1 ;; esac - - name: Check signing secrets - id: check_secrets - env: - APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} + - name: Validate signing policy run: | - if [ -n "$APP_P12" ]; then - echo "signing_enabled=true" >> "$GITHUB_OUTPUT" - else - echo "signing_enabled=false" >> "$GITHUB_OUTPUT" - echo "::notice::macOS signing skipped — secrets unavailable (Dependabot or fork PR context). Compile + tests + dylib bundling still validated." - fi + case "$SIGNING_MODE" in + validation) + echo "macOS signing mode: validation (ad-hoc app signature and explicitly unsigned package)" + ;; + distribution) + echo "macOS signing mode: distribution (build job remains secretless; a fresh job performs signing)" + ;; + *) + echo "::error::signing_mode must be validation or distribution, got: ${SIGNING_MODE}" + exit 1 + ;; + esac - name: Set Homebrew prefix run: echo "HOMEBREW_PREFIX=$(brew --prefix)" >> "$GITHUB_ENV" - name: Install dependencies - run: brew install cmake autoconf automake libtool asciidoctor + run: brew install cmake autoconf automake libtool asciidoctor ccache pkg-config + + - name: Select ccache key + id: ccache-key + env: + RECACHE: ${{ inputs.recache }} + run: .github/scripts/select-ccache-key-suffix.sh + + - name: Restore ccache + id: ccache + uses: actions/cache/restore@v6 + with: + path: .ccache + key: ccache-macos-${{ inputs.arch }}-appleclang-${{ github.sha }}${{ steps.ccache-key.outputs.suffix }} + restore-keys: | + ccache-macos-${{ inputs.arch }}-appleclang- + + - name: Configure ccache + run: | + echo "CCACHE_DIR=${GITHUB_WORKSPACE}/.ccache" >> "$GITHUB_ENV" + echo "ccache recache: ${{ inputs.recache }}" + if [ "${{ inputs.recache }}" = "true" ]; then + echo "CCACHE_RECACHE=1" >> "$GITHUB_ENV" + echo "Forcing ccache recache for this run" + fi + mkdir -p "${GITHUB_WORKSPACE}/.ccache" + ccache --version + ccache --zero-stats - name: Compute Qt cache key id: qt-key run: | .github/scripts/macos-qt-cache-key.sh \ --arch "${{ inputs.arch }}" \ - --runner "${{ inputs.runner }}" \ - --deployment-target "${{ inputs.deployment_target }}" \ + --runner "${{ env.RUNNER }}" \ + --deployment-target "${{ env.DEPLOYMENT_TARGET }}" \ --github-output - name: Restore Qt cache id: qt-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: qt-prefix key: ${{ steps.qt-key.outputs.key }} - fail-on-cache-miss: true - - name: Verify cached Qt deployment target + - name: Build Qt + if: steps.qt-cache.outputs.cache-hit != 'true' + run: | + .github/scripts/build-qt-macos.sh \ + --arch "${{ inputs.arch }}" \ + --deployment-target "${{ env.DEPLOYMENT_TARGET }}" \ + --prefix "${GITHUB_WORKSPACE}/qt-prefix" + + - name: Save Qt cache + if: steps.qt-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: qt-prefix + key: ${{ steps.qt-cache.outputs.cache-primary-key }} + + - name: Verify Qt prefix run: | .github/scripts/verify-macos-artifacts.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --allow-prefix "${GITHUB_WORKSPACE}/qt-prefix" \ "${GITHUB_WORKSPACE}/qt-prefix" @@ -111,7 +289,7 @@ jobs: if: inputs.arch == 'arm64' run: | .github/scripts/install-r-macos-gfortran.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --work-dir "${RUNNER_TEMP}/r-macos-gfortran" \ --prefix "${GITHUB_WORKSPACE}/gfortran-prefix" \ @@ -122,7 +300,7 @@ jobs: if: inputs.arch == 'x86_64' run: | .github/scripts/install-xpack-gfortran-macos.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --work-dir "${RUNNER_TEMP}/xpack-gfortran" \ --prefix "${GITHUB_WORKSPACE}/gfortran-prefix" \ @@ -162,206 +340,263 @@ jobs: echo "cache_key=${{ steps.controlled-arm-fc.outputs.cache_key }}" } >> "$GITHUB_OUTPUT" - - name: Verify static Fortran runtime deployment targets + - name: Verify static Fortran runtime run: | .github/scripts/verify-macos-static-archives.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --mode error \ ${{ steps.fc.outputs.runtime_archives }} - - name: Cache libusb + - name: Restore libusb cache id: libusb-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: libusb-prefix - key: libusb-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.0.27-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-libusb-macos.sh') }} + key: libusb-macos-${{ inputs.arch }}-${{ env.RUNNER }}-1.0.27-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-libusb-macos.sh') }} - name: Build libusb if: steps.libusb-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-libusb-macos.sh \ 1.0.27 \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/libusb-prefix" - name: Save libusb cache if: steps.libusb-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: libusb-prefix - key: libusb-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.0.27-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-libusb-macos.sh') }} - - - name: Cache Hamlib - id: hamlib-cache - uses: actions/cache/restore@v5 - with: - path: hamlib-prefix - key: hamlib-macos-${{ inputs.arch }}-${{ inputs.runner }}-${{ inputs.hamlib_branch }}-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-hamlib-macos.sh') }} + key: ${{ steps.libusb-cache.outputs.cache-primary-key }} - - name: Build Hamlib - if: steps.hamlib-cache.outputs.cache-hit != 'true' - env: - PKG_CONFIG_PATH: ${{ github.workspace }}/libusb-prefix/lib/pkgconfig - run: | - .github/scripts/build-hamlib-macos.sh \ - "${{ inputs.hamlib_branch }}" \ - "${{ inputs.deployment_target }}" \ - "${GITHUB_WORKSPACE}/hamlib-prefix" - - - name: Save Hamlib cache - if: steps.hamlib-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 - with: - path: hamlib-prefix - key: hamlib-macos-${{ inputs.arch }}-${{ inputs.runner }}-${{ inputs.hamlib_branch }}-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-hamlib-macos.sh') }} - - - name: Cache PortAudio + - name: Restore PortAudio cache id: portaudio-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: portaudio-prefix - key: portaudio-macos-${{ inputs.arch }}-${{ inputs.runner }}-19.7.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-portaudio-macos.sh') }} + key: portaudio-macos-${{ inputs.arch }}-${{ env.RUNNER }}-19.7.0-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-portaudio-macos.sh') }} - name: Build PortAudio if: steps.portaudio-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-portaudio-macos.sh \ 19.7.0 \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/portaudio-prefix" - name: Save PortAudio cache if: steps.portaudio-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: portaudio-prefix - key: portaudio-macos-${{ inputs.arch }}-${{ inputs.runner }}-19.7.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-portaudio-macos.sh') }} + key: ${{ steps.portaudio-cache.outputs.cache-primary-key }} - - name: Cache FFTW + - name: Restore FFTW cache id: fftw-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: fftw-prefix - key: fftw-macos-${{ inputs.arch }}-${{ inputs.runner }}-3.3.10-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-fftw-macos.sh') }} + key: fftw-macos-${{ inputs.arch }}-${{ env.RUNNER }}-3.3.10-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-fftw-macos.sh') }} - name: Build FFTW if: steps.fftw-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-fftw-macos.sh \ 3.3.10 \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/fftw-prefix" - name: Save FFTW cache if: steps.fftw-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: fftw-prefix - key: fftw-macos-${{ inputs.arch }}-${{ inputs.runner }}-3.3.10-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-fftw-macos.sh') }} + key: ${{ steps.fftw-cache.outputs.cache-primary-key }} - - name: Cache Boost + - name: Restore Boost cache id: boost-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: boost-prefix - key: boost-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.85.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-boost-macos.sh') }} + key: boost-macos-${{ inputs.arch }}-${{ env.RUNNER }}-${{ env.BOOST_VERSION }}-${{ env.BOOST_SOURCE_SHA256 }}-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-boost-macos.sh') }} - name: Build Boost if: steps.boost-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-boost-macos.sh \ - 1.85.0 \ + "${BOOST_VERSION}" \ + "${BOOST_SOURCE_SHA256}" \ "${{ inputs.arch }}" \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/boost-prefix" - name: Save Boost cache if: steps.boost-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: boost-prefix - key: boost-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.85.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-boost-macos.sh') }} - - - name: Configure - env: - PKG_CONFIG_PATH: ${{ github.workspace }}/qt-prefix/lib/pkgconfig:${{ github.workspace }}/boost-prefix/lib/pkgconfig:${{ github.workspace }}/fftw-prefix/lib/pkgconfig:${{ github.workspace }}/libusb-prefix/lib/pkgconfig:${{ github.workspace }}/portaudio-prefix/lib/pkgconfig:${{ github.workspace }}/hamlib-prefix/lib/pkgconfig - run: | - cmake -S . -B wsjtx-build \ - -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/qt-prefix;${GITHUB_WORKSPACE}/boost-prefix;${GITHUB_WORKSPACE}/fftw-prefix;${GITHUB_WORKSPACE}/libusb-prefix;${GITHUB_WORKSPACE}/portaudio-prefix;${GITHUB_WORKSPACE}/hamlib-prefix" \ - -DCMAKE_Fortran_COMPILER="${{ steps.fc.outputs.path }}" \ - -DCMAKE_Fortran_FLAGS="${{ steps.fc.outputs.fortran_runtime_flags }}" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ inputs.deployment_target }} \ - -DCMAKE_EXE_LINKER_FLAGS="-Wl,-headerpad_max_install_names ${{ steps.fc.outputs.runtime_link_flags }}" \ - -DWSJT_MACOS_LIBGOMP_LIBRARY="${{ steps.fc.outputs.libgomp }}" \ - -DWSJT_SOURCE_REVISION="${{ steps.source_revision.outputs.sha }}" \ - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ - -DWSJT_SKIP_MANPAGES=ON \ - -DWSJT_SKIP_BUNDLE_FIXUP=ON \ - -DWSJT_BUILD_TESTS=ON \ - -DWSJT_RELEASE_CHANNEL="${{ inputs.release_channel }}" \ - -DWSJT_RC_NUMBER="${{ inputs.rc_number }}" \ - -Wno-dev + key: ${{ steps.boost-cache.outputs.cache-primary-key }} - - name: Verify resolved dependency prefixes - run: | - CACHE=wsjtx-build/CMakeCache.txt - BAD=$(awk -F= ' - /^(Boost_DIR|Boost_INCLUDE_DIR|Boost_LOG_LIBRARY_RELEASE|Boost_LOG_SETUP_LIBRARY_RELEASE|FFTW3F_LIBRARY|FFTW3F_THREADS_LIBRARY|FFTW3_INCLUDE_DIR|Hamlib_INCLUDE_DIR|Hamlib_LIBRARY|Portaudio_INCLUDE_DIR|Portaudio_LIBRARY|Usb_INCLUDE_DIR|Usb_LIBRARY|Qt5[^:]*_DIR|Qt5[^:]*_EXECUTABLE):/ && $2 ~ /^(\/opt\/homebrew|\/usr\/local\/Cellar|\/usr\/local\/opt|\/opt\/local)/ { - print - } - ' "$CACHE") - if [ -n "$BAD" ]; then - echo "::error::Deployable macOS build resolved bundled dependencies from a package-manager prefix:" - echo "$BAD" - exit 1 - fi - - QT_BAD=$(awk -F= -v prefix="${GITHUB_WORKSPACE}/qt-prefix" ' - /^Qt5[^:]*_(DIR|EXECUTABLE):/ && index($2, prefix) != 1 { - print - } - ' "$CACHE") - if [ -n "$QT_BAD" ]; then - echo "::error::Deployable macOS build did not resolve Qt from the cached qt-prefix:" - echo "$QT_BAD" - exit 1 - fi - - - name: Verify built dependency deployment targets + - name: Verify pinned runtime prefixes run: | .github/scripts/verify-macos-artifacts.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ - --allow-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ - --allow-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ --allow-prefix "${GITHUB_WORKSPACE}/libusb-prefix" \ --allow-prefix "${GITHUB_WORKSPACE}/portaudio-prefix" \ - "${GITHUB_WORKSPACE}/boost-prefix" \ - "${GITHUB_WORKSPACE}/fftw-prefix" \ + --allow-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ + --allow-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ "${GITHUB_WORKSPACE}/libusb-prefix" \ - "${GITHUB_WORKSPACE}/portaudio-prefix" + "${GITHUB_WORKSPACE}/portaudio-prefix" \ + "${GITHUB_WORKSPACE}/fftw-prefix" \ + "${GITHUB_WORKSPACE}/boost-prefix" - - name: Verify Hamlib static archive deployment targets + - name: Restore Hamlib cache + id: hamlib-cache + uses: actions/cache/restore@v6 + with: + path: hamlib-prefix + key: hamlib-macos-${{ inputs.arch }}-${{ env.RUNNER }}-${{ inputs.hamlib_branch }}-libusb1.0.27-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-hamlib-macos.sh', '.github/scripts/build-libusb-macos.sh') }} + + - name: Build Hamlib + if: steps.hamlib-cache.outputs.cache-hit != 'true' + run: | + .github/scripts/build-hamlib-macos.sh \ + "${HAMLIB_BRANCH}" \ + "${DEPLOYMENT_TARGET}" \ + "${GITHUB_WORKSPACE}/hamlib-prefix" \ + "${GITHUB_WORKSPACE}/libusb-prefix" + + - name: Verify Hamlib prefix run: | - hamlib_archives=( "${GITHUB_WORKSPACE}/hamlib-prefix/lib/"*.a ) + test -f "${GITHUB_WORKSPACE}/hamlib-prefix/lib/libhamlib.a" .github/scripts/verify-macos-static-archives.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --mode error \ - "${hamlib_archives[@]}" + "${GITHUB_WORKSPACE}/hamlib-prefix/lib/libhamlib.a" + + - name: Save Hamlib cache + if: steps.hamlib-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: hamlib-prefix + key: ${{ steps.hamlib-cache.outputs.cache-primary-key }} + + - name: Restore pFUnit cache + id: pfunit-cache + uses: actions/cache/restore@v6 + with: + path: pfunit-prefix + key: pfunit-macos-${{ inputs.arch }}-${{ env.RUNNER }}-v4.14.0-${{ steps.fc.outputs.cache_key }}-min${{ env.DEPLOYMENT_TARGET }}-epoch3-${{ hashFiles('.github/scripts/build-pfunit-macos.sh') }} + + - name: Build pFUnit + if: steps.pfunit-cache.outputs.cache-hit != 'true' + env: + # pFUnit configure uses try_run probes; expose only the controlled + # compiler runtime for those probes, not for the final test binaries. + DYLD_LIBRARY_PATH: ${{ steps.fc.outputs.runtime_lib_dir }} + run: | + .github/scripts/build-pfunit-macos.sh \ + v4.14.0 \ + "${{ steps.fc.outputs.path }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ + "${GITHUB_WORKSPACE}/pfunit-prefix" + + - name: Locate pFUnit config + id: pfunit + run: | + CONFIG=$(find "${GITHUB_WORKSPACE}/pfunit-prefix" -name PFUNITConfig.cmake -print -quit) + if [ -z "$CONFIG" ]; then + echo "ERROR: PFUNITConfig.cmake not found under pfunit-prefix" + find "${GITHUB_WORKSPACE}/pfunit-prefix" -maxdepth 3 -type d + exit 1 + fi + PFUNIT_DIR="$(dirname "$CONFIG")" + echo "Found PFUNITConfig.cmake at: $CONFIG" + echo "dir=${PFUNIT_DIR}" >> "$GITHUB_OUTPUT" + + - name: Save pFUnit cache + if: steps.pfunit-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: pfunit-prefix + key: ${{ steps.pfunit-cache.outputs.cache-primary-key }} - - name: Build + - name: Configure build and tests + env: + PKG_CONFIG_PATH: ${{ github.workspace }}/qt-prefix/lib/pkgconfig:${{ github.workspace }}/boost-prefix/lib/pkgconfig:${{ github.workspace }}/fftw-prefix/lib/pkgconfig:${{ github.workspace }}/libusb-prefix/lib/pkgconfig:${{ github.workspace }}/portaudio-prefix/lib/pkgconfig:${{ github.workspace }}/hamlib-prefix/lib/pkgconfig:${{ github.workspace }}/pfunit-prefix/lib/pkgconfig + run: | + cmake -S . -B wsjtx-build \ + -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/qt-prefix;${GITHUB_WORKSPACE}/boost-prefix;${GITHUB_WORKSPACE}/fftw-prefix;${GITHUB_WORKSPACE}/libusb-prefix;${GITHUB_WORKSPACE}/portaudio-prefix;${GITHUB_WORKSPACE}/hamlib-prefix;${GITHUB_WORKSPACE}/pfunit-prefix" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_Fortran_COMPILER="${{ steps.fc.outputs.path }}" \ + -DCMAKE_Fortran_FLAGS="${{ steps.fc.outputs.fortran_runtime_flags }}" \ + -DCMAKE_EXE_LINKER_FLAGS="${{ steps.fc.outputs.runtime_link_flags }}" \ + -DCMAKE_INSTALL_RPATH="${GITHUB_WORKSPACE}/qt-prefix/lib;${GITHUB_WORKSPACE}/boost-prefix/lib;${GITHUB_WORKSPACE}/fftw-prefix/lib;${GITHUB_WORKSPACE}/libusb-prefix/lib;${GITHUB_WORKSPACE}/portaudio-prefix/lib;${GITHUB_WORKSPACE}/hamlib-prefix/lib" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.DEPLOYMENT_TARGET }} \ + -DWSJT_SKIP_MANPAGES=ON \ + -DWSJT_ENABLE_TESTS=ON \ + -DWSJT_ENABLE_GUI_SMOKE_TESTS=ON \ + -DWSJT_MACOS_LIBGOMP_LIBRARY="${{ steps.fc.outputs.libgomp }}" \ + -DPFUNIT_DIR="${{ steps.pfunit.outputs.dir }}" \ + -DWSJT_SOURCE_REVISION="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}" \ + -DWSJT_RELEASE_CHANNEL="${WSJT_RELEASE_CHANNEL}" \ + -DWSJT_RC_NUMBER="${WSJT_RC_NUMBER}" \ + -Wno-dev + + - name: Build and test targets run: cmake --build wsjtx-build -j"$(sysctl -n hw.ncpu)" + - name: Report suppressed ccache save + if: ${{ (inputs.save_ccache || inputs.recache) && github.ref != 'refs/heads/develop' }} + run: echo "::notice::Not saving ccache because shared compiler caches are published only from develop" + + - name: Save ccache + if: ${{ success() && (inputs.save_ccache || inputs.recache) && github.ref == 'refs/heads/develop' && steps.ccache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v6 + with: + path: .ccache + key: ${{ steps.ccache.outputs.cache-primary-key }} + + - name: Apply WSJT-X shared memory limits + run: | + python3 - <<'PY' + import plistlib + import subprocess + + expected_arguments = [ + "/usr/sbin/sysctl", + "kern.sysv.shmmax=52428800", + "kern.sysv.shmall=25600", + ] + + with open("Darwin/com.wsjtx.sysctl.plist", "rb") as source: + configuration = plistlib.load(source) + + if ( + configuration.get("Program") != expected_arguments[0] + or configuration.get("ProgramArguments") != expected_arguments + ): + raise SystemExit("shared memory plist does not match CI expectations") + + subprocess.run(["/usr/bin/sudo", *expected_arguments], check=True) + subprocess.run( + [expected_arguments[0], "kern.sysv.shmmax", "kern.sysv.shmall"], check=True + ) + PY + + - name: Raise shared memory total for parallel GUI tests + run: | + # Three decoder segments require 35,359 pages; leave headroom for other IPC. + sudo /usr/sbin/sysctl kern.sysv.shmall=40960 + /usr/sbin/sysctl kern.sysv.shmmax kern.sysv.shmall + - name: Run tests id: ctest - run: ctest --output-on-failure --output-junit ctest-results.xml + run: ctest --parallel 3 --output-on-failure --output-junit ctest-results.xml working-directory: wsjtx-build - name: Publish test summary @@ -371,23 +606,42 @@ jobs: - name: Upload test results if: always() && steps.ctest.conclusion != 'skipped' - continue-on-error: true uses: actions/upload-artifact@v7 with: name: ctest-results-macos-${{ inputs.arch }} path: wsjtx-build/ctest-results.xml if-no-files-found: ignore + - name: Upload WSJT-X startup diagnostics + if: failure() && steps.ctest.outcome == 'failure' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-startup-smoke-macos-${{ inputs.arch }} + path: wsjtx-build/startup-smoke-diagnostics + if-no-files-found: ignore + retention-days: 7 + + - name: Show ccache stats + if: always() + run: ccache --show-stats + - name: Verify architecture run: | file wsjtx-build/jt9 - lipo -archs wsjtx-build/jt9 | grep -q ${{ inputs.arch }} + ARCHS=$(lipo -archs wsjtx-build/jt9) + case " ${ARCHS} " in + *" ${{ inputs.arch }} "*) ;; + *) + echo "::error::Expected ${{ inputs.arch }} in jt9 architectures, found: ${ARCHS}" + exit 1 + ;; + esac - name: Install app bundle and collect CLI assets id: collect run: | BUILD=wsjtx-build - STAGE=stage/wsjtx-${{ inputs.version }}-${{ inputs.arch }} + STAGE="stage/wsjtx-${VERSION}-${ARCH}" ASSETS=assets mkdir -p "${ASSETS}" @@ -398,10 +652,13 @@ jobs: echo "::error::CMake install did not create ${APP}" exit 1 fi - if [ ! -x "${APP}/Contents/MacOS/map65" ]; then - echo "::error::CMake install did not create executable MAP65 companion app binary at ${APP}/Contents/MacOS/map65" - exit 1 - fi + + for bin in qmap map65; do + if [ ! -x "${APP}/Contents/MacOS/${bin}" ]; then + echo "::error::Expected app companion binary is missing after install: ${APP}/Contents/MacOS/${bin}" + exit 1 + fi + done for bin in jt9 wsprd wsprcode jt65code jt4code ft8code q65code encode77 fcal hash22calc; do [ -f "${BUILD}/${bin}" ] && cp "${BUILD}/${bin}" "${ASSETS}/" @@ -440,10 +697,6 @@ jobs: echo "::error::Expected CMake-installed alert sound is missing: ${SOUNDDIR}/Wanted.wav" exit 1 fi - if [ ! -x "${APP}/Contents/MacOS/map65" ]; then - echo "::error::Expected CMake-installed MAP65 binary is missing: ${APP}/Contents/MacOS/map65" - exit 1 - fi if [ -e "${APP}/Contents/MacOS/sounds" ]; then echo "::error::Alert sounds must not be installed under Contents/MacOS; codesign treats them as unsigned code." @@ -455,547 +708,114 @@ jobs: printf ' %s\n' "$@" echo "Verified CMake-installed alert sounds in ${SOUNDDIR}" - - name: Bundle dylibs into app - run: | - set -Eeuo pipefail - STAGE="${{ steps.collect.outputs.stage_dir }}" - APP="${STAGE}/wsjtx.app" - FRAMEWORKS="${APP}/Contents/Frameworks" - FORTRAN_PREFIX="${{ steps.fc.outputs.prefix }}" - FORTRAN_ORIGINAL_PREFIX="${{ steps.fc.outputs.original_prefix }}" - GCC_LIB="${{ steps.fc.outputs.runtime_lib_dir }}" - mkdir -p "${FRAMEWORKS}" - - dump_bundle_context() { - local status="$1" - local line="$2" - local command="$3" - echo "::error::Bundle dylibs into app failed at line ${line} with status ${status}: ${command}" - echo "APP=${APP}" - echo "FRAMEWORKS=${FRAMEWORKS}" - echo "FORTRAN_PREFIX=${FORTRAN_PREFIX}" - echo "FORTRAN_ORIGINAL_PREFIX=${FORTRAN_ORIGINAL_PREFIX}" - echo "GCC_LIB=${GCC_LIB}" - echo "HOMEBREW_PREFIX=${HOMEBREW_PREFIX}" - echo "App executable contents:" - ls -la "${APP}/Contents/MacOS" || true - echo "Framework contents:" - ls -la "${FRAMEWORKS}" || true - echo "External references in app executables:" - find "${APP}/Contents/MacOS" -type f -perm +111 -print -exec otool -L {} \; 2>/dev/null || true - if [ -f macdeployqt.log ]; then - echo "macdeployqt.log:" - cat macdeployqt.log - fi - } - trap 'status=$?; dump_bundle_context "$status" "$LINENO" "$BASH_COMMAND"; exit "$status"' ERR - - run_logged() { - echo "+ $*" - "$@" - } - - echo "Running macdeployqt..." - set +e - "${GITHUB_WORKSPACE}/qt-prefix/bin/macdeployqt" "${APP}" -verbose=2 > macdeployqt.log 2>&1 - status=$? - set -e - if [ "$status" -ne 0 ]; then - echo "::error::macdeployqt failed with status ${status}" - dump_bundle_context "$status" "$LINENO" "macdeployqt" - exit "$status" - fi - cat macdeployqt.log - - resolve_lib() { - local lib="$1" - if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$lib" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then - local original_prefix="${FORTRAN_ORIGINAL_PREFIX}/" - local relocated="${FORTRAN_PREFIX}/${lib:${#original_prefix}}" - [ -f "$relocated" ] && echo "$relocated" && return 0 - fi - if [[ "$lib" == $HOMEBREW_PREFIX/* ]]; then - echo "$lib" - return 0 - elif [[ "$lib" == $GITHUB_WORKSPACE/* ]]; then - echo "$lib" - return 0 - elif [[ "$lib" == @rpath/* ]]; then - local name="${lib#@rpath/}" - for dir in \ - "$FRAMEWORKS" \ - "$GITHUB_WORKSPACE/boost-prefix/lib" \ - "$GITHUB_WORKSPACE/fftw-prefix/lib" \ - "$GITHUB_WORKSPACE/libusb-prefix/lib" \ - "$GITHUB_WORKSPACE/portaudio-prefix/lib" \ - "$FORTRAN_PREFIX/lib" \ - "$GCC_LIB" \ - "$HOMEBREW_PREFIX/lib" - do - [ -f "$dir/$name" ] && echo "$dir/$name" && return - done - fi - return 0 - } - - should_bundle_ref() { - local ref="$1" - case "$ref" in - *Qt*.framework/*) - return 1 - ;; - "$FORTRAN_ORIGINAL_PREFIX"/*|"$HOMEBREW_PREFIX"/*|"$GITHUB_WORKSPACE"/*|@rpath/*) - return 0 - ;; - *) - return 1 - ;; - esac - } - - bundle_dylib() { - local binary="$1" - local lib - while IFS= read -r lib; do - should_bundle_ref "$lib" || continue - local resolved - resolved=$(resolve_lib "$lib") - if [ -z "$resolved" ]; then - echo "::error::Could not resolve ${lib} required by ${binary}" - exit 1 - fi - local libname - libname=$(basename "$resolved") - case "$libname" in - libgomp*.dylib) - echo "::error::Refusing to bundle ${resolved}; libgomp must be linked statically for deployable macOS artifacts." - exit 1 - ;; - esac - if [ ! -f "${FRAMEWORKS}/${libname}" ]; then - echo " Bundling: $resolved -> ${FRAMEWORKS}/${libname}" - run_logged cp "$resolved" "${FRAMEWORKS}/${libname}" - run_logged chmod 644 "${FRAMEWORKS}/${libname}" - run_logged install_name_tool -id "@rpath/${libname}" "${FRAMEWORKS}/${libname}" - bundle_dylib "${FRAMEWORKS}/${libname}" - fi - if [ "$lib" != "@rpath/${libname}" ]; then - run_logged install_name_tool -change "$lib" "@rpath/${libname}" "$binary" - fi - done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' || true) - } - - ensure_app_rpath() { - local binary="$1" - local rpath - - while IFS= read -r rpath; do - [ -n "$rpath" ] || continue - case "$rpath" in - "$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - run_logged install_name_tool -delete_rpath "$rpath" "$binary" - ;; - esac - done < <(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) - - if ! otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' | grep -Fxq "@executable_path/../Frameworks"; then - run_logged install_name_tool -add_rpath "@executable_path/../Frameworks" "$binary" - fi - } - - for exe in "${APP}/Contents/MacOS/"*; do - [ -f "$exe" ] && [ -x "$exe" ] && { - ensure_app_rpath "$exe" - bundle_dylib "$exe" - for fw in $(otool -L "$exe" | awk '{print $1}' | grep '\.framework/' || true); do - fwname=$(basename "$fw") - bundled=$(find "${FRAMEWORKS}" -name "${fwname}" -path "*.framework/*" 2>/dev/null | head -1) - if [ -n "$bundled" ]; then - app_contents="${APP}/Contents/" - fwrel="${bundled:${#app_contents}}" - if [ "$fw" != "@executable_path/../${fwrel}" ]; then - run_logged install_name_tool -change "$fw" "@executable_path/../${fwrel}" "$exe" - fi - fi - done - } - done - - for fw in "${FRAMEWORKS}"/*.dylib; do - [ -f "$fw" ] && bundle_dylib "$fw" - done - - for exe in "${APP}/Contents/MacOS/"*; do - [ -f "$exe" ] && [ -x "$exe" ] && bundle_dylib "$exe" - done - - echo "Checking for remaining external references..." - remaining_refs="${RUNNER_TEMP:-/tmp}/wsjtx-app-remaining-refs.txt" - : > "$remaining_refs" - while IFS= read -r binary; do - while IFS= read -r ref; do - case "$ref" in - "$FORTRAN_ORIGINAL_PREFIX"/*|"$HOMEBREW_PREFIX"/*|"$GITHUB_WORKSPACE"/*) - echo "${binary}: ${ref}" >> "$remaining_refs" - ;; - esac - done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' || true) - done < <(find "${APP}/Contents/MacOS" -type f -perm +111 -print 2>/dev/null) - if [ -s "$remaining_refs" ]; then - echo "::error::External build-time paths still present:" - cat "$remaining_refs" - exit 1 - else - echo "All dylibs bundled successfully" - fi - - - name: Bundle dylibs into CLI tools + - name: Deploy macOS app dependencies run: | - set -Eeuo pipefail - ASSETS="${{ steps.collect.outputs.assets_dir }}" - STAGE="${{ steps.collect.outputs.stage_dir }}" - LIBDIR="${ASSETS}/lib" - FORTRAN_PREFIX="${{ steps.fc.outputs.prefix }}" - FORTRAN_ORIGINAL_PREFIX="${{ steps.fc.outputs.original_prefix }}" - GCC_LIB="${{ steps.fc.outputs.runtime_lib_dir }}" - mkdir -p "${LIBDIR}" - - dump_cli_context() { - local status="$1" - local line="$2" - local command="$3" - echo "::error::Bundle dylibs into CLI tools failed at line ${line} with status ${status}: ${command}" - echo "ASSETS=${ASSETS}" - echo "LIBDIR=${LIBDIR}" - echo "FORTRAN_PREFIX=${FORTRAN_PREFIX}" - echo "FORTRAN_ORIGINAL_PREFIX=${FORTRAN_ORIGINAL_PREFIX}" - echo "GCC_LIB=${GCC_LIB}" - echo "HOMEBREW_PREFIX=${HOMEBREW_PREFIX}" - echo "Asset contents:" - ls -la "${ASSETS}" || true - echo "Library contents:" - ls -la "${LIBDIR}" || true - echo "External references in CLI assets:" - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] || continue - echo "== $bin ==" - otool -L "$bin" || true - done - } - trap 'status=$?; dump_cli_context "$status" "$LINENO" "$BASH_COMMAND"; exit "$status"' ERR - - run_logged() { - echo "+ $*" - "$@" - } - - resolve_cli_ref() { - local ref="$1" - local name="" suffix="" - - if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$ref" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then - local original_prefix="${FORTRAN_ORIGINAL_PREFIX}/" - local relocated="${FORTRAN_PREFIX}/${ref:${#original_prefix}}" - [ -f "$relocated" ] && echo "$relocated" - return 0 - fi - - case "$ref" in - /usr/lib/*|/System/Library/*) - return 0 - ;; - @loader_path/lib/*) - name="${ref#@loader_path/lib/}" - [ -f "${LIBDIR}/${name}" ] && echo "${LIBDIR}/${name}" - return 0 - ;; - @loader_path/*) - name="${ref#@loader_path/}" - [ -f "${LIBDIR}/${name}" ] && echo "${LIBDIR}/${name}" - return 0 - ;; - "$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - echo "$ref" - return 0 - ;; - esac - - if [[ "$ref" == @rpath/* ]]; then - suffix="${ref#@rpath/}" - if [[ "$suffix" == *.framework/* ]]; then - for dir in \ - "${STAGE}/wsjtx.app/Contents/Frameworks" \ - "${GITHUB_WORKSPACE}/qt-prefix/lib" - do - [ -f "${dir}/${suffix}" ] && echo "${dir}/${suffix}" && return 0 - done - else - name="${suffix}" - for dir in \ - "${LIBDIR}" \ - "${STAGE}/wsjtx.app/Contents/Frameworks" \ - "${GITHUB_WORKSPACE}/boost-prefix/lib" \ - "${GITHUB_WORKSPACE}/fftw-prefix/lib" \ - "${GITHUB_WORKSPACE}/libusb-prefix/lib" \ - "${GITHUB_WORKSPACE}/portaudio-prefix/lib" \ - "${FORTRAN_PREFIX}/lib" \ - "${GCC_LIB}" \ - "${HOMEBREW_PREFIX}/lib" - do - [ -f "${dir}/${name}" ] && echo "${dir}/${name}" && return 0 - done - fi - fi + .github/scripts/deploy-macos-app.sh \ + --app "${{ steps.collect.outputs.stage_dir }}/wsjtx.app" \ + --workspace-prefix "${GITHUB_WORKSPACE}" \ + --qt-prefix "${GITHUB_WORKSPACE}/qt-prefix" \ + --boost-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ + --fftw-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ + --libusb-prefix "${GITHUB_WORKSPACE}/libusb-prefix" \ + --portaudio-prefix "${GITHUB_WORKSPACE}/portaudio-prefix" \ + --fortran-prefix "${{ steps.fc.outputs.prefix }}" \ + --fortran-original-prefix "${{ steps.fc.outputs.original_prefix }}" \ + --gcc-lib "${{ steps.fc.outputs.runtime_lib_dir }}" \ + --homebrew-prefix "${HOMEBREW_PREFIX}" - return 0 - } - - bundle_cli_deps() { - local binary="$1" - local change_prefix="$2" - local ref resolved out name target - - while IFS= read -r ref; do - resolved=$(resolve_cli_ref "$ref") - if [ -z "$resolved" ]; then - case "$ref" in - @rpath/*|@loader_path/*|"$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - echo "::error::Could not resolve ${ref} required by ${binary}" - exit 1 - ;; - *) - continue - ;; - esac - fi - - name="$(basename "$resolved")" - case "$name" in - libgomp*.dylib) - echo "::error::Refusing to bundle ${resolved}; libgomp must be linked statically for deployable macOS artifacts." - exit 1 - ;; - esac - - out="${LIBDIR}/${name}" - if [ ! -f "$out" ]; then - echo " Bundling: ${resolved} -> ${out}" - run_logged cp "$resolved" "$out" - run_logged chmod 644 "$out" - run_logged install_name_tool -id "@rpath/${name}" "$out" - bundle_cli_deps "$out" "@rpath" - fi - - target="${change_prefix}/${name}" - if [ "$ref" != "$target" ]; then - run_logged install_name_tool -change "$ref" "$target" "$binary" - fi - done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' | grep -E "($HOMEBREW_PREFIX|$GITHUB_WORKSPACE|@rpath|@loader_path)" || true) - } - - ensure_cli_rpath() { - local binary="$1" - local rpath - local bad_rpaths=() - local unique_bad_rpaths=() - - while IFS= read -r rpath; do - [ -n "$rpath" ] || continue - case "$rpath" in - "$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - bad_rpaths+=("$rpath") - ;; - esac - done < <(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) - - # Deduplicate bad rpaths (compatible with macOS Bash 3.2) - if [ "${#bad_rpaths[@]}" -gt 0 ]; then - for rpath in "${bad_rpaths[@]}"; do - local found=0 - local u - if [ "${#unique_bad_rpaths[@]}" -gt 0 ]; then - for u in "${unique_bad_rpaths[@]}"; do - [ "$u" = "$rpath" ] && found=1 && break - done - fi - [ "$found" -eq 0 ] && unique_bad_rpaths+=("$rpath") - done - fi - - if [ "${#unique_bad_rpaths[@]}" -gt 0 ]; then - for rpath in "${unique_bad_rpaths[@]}"; do - run_logged install_name_tool -delete_rpath "$rpath" "$binary" - done - fi - - if ! otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' | grep -Fxq "@loader_path/lib"; then - run_logged install_name_tool -add_rpath "@loader_path/lib" "$binary" + APP="${{ steps.collect.outputs.stage_dir }}/wsjtx.app" + for file in \ + "${APP}/Contents/PlugIns/platforms/libqcocoa.dylib" \ + "${APP}/Contents/Resources/qt.conf" + do + if [ ! -f "$file" ]; then + echo "::error::Expected macOS app deployment file is missing: ${file}" + exit 1 fi - } - - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] || continue - ensure_cli_rpath "$bin" - bundle_cli_deps "$bin" "@rpath" - run_logged codesign --force --sign - "$bin" - done - - for lib in "${LIBDIR}"/*; do - [ -f "$lib" ] || continue - bundle_cli_deps "$lib" "@rpath" - run_logged codesign --force --sign - "$lib" done - echo "Verifying CLI tools..." - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] && { - BAD=$(otool -L "$bin" | grep "$HOMEBREW_PREFIX" || true) - if [ -n "$BAD" ]; then - echo "ERROR: $(basename "$bin") still has Homebrew refs:" - echo "$BAD" - exit 1 - fi - } - done - echo "All CLI tools are self-contained" - - cp -R "${LIBDIR}" "${STAGE}/lib" - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] && { - cp "$bin" "${STAGE}/$(basename "$bin")" - } - done + - name: Deploy macOS CLI tool dependencies + run: | + .github/scripts/deploy-macos-cli-tools.sh \ + --assets "${{ steps.collect.outputs.assets_dir }}" \ + --stage "${{ steps.collect.outputs.stage_dir }}" \ + --workspace-prefix "${GITHUB_WORKSPACE}" \ + --boost-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ + --fftw-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ + --libusb-prefix "${GITHUB_WORKSPACE}/libusb-prefix" \ + --portaudio-prefix "${GITHUB_WORKSPACE}/portaudio-prefix" \ + --fortran-prefix "${{ steps.fc.outputs.prefix }}" \ + --fortran-original-prefix "${{ steps.fc.outputs.original_prefix }}" \ + --gcc-lib "${{ steps.fc.outputs.runtime_lib_dir }}" \ + --homebrew-prefix "${HOMEBREW_PREFIX}" - name: Verify bundled macOS deployment targets run: | STAGE="${{ steps.collect.outputs.stage_dir }}" .github/scripts/verify-macos-artifacts.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ "$STAGE" - - name: Import signing certificates - if: steps.check_secrets.outputs.signing_enabled == 'true' - env: - APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} - APP_P12_PW: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }} - INST_P12: ${{ secrets.DEVELOPER_ID_INSTALLER_P12 }} - INST_P12_PW: ${{ secrets.DEVELOPER_ID_INSTALLER_PASSWORD }} - run: | - KEYCHAIN_PATH="$RUNNER_TEMP/signing.keychain-db" - KEYCHAIN_PASSWORD="$(openssl rand -hex 16)" - - security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH" - security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - - echo "$APP_P12" | base64 --decode > "$RUNNER_TEMP/app.p12" - security import "$RUNNER_TEMP/app.p12" -P "$APP_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" - - echo "$INST_P12" | base64 --decode > "$RUNNER_TEMP/installer.p12" - security import "$RUNNER_TEMP/installer.p12" -P "$INST_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" - - security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - security list-keychains -d user -s "$KEYCHAIN_PATH" login.keychain-db - - APP_IDENTITY=$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" | grep "Developer ID Application" | head -1 | awk -F'"' '{print $2}') - INST_IDENTITY=$(security find-identity -v "$KEYCHAIN_PATH" | grep "Developer ID Installer" | head -1 | awk -F'"' '{print $2}') - echo "App identity: $APP_IDENTITY" - echo "Installer identity: $INST_IDENTITY" - echo "identity=$APP_IDENTITY" >> "$GITHUB_OUTPUT" - echo "installer_identity=$INST_IDENTITY" >> "$GITHUB_OUTPUT" - id: keychain - - # ALWAYS runs. Real Developer ID when secrets are present, ad-hoc - # signing (-) otherwise. Mirrors the Windows self-signed-sandbox - # pattern in build-windows.yml: prove the signing step is wired, - # rely on a real cert in production. Ad-hoc signing produces a - # structurally-valid signature with no Apple trust chain — pkg - # will not pass Gatekeeper without right-click→Open, but is - # well-formed and the all-platforms-ready gate in release.yml - # finds the artifact at the expected path. - - name: Code sign binaries + - name: Ad-hoc sign binaries for build validation run: | STAGE="${{ steps.collect.outputs.stage_dir }}" ASSETS="${{ steps.collect.outputs.assets_dir }}" APP="${STAGE}/wsjtx.app" ENTITLEMENTS="${GITHUB_WORKSPACE}/entitlements.plist" - if [ "${{ steps.check_secrets.outputs.signing_enabled }}" = "true" ]; then - IDENTITY="${{ steps.keychain.outputs.identity }}" - TS="--timestamp" - echo "Code signing mode: Developer ID (real)" - else - IDENTITY="-" - TS="" - echo "Code signing mode: ad-hoc (no Apple trust chain; pkg will be unsigned)" - fi + IDENTITY="-" + echo "Code signing mode: ad-hoc (no Apple trust chain; pkg will be unsigned)" - # entitlements.plist declares com.apple.security.cs.disable- - # library-validation, which is required for any app bundling - # its own non-system frameworks (Qt, etc.) under hardened - # runtime — otherwise dyld refuses to load them. Applied on - # both signing paths: the real-cert path needs it for - # notarization-friendly distribution; the ad-hoc path needs - # it because each ad-hoc signature has its own pseudo-Team-ID - # so the main binary and bundled frameworks never match. - # (The plist is non-empty, so macos-15-intel's codesign now - # parses it cleanly — no need for the conditional that PR #23 - # introduced as a workaround for the empty-plist parser bug.) + # Sign nested code before the containing bundle. Executable + # entitlements are defined in the repository-root plist. find "${APP}/Contents/Frameworks" -type f \( -name "*.dylib" -o -perm +111 \) \ - -exec codesign --force --options runtime $TS --sign "$IDENTITY" {} \; + -exec codesign --force --options runtime --sign "$IDENTITY" {} \; find "${APP}/Contents/Frameworks" -name "*.framework" -type d | while read -r fw; do - codesign --force --options runtime $TS --sign "$IDENTITY" "$fw" + codesign --force --options runtime --sign "$IDENTITY" "$fw" done - if [ -d "${APP}/Contents/PlugIns" ]; then - find "${APP}/Contents/PlugIns" -type f -name "*.dylib" \ - -exec codesign --force --options runtime $TS --sign "$IDENTITY" {} \; - fi + find "${APP}/Contents/PlugIns" -type f -name "*.dylib" \ + -exec codesign --force --options runtime --sign "$IDENTITY" {} \; 2>/dev/null || true find "${APP}/Contents/MacOS" -type f -perm +111 \ - -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" $TS --sign "$IDENTITY" {} \; - # Bundle-level codesign re-signs the main executable. --force - # without --entitlements would WIPE the entitlements applied - # in the previous step (PR #27 missed this — rc1 shipped with - # an unentitled wsjtx binary, so disable-library-validation - # never took effect and the dyld load of QtSerialPort still - # failed with mismatched Team IDs). - codesign --force --options runtime --entitlements "$ENTITLEMENTS" $TS --sign "$IDENTITY" "${APP}" + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$IDENTITY" {} \; + # Bundle signing re-signs the main executable, so it must receive the + # entitlement file again. + codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$IDENTITY" "${APP}" codesign --verify --deep --strict --verbose=2 "${APP}" - # Defensive: confirm the entitlement actually made it onto - # the main binary. `codesign --verify` doesn't check - # entitlement presence — it only validates the signature - # itself — so a re-sign that wipes entitlements would still - # pass verify (that's how rc1 shipped broken). + # codesign --verify validates the signature, not required entitlement + # presence. MAIN_BIN="${APP}/Contents/MacOS/wsjtx" - if ! codesign -d --entitlements - "$MAIN_BIN" 2>/dev/null | grep -q "disable-library-validation"; then + ENTITLEMENTS_OUT=$(codesign -d --entitlements - "$MAIN_BIN" 2>/dev/null) + if [[ "$ENTITLEMENTS_OUT" != *"disable-library-validation"* ]]; then echo "::error::wsjtx binary is missing com.apple.security.cs.disable-library-validation entitlement." echo "::error::Bundled Qt frameworks will fail to load under hardened runtime." codesign -d --entitlements - "$MAIN_BIN" || true exit 1 fi echo "Confirmed disable-library-validation entitlement on $MAIN_BIN" + if [[ "$ENTITLEMENTS_OUT" == *"allow-unsigned-executable-memory"* ]]; then + echo "::error::${MAIN_BIN} must not grant unsigned executable memory." + exit 1 + fi + echo "Confirmed no unsigned executable memory entitlement on $MAIN_BIN" for dir in "${STAGE}" "${ASSETS}"; do find "${dir}" -maxdepth 1 -type f -perm +111 \ - -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" $TS --sign "$IDENTITY" {} \; + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$IDENTITY" {} \; done for dir in "${STAGE}/lib" "${ASSETS}/lib"; do [ -d "$dir" ] && find "$dir" -type f \ - -exec codesign --force --options runtime $TS --sign "$IDENTITY" {} \; + -exec codesign --force --options runtime --sign "$IDENTITY" {} \; done - # ALWAYS runs. productbuild signs with the Developer ID Installer - # cert when secrets are present; produces an unsigned .pkg - # otherwise. Either way the artifact is named identically and - # satisfies the all-platforms-ready gate in release.yml. - - name: Build and verify installer pkg + - name: Prepare installer package run: | STAGE="${{ steps.collect.outputs.stage_dir }}" - PKG_ID="org.k1jt.wsjtx.${{ inputs.arch }}" - PKG_VERSION="${{ inputs.version }}" + PKG_ID="org.k1jt.wsjtx.${ARCH}" + PKG_VERSION="${VERSION}" PAYLOAD="$RUNNER_TEMP/pkg-payload" SCRIPTS="$RUNNER_TEMP/pkg-scripts" @@ -1036,134 +856,103 @@ jobs: --install-location / \ "$RUNNER_TEMP/wsjtx-component.pkg" - PKG_OUT="wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg" - if [ "${{ steps.check_secrets.outputs.signing_enabled }}" = "true" ]; then - INST_IDENTITY="${{ steps.keychain.outputs.installer_identity }}" - productbuild \ - --package "$RUNNER_TEMP/wsjtx-component.pkg" \ - --sign "$INST_IDENTITY" \ - "$PKG_OUT" - else - productbuild \ - --package "$RUNNER_TEMP/wsjtx-component.pkg" \ - "$PKG_OUT" - fi - + - name: Build unsigned validation package + if: inputs.signing_mode == 'validation' + id: package + run: | + PKG_OUT="wsjtx-${VERSION}-${ARCH}-macOS.pkg" + productbuild \ + --package "$RUNNER_TEMP/wsjtx-component.pkg" \ + "$PKG_OUT" + echo "path=$PKG_OUT" >> "$GITHUB_OUTPUT" + echo "artifact_name=wsjtx-${VERSION}-${ARCH}-macOS-unsigned.pkg" >> "$GITHUB_OUTPUT" + + - name: Verify unsigned validation package + if: inputs.signing_mode == 'validation' + run: | + PKG_OUT="${{ steps.package.outputs.path }}" CHECK_PAYLOAD="$RUNNER_TEMP/pkg-check" - rm -rf "$CHECK_PAYLOAD" pkgutil --expand-full "$PKG_OUT" "$CHECK_PAYLOAD" [ "$(/usr/libexec/PlistBuddy -c "Print :0:BundleIsRelocatable" "$RUNNER_TEMP/components.plist")" = "false" ] [ "$(/usr/libexec/PlistBuddy -c "Print :0:BundleIsVersionChecked" "$RUNNER_TEMP/components.plist")" = "false" ] [ "$(/usr/libexec/PlistBuddy -c "Print :0:BundleOverwriteAction" "$RUNNER_TEMP/components.plist")" = "upgrade" ] - + test -x "$CHECK_PAYLOAD/wsjtx-component.pkg/Payload/Applications/wsjtx.app/Contents/MacOS/qmap" + test -x "$CHECK_PAYLOAD/wsjtx-component.pkg/Payload/Applications/wsjtx.app/Contents/MacOS/map65" APP_PAYLOAD="$CHECK_PAYLOAD/wsjtx-component.pkg/Payload/Applications/wsjtx.app" - DATADIR="${APP_PAYLOAD}/Contents/Resources/wsjtx" - DOCDIR="${APP_PAYLOAD}/Contents/Resources/doc/wsjtx" SOUNDDIR="${APP_PAYLOAD}/Contents/Resources/sounds" - - for file in cty.dat cty.dat_copyright.txt grid.dat sat.dat eclipse.txt ALLCALL7.TXT JPLEPH; do - if [ ! -f "${DATADIR}/${file}" ]; then - echo "::error::Expected packaged data file is missing: ${DATADIR}/${file}" - exit 1 - fi - done - - set -- "${DOCDIR}/wsjtx-main"*.html + set -- "${APP_PAYLOAD}/Contents/Resources/doc/wsjtx/wsjtx-main"*.html if [ "$#" -lt 1 ] || [ ! -f "$1" ]; then echo "::error::Expected at least one local user guide in the packaged app bundle." printf 'Matched paths:\n' printf ' %s\n' "$@" exit 1 fi - if [ ! -f "${SOUNDDIR}/Wanted.wav" ]; then echo "::error::Expected packaged alert sound is missing: ${SOUNDDIR}/Wanted.wav" exit 1 fi - if [ ! -x "${APP_PAYLOAD}/Contents/MacOS/map65" ]; then - echo "::error::Expected packaged MAP65 binary is missing: ${APP_PAYLOAD}/Contents/MacOS/map65" - exit 1 - fi - if [ -e "${APP_PAYLOAD}/Contents/MacOS/sounds" ]; then echo "::error::Packaged alert sounds must not be under Contents/MacOS." exit 1 fi - - echo "Verified packaged local user guides:" - printf ' %s\n' "$@" echo "Verified packaged alert sounds in ${SOUNDDIR}" + .github/scripts/verify-macos-artifacts.sh \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ + --arch "${{ inputs.arch }}" \ + "$CHECK_PAYLOAD/wsjtx-component.pkg/Payload" - - name: Notarize pkg - if: steps.check_secrets.outputs.signing_enabled == 'true' - env: - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + - name: Stage distribution signing input + if: inputs.signing_mode == 'distribution' run: | - notarize_and_staple() { - local file="$1" - echo "Notarizing: $file" - xcrun notarytool submit "$file" \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" \ - --wait 2>&1 | tee notarize.log - - if grep -q "status: Invalid" notarize.log; then - SUBMISSION_ID=$(grep "id:" notarize.log | head -1 | awk '{print $2}') - xcrun notarytool log "$SUBMISSION_ID" \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" || true - exit 1 - fi - - xcrun stapler staple "$file" - } + mkdir -p distribution-signing-input + cp "${{ runner.temp }}/wsjtx-component.pkg" distribution-signing-input/ + cp "${{ runner.temp }}/components.plist" distribution-signing-input/ + cp entitlements.plist distribution-signing-input/ - notarize_and_staple "wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg" + - name: Upload distribution signing input + if: inputs.signing_mode == 'distribution' + uses: actions/upload-artifact@v7 + with: + name: macos-signing-input-${{ inputs.version }}-${{ inputs.arch }} + path: distribution-signing-input + retention-days: 1 - - name: Notarize CLI tools - if: steps.check_secrets.outputs.signing_enabled == 'true' - env: - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + - name: Write validation signing report + if: inputs.signing_mode == 'validation' run: | - ASSETS="${{ steps.collect.outputs.assets_dir }}" - zip -r cli-tools.zip "${ASSETS}"/ - xcrun notarytool submit cli-tools.zip \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" \ - --wait 2>&1 | tee notarize-cli.log - - if grep -q "status: Invalid" notarize-cli.log; then - SUBMISSION_ID=$(grep "id:" notarize-cli.log | head -1 | awk '{print $2}') - xcrun notarytool log "$SUBMISSION_ID" \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" || true + PKG_OUT="${{ steps.package.outputs.path }}" + PKG_SIGNATURE=$(pkgutil --check-signature "$PKG_OUT" 2>&1 || true) + printf '%s\n' "$PKG_SIGNATURE" + if [[ "$PKG_SIGNATURE" != *"Status: no signature"* ]]; then + echo "::error::Validation package did not report the expected unsigned status." exit 1 fi - rm cli-tools.zip - - - name: Clean up keychain - if: always() && steps.check_secrets.outputs.signing_enabled == 'true' - run: security delete-keychain "$RUNNER_TEMP/signing.keychain-db" 2>/dev/null || true + SHA256=$(shasum -a 256 "$PKG_OUT" | awk '{print $1}') + jq -n \ + --arg mode validation \ + --arg artifact "$PKG_OUT" \ + --arg sha256 "$SHA256" \ + --arg git_sha "$GITHUB_SHA" \ + '{schema_version: 1, mode: $mode, artifact: $artifact, sha256: $sha256, git_sha: $git_sha, signed: false, notarized: false, publishable: false}' \ + > macos-signing-report.json - name: Upload pkg + if: inputs.signing_mode == 'validation' + uses: actions/upload-artifact@v7 + with: + name: ${{ steps.package.outputs.artifact_name }} + path: ${{ steps.package.outputs.path }} + + - name: Upload signing report + if: inputs.signing_mode == 'validation' uses: actions/upload-artifact@v7 with: - name: wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg - path: wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg + name: macos-signing-report-${{ inputs.version }}-${{ inputs.arch }} + path: macos-signing-report.json - name: Package individual binaries run: | - # Tarball and inner-dir names include the arch suffix so arm64 - # and x86_64 per-binary artifacts can coexist in a single - # GitHub Release without ReleaseAsset.name collisions (#24). + # Architecture-qualified names prevent release-asset collisions. ASSETS="${{ steps.collect.outputs.assets_dir }}" ARCH="${{ inputs.arch }}" PKGS=packages @@ -1185,3 +974,260 @@ jobs: with: name: individual-binaries-macos-${{ inputs.arch }} path: packages/*.tar.gz + + # Keep repository-built code after signing, notarization, cleanup, and + # artifact publication so a detached child cannot reach later secrets. + - name: Smoke-launch deployed WSJT-X app + id: deployed_wsjtx_smoke + timeout-minutes: 1 + run: | + APP="${GITHUB_WORKSPACE}/${{ steps.collect.outputs.stage_dir }}/wsjtx.app" + DIAGNOSTICS="${GITHUB_WORKSPACE}/wsjtx-build/deployed-startup-smoke-diagnostics" + + unset DYLD_LIBRARY_PATH + unset DYLD_FRAMEWORK_PATH + unset DYLD_INSERT_LIBRARIES + unset DYLD_ROOT_PATH + unset DYLD_IMAGE_SUFFIX + unset QT_PLUGIN_PATH + unset QT_QPA_PLATFORM_PLUGIN_PATH + unset QML_IMPORT_PATH + unset QML2_IMPORT_PATH + + export DYLD_FALLBACK_LIBRARY_PATH="/usr/lib" + export DYLD_FALLBACK_FRAMEWORK_PATH="/System/Library/Frameworks" + export QT_QPA_PLATFORM="cocoa" + export PATH="/usr/bin:/bin:/usr/sbin:/sbin" + + cd "$RUNNER_TEMP" + /bin/bash "${GITHUB_WORKSPACE}/test/run-wsjtx-startup-macos.sh" \ + "$DIAGNOSTICS" \ + "${APP}/Contents/MacOS/wsjtx" \ + --startup-smoke-test \ + --rig-name CI-DEPLOYED-STARTUP + + - name: Upload deployed WSJT-X startup diagnostics + if: failure() && steps.deployed_wsjtx_smoke.outcome == 'failure' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-deployed-startup-smoke-macos-${{ inputs.arch }} + path: wsjtx-build/deployed-startup-smoke-diagnostics + if-no-files-found: ignore + retention-days: 7 + + sign_distribution: + if: inputs.signing_mode == 'distribution' + needs: build + runs-on: ${{ inputs.runner || (inputs.arch == 'x86_64' && 'macos-15-intel' || 'macos-15') }} + timeout-minutes: 30 + environment: apple-release-signing + env: + VERSION: ${{ inputs.version }} + ARCH: ${{ inputs.arch }} + APPLE_TEAM_ID: ${{ inputs.apple_team_id || vars.APPLE_TEAM_ID }} + APP_CERT_SHA1: ${{ inputs.application_certificate_sha1 || vars.APPLE_APPLICATION_CERTIFICATE_SHA1 }} + INST_CERT_SHA1: ${{ inputs.installer_certificate_sha1 || vars.APPLE_INSTALLER_CERTIFICATE_SHA1 }} + steps: + - name: Validate distribution credentials + env: + APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} + APP_P12_PW: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }} + INST_P12: ${{ secrets.DEVELOPER_ID_INSTALLER_P12 }} + INST_P12_PW: ${{ secrets.DEVELOPER_ID_INSTALLER_PASSWORD }} + ASC_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} + ASC_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} + ASC_PRIVATE_KEY_P8_BASE64: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY_P8_BASE64 }} + run: | + missing=() + for name in APP_P12 APP_P12_PW INST_P12 INST_P12_PW ASC_KEY_ID ASC_ISSUER_ID ASC_PRIVATE_KEY_P8_BASE64 APPLE_TEAM_ID APP_CERT_SHA1 INST_CERT_SHA1; do + [ -n "${!name}" ] || missing+=("$name") + done + if [ "${#missing[@]}" -ne 0 ]; then + printf '::error::Distribution signing is missing required credentials or identity configuration: %s\n' "${missing[*]}" + exit 1 + fi + + - name: Download unsigned component package + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + name: macos-signing-input-${{ inputs.version }}-${{ inputs.arch }} + path: signing-input + + - name: Expand signing input without executing it + run: | + pkgutil --expand-full signing-input/wsjtx-component.pkg "$RUNNER_TEMP/expanded-component" + test -d "$RUNNER_TEMP/expanded-component/Payload/Applications/wsjtx.app" + test -d "$RUNNER_TEMP/expanded-component/Payload/usr/local/wsjtx" + + - name: Import and verify Developer ID identities + id: identities + env: + APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} + APP_P12_PW: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }} + INST_P12: ${{ secrets.DEVELOPER_ID_INSTALLER_P12 }} + INST_P12_PW: ${{ secrets.DEVELOPER_ID_INSTALLER_PASSWORD }} + run: | + KEYCHAIN_PATH="$RUNNER_TEMP/release-signing.keychain-db" + KEYCHAIN_PASSWORD="$(openssl rand -hex 16)" + security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + security set-keychain-settings -lut 1800 "$KEYCHAIN_PATH" + security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + printf '%s' "$APP_P12" | base64 --decode > "$RUNNER_TEMP/app.p12" + printf '%s' "$INST_P12" | base64 --decode > "$RUNNER_TEMP/installer.p12" + security import "$RUNNER_TEMP/app.p12" -P "$APP_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" + security import "$RUNNER_TEMP/installer.p12" -P "$INST_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" + rm -f "$RUNNER_TEMP/app.p12" "$RUNNER_TEMP/installer.p12" + security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + security list-keychains -d user -s "$KEYCHAIN_PATH" login.keychain-db + + APP_IDENTITY=$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" | awk -F'"' '/Developer ID Application/ {print $2; exit}') + INST_IDENTITY=$(security find-identity -v "$KEYCHAIN_PATH" | awk -F'"' '/Developer ID Installer/ {print $2; exit}') + [ -n "$APP_IDENTITY" ] || { echo "::error::No Developer ID Application identity was imported."; exit 1; } + [ -n "$INST_IDENTITY" ] || { echo "::error::No Developer ID Installer identity was imported."; exit 1; } + [[ "$APP_IDENTITY" == *"(${APPLE_TEAM_ID})"* ]] || { echo "::error::Application identity is not owned by the expected team."; exit 1; } + [[ "$INST_IDENTITY" == *"(${APPLE_TEAM_ID})"* ]] || { echo "::error::Installer identity is not owned by the expected team."; exit 1; } + + app_actual=$(security find-certificate -c "$APP_IDENTITY" -Z "$KEYCHAIN_PATH" | awk '/SHA-1 hash:/ {print toupper($3); exit}') + inst_actual=$(security find-certificate -c "$INST_IDENTITY" -Z "$KEYCHAIN_PATH" | awk '/SHA-1 hash:/ {print toupper($3); exit}') + app_expected=$(printf '%s' "$APP_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]') + inst_expected=$(printf '%s' "$INST_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]') + [ "$app_actual" = "$app_expected" ] || { echo "::error::Application certificate fingerprint mismatch."; exit 1; } + [ "$inst_actual" = "$inst_expected" ] || { echo "::error::Installer certificate fingerprint mismatch."; exit 1; } + echo "application=$APP_IDENTITY" >> "$GITHUB_OUTPUT" + echo "installer=$INST_IDENTITY" >> "$GITHUB_OUTPUT" + + - name: Sign staged application and command-line tools + env: + APP_IDENTITY: ${{ steps.identities.outputs.application }} + run: | + PAYLOAD="$RUNNER_TEMP/expanded-component/Payload" + APP="$PAYLOAD/Applications/wsjtx.app" + ENTITLEMENTS="$GITHUB_WORKSPACE/signing-input/entitlements.plist" + test -f "$ENTITLEMENTS" + + find "$APP/Contents/Frameworks" -type f \( -name "*.dylib" -o -perm +111 \) \ + -exec codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" {} \; + find "$APP/Contents/Frameworks" -name "*.framework" -type d | while read -r framework; do + codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" "$framework" + done + find "$APP/Contents/PlugIns" -type f -name "*.dylib" \ + -exec codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" {} \; + find "$APP/Contents/MacOS" -type f -perm +111 \ + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --timestamp --sign "$APP_IDENTITY" {} \; + codesign --force --options runtime --entitlements "$ENTITLEMENTS" --timestamp --sign "$APP_IDENTITY" "$APP" + + find "$PAYLOAD/usr/local/wsjtx" -maxdepth 1 -type f -perm +111 \ + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --timestamp --sign "$APP_IDENTITY" {} \; + [ ! -d "$PAYLOAD/usr/local/wsjtx/lib" ] || find "$PAYLOAD/usr/local/wsjtx/lib" -type f \ + -exec codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" {} \; + codesign --verify --deep --strict --verbose=2 "$APP" + + - name: Build signed distribution package + id: package + env: + INST_IDENTITY: ${{ steps.identities.outputs.installer }} + run: | + COMPONENT="$RUNNER_TEMP/wsjtx-signed-component.pkg" + pkgbuild \ + --root "$RUNNER_TEMP/expanded-component/Payload" \ + --scripts "$RUNNER_TEMP/expanded-component/Scripts" \ + --component-plist "$GITHUB_WORKSPACE/signing-input/components.plist" \ + --identifier "org.k1jt.wsjtx.${ARCH}" \ + --version "$VERSION" \ + --install-location / \ + "$COMPONENT" + pkgutil --payload-files "$COMPONENT" >/dev/null + PKG_OUT="wsjtx-${VERSION}-${ARCH}-macOS.pkg" + productbuild \ + --package "$COMPONENT" \ + --sign "$INST_IDENTITY" \ + "$PKG_OUT" + echo "path=$PKG_OUT" >> "$GITHUB_OUTPUT" + + - name: Verify rebuilt distribution package + run: | + PKG_OUT="${{ steps.package.outputs.path }}" + CHECK_PACKAGE="$RUNNER_TEMP/signed-package-check" + pkgutil --expand-full "$PKG_OUT" "$CHECK_PACKAGE" + COMPONENT="$CHECK_PACKAGE/wsjtx-signed-component.pkg" + PAYLOAD="$COMPONENT/Payload" + APP="$PAYLOAD/Applications/wsjtx.app" + test -x "$APP/Contents/MacOS/qmap" + test -x "$APP/Contents/MacOS/map65" + test -x "$COMPONENT/Scripts/postinstall" + test -d "$PAYLOAD/usr/local/wsjtx" + codesign --verify --deep --strict --verbose=2 "$APP" + + - name: Notarize and staple distribution package + id: notarize + env: + ASC_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} + ASC_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} + ASC_PRIVATE_KEY_P8_BASE64: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY_P8_BASE64 }} + run: | + KEY_PATH="$RUNNER_TEMP/AuthKey_${ASC_KEY_ID}.p8" + printf '%s' "$ASC_PRIVATE_KEY_P8_BASE64" | base64 --decode > "$KEY_PATH" + chmod 600 "$KEY_PATH" + xcrun notarytool submit "${{ steps.package.outputs.path }}" \ + --key "$KEY_PATH" \ + --key-id "$ASC_KEY_ID" \ + --issuer "$ASC_ISSUER_ID" \ + --wait --output-format json > notarization.json + SUBMISSION_ID=$(jq -r '.id // empty' notarization.json) + STATUS=$(jq -r '.status // empty' notarization.json) + if [ "$STATUS" != "Accepted" ] || [ -z "$SUBMISSION_ID" ]; then + echo "::error::Apple notarization did not return Accepted (status=${STATUS:-missing})." + [ -n "$SUBMISSION_ID" ] && xcrun notarytool log "$SUBMISSION_ID" \ + --key "$KEY_PATH" --key-id "$ASC_KEY_ID" --issuer "$ASC_ISSUER_ID" || true + exit 1 + fi + xcrun stapler staple "${{ steps.package.outputs.path }}" + xcrun stapler validate "${{ steps.package.outputs.path }}" + echo "submission_id=$SUBMISSION_ID" >> "$GITHUB_OUTPUT" + echo "status=$STATUS" >> "$GITHUB_OUTPUT" + rm -f "$KEY_PATH" + + - name: Verify distribution trust and write signing report + run: | + PKG_OUT="${{ steps.package.outputs.path }}" + COMPONENT="$RUNNER_TEMP/signed-package-check/wsjtx-signed-component.pkg" + APP="$COMPONENT/Payload/Applications/wsjtx.app" + codesign --verify --deep --strict --verbose=2 "$APP" + codesign -dv --verbose=4 "$APP" 2> codesign-details.txt + grep -F "TeamIdentifier=${APPLE_TEAM_ID}" codesign-details.txt + pkgutil --check-signature "$PKG_OUT" | tee pkg-signature.txt + grep -F "Developer ID Installer:" pkg-signature.txt + grep -F "(${APPLE_TEAM_ID})" pkg-signature.txt + xcrun stapler validate "$PKG_OUT" + spctl --assess --type install --verbose=4 "$PKG_OUT" + SHA256=$(shasum -a 256 "$PKG_OUT" | awk '{print $1}') + jq -n \ + --arg mode distribution \ + --arg artifact "$PKG_OUT" \ + --arg sha256 "$SHA256" \ + --arg git_sha "$GITHUB_SHA" \ + --arg team_id "$APPLE_TEAM_ID" \ + --arg app_certificate_sha1 "$(printf '%s' "$APP_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]')" \ + --arg installer_certificate_sha1 "$(printf '%s' "$INST_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]')" \ + --arg notarization_id "${{ steps.notarize.outputs.submission_id }}" \ + --arg notarization_status "${{ steps.notarize.outputs.status }}" \ + '{schema_version: 1, mode: $mode, artifact: $artifact, sha256: $sha256, git_sha: $git_sha, team_id: $team_id, application_certificate_sha1: $app_certificate_sha1, installer_certificate_sha1: $installer_certificate_sha1, notarization: {id: $notarization_id, status: $notarization_status}, stapled: true, gatekeeper_accepted: true, isolated_signing_job: true}' \ + > macos-signing-report.json + + - name: Remove signing credentials + if: always() + run: | + rm -f "$RUNNER_TEMP/app.p12" "$RUNNER_TEMP/installer.p12" "$RUNNER_TEMP"/AuthKey_*.p8 + security delete-keychain "$RUNNER_TEMP/release-signing.keychain-db" 2>/dev/null || true + + - name: Upload signed distribution package + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: ${{ steps.package.outputs.path }} + path: ${{ steps.package.outputs.path }} + + - name: Upload distribution signing report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: macos-signing-report-${{ inputs.version }}-${{ inputs.arch }} + path: macos-signing-report.json |
