Repository navigation
mcxtrace-autobuild #1145
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: mcxtrace-autobuild | |
| on: | |
| schedule: | |
| - cron: '50 23 * * *' # 23:50 every day | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| manual-debugging: | |
| type: boolean | |
| description: Launch manual debugging tmate for inspection (automatic in case of errors) | |
| default: false | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: ubuntu-latest, CC: gcc, CXX: g++, python: '3.11' } | |
| - { os: ubuntu-24.04-arm, CC: gcc, CXX: g++, python: '3.11' } | |
| - { os: macos-latest, CC: clang, CXX: clang++, python: "3.11" } | |
| name: ${{ matrix.os }}.${{ matrix.CC }}.python-${{ matrix.python }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| CC: ${{ matrix.CC }} | |
| CXX: ${{ matrix.CXX }} | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| path: McCode | |
| - name: Setup python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Setup build-deps-linux-intel | |
| id: setup-build-deps-linux-intel | |
| if: matrix.os == 'ubuntu-latest' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if [ "$RUNNER_OS" == "Linux" ]; then sudo apt-get update && sudo apt-get -y install equivs ; fi | |
| if [ "$RUNNER_OS" == "Linux" ]; then sudo apt-get -y install xvfb mingw-w64 gfortran-mingw-w64 mingw-w64-x86-64-dev libz-mingw-w64-dev dos2unix nsis wine64; fi | |
| if [ "$RUNNER_OS" == "Linux" ]; then sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install wine32; fi | |
| # Latest Inno Setup release, auto-detected; pin with INNOSETUP_VERSION=x.y.z if needed | |
| if [ "$RUNNER_OS" == "Linux" ]; then ./McCode/meta-pkgs/windows/install-innosetup ; fi | |
| - name: Setup build-deps-linux-arm | |
| id: setup-build-deps-linux-arm | |
| if: matrix.os == 'ubuntu-24.04-arm' | |
| run: | | |
| if [ "$RUNNER_OS" == "Linux" ]; then sudo apt-get update && sudo apt-get -y install equivs ; fi | |
| - name: Check versions | |
| id: version-checks | |
| run: | | |
| which python3 | |
| python3 --version | |
| which cmake | |
| cmake --version | |
| #NB: bison and flex in path are actually too old, on mac we | |
| #inject these via a brew keg later | |
| - name: Build McXtrace | |
| id: mcxtrace-build | |
| if: matrix.os != 'ubuntu-24.04-arm' | |
| run: | | |
| if [ "$RUNNER_OS" == "macOS" ]; then export SDKROOT=$(xcrun --sdk macosx --show-sdk-path); fi | |
| set -e | |
| set -u | |
| set -x | |
| cd McCode | |
| # Check if this is a clear-cut release-tag build: | |
| export REV=`git tag --points-at HEAD | cut -b2-` | |
| # Otherwise, pick latest and add _nightly | |
| if [ "$REV" == "" ]; then export REV=`git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags origin 'v*.*.*' | tail -1 | cut -f3 -d/ | cut -f2 -dv`_nightly; fi | |
| echo Building on $RUNNER_OS with version set to $REV | |
| if [ "$RUNNER_OS" == "macOS" ]; then ./buildscripts/build_macos_mcxtrace ${REV} && tar cfz mcxtrace-macOS-conda.tgz mcxtrace-macOS-arm64/ mcxtrace-macOS-x86_64/; fi; | |
| if [ "$RUNNER_OS" == "Linux" ]; then ./buildscripts/build_debs_mcxtrace ${REV} meta && mv dist mcxtrace-debian-x86_64 && tar cfz mcxtrace-debian-x86_64.tgz mcxtrace-debian-x86_64/; fi | |
| - name: Build McXtrace arm Linux | |
| id: mcxtrace-build-arm | |
| if: matrix.os == 'ubuntu-24.04-arm' | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| cd McCode | |
| # Check if this is a clear-cut release-tag build: | |
| export REV=`git tag --points-at HEAD | cut -b2-` | |
| # Otherwise, pick latest and add _nightly | |
| if [ "$REV" == "" ]; then export REV=`git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags origin 'v*.*.*' | tail -1 | cut -f3 -d/ | cut -f2 -dv`_nightly; fi | |
| echo Building on $RUNNER_OS with version set to $REV | |
| if [ "$RUNNER_OS" == "Linux" ]; then ./buildscripts/build_debs_mcxtrace_arm64 ${REV} meta && mv dist mcxtrace-debian-arm64 && tar cfz mcxtrace-debian-arm64.tgz mcxtrace-debian-arm64/; fi | |
| - name: Cross-Build McXtrace for windows | |
| id: mcxtrace-mingw-build | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| cd McCode | |
| # Check if this is a clear-cut release-tag build: | |
| export REV=`git tag --points-at HEAD | cut -b2-` | |
| # Otherwise, pick latest and add _nightly | |
| if [ "$REV" == "" ]; then export REV=`git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags origin 'v*.*.*' | tail -1 | cut -f3 -d/ | cut -f2 -dv`_nightly; fi | |
| echo Cross-compiling for MinGW Windows on $RUNNER_OS with version set to $REV | |
| if [ "$RUNNER_OS" == "Linux" ]; then rm -rf dist; fi | |
| if [ "$RUNNER_OS" == "Linux" ]; then ./buildscripts/build_windows_mcxtrace ${REV} meta && mv dist mcxtrace-mingw64-Windows-x86_64; fi | |
| if [ "$RUNNER_OS" == "Linux" ]; then tar cfz mcxtrace-Windows-MinGW-x86_64.tgz mcxtrace-mingw64-Windows-x86_64/; fi | |
| echo Building MSVC Windows installer on $RUNNER_OS with version set to $REV | |
| if [ "$RUNNER_OS" == "Linux" ]; then rm -rf dist; fi | |
| if [ "$RUNNER_OS" == "Linux" ]; then ./buildscripts/build_windows_mcxtrace_conda ${REV} meta && mv dist mcxtrace-MSVC-Windows-x86_64; fi | |
| if [ "$RUNNER_OS" == "Linux" ]; then tar cfz mcxtrace-Windows-MSVC-x86_64.tgz mcxtrace-MSVC-Windows-x86_64/; fi | |
| - name: 'Upload Artifact' | |
| id: tar-upload | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: mcxtrace-artefacts-${{ matrix.os }} | |
| path: "McCode/mcxtrace-*.tgz" | |
| - name: Setup tmate session for manual debugging | |
| uses: mxschmitt/action-tmate@v3 | |
| if: always() && (inputs.manual-debugging) | |
| with: | |
| limit-access-to-actor: true | |
| # Combine the per-platform artefacts into one tree laid out like | |
| # https://download.mcxtrace.org/mcxtrace-<version>/ (skeleton: INSTALL-McXtrace). | |
| # Only done for release tags and manual runs, to spare artefact storage | |
| # on the nightlies. | |
| assemble-release: | |
| needs: build | |
| if: ${{ !cancelled() && (startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch') }} | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| path: McCode | |
| - name: Determine version | |
| id: version | |
| run: | | |
| set -e | |
| cd McCode | |
| # Same logic as in the build job | |
| export REV=`git tag --points-at HEAD | cut -b2-` | |
| if [ "$REV" == "" ]; then export REV=`git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags origin 'v*.*.*' | tail -1 | cut -f3 -d/ | cut -f2 -dv`_nightly; fi | |
| echo "Assembling release tree for version $REV" | |
| echo "rev=$REV" >> "$GITHUB_OUTPUT" | |
| - name: Download per-platform artefacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: mcxtrace-artefacts-* | |
| merge-multiple: true | |
| path: artefacts | |
| - name: Assemble release tree | |
| id: assemble | |
| run: | | |
| ls -l artefacts | |
| cd McCode | |
| ./buildscripts/assemble_release_tree mcxtrace ${{ steps.version.outputs.rev }} ../artefacts ../release \ | |
| || echo "incomplete=true" >> "$GITHUB_OUTPUT" | |
| # release/ holds only mcxtrace-<version>/, so that directory becomes the | |
| # top level inside the downloaded zip | |
| - name: Upload release tree | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: mcxtrace-${{ steps.version.outputs.rev }} | |
| path: release/ | |
| if-no-files-found: error | |
| - name: Fail if release tree is incomplete | |
| if: steps.assemble.outputs.incomplete == 'true' | |
| run: | | |
| echo "::error::Release tree is missing platform artefacts - see the 'Assemble release tree' step" | |
| exit 1 |