1+ # Copyright 2026 Arm Limited and/or its affiliates.
2+ #
3+ # This source code is licensed under the BSD-style license found in the
4+ # LICENSE file in the root directory of this source tree.
5+
6+ name : Build CMSIS Pack
7+
8+ on :
9+ schedule :
10+ # Nightly at 03:00 UTC, staggered after nightly.yml (02:00) so the
11+ # shared runner pool isn't hit by both at the same minute.
12+ - cron : 0 3 * * *
13+ release :
14+ # Build (and, for non-prerelease, publish) the pack when a GitHub
15+ # Release is created. The tag the release points at drives the pack
16+ # version via GITHUB_REF below.
17+ types : [published]
18+ push :
19+ branches :
20+ - main
21+ - release/*
22+ paths :
23+ - .github/workflows/build-cmsis-pack.yml
24+ - backends/arm/cmsis_pack/**
25+ - backends/arm/cmsis_pack/scripts/**
26+ - backends/arm/runtime/**
27+ - backends/cortex_m/**
28+ - kernels/portable/**
29+ - kernels/quantized/**
30+ - runtime/**
31+ - schema/**
32+ pull_request :
33+ paths :
34+ - .github/workflows/build-cmsis-pack.yml
35+ - backends/arm/cmsis_pack/**
36+ - backends/arm/cmsis_pack/scripts/**
37+ workflow_dispatch :
38+ inputs :
39+ version_override :
40+ description : ' Override pack version (e.g., 1.2.0). Leave empty to derive from version.txt'
41+ required : false
42+ type : string
43+
44+ concurrency :
45+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
46+ cancel-in-progress : true
47+
48+ jobs :
49+ build-cmsis-pack :
50+ name : build-cmsis-pack
51+ uses : pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
52+ permissions :
53+ id-token : write
54+ contents : read
55+ with :
56+ runner : linux.2xlarge
57+ docker-image : ci-image:executorch-ubuntu-22.04-arm-sdk
58+ submodules : ' recursive'
59+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
60+ timeout : 60
61+ upload-artifact : cmsis-pack-artifact
62+ script : |
63+ set -eux
64+
65+ echo "::group::Setup environment"
66+ # The generic Linux job chooses to use base env, not the one setup by the image
67+ CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
68+ conda activate "${CONDA_ENV}"
69+
70+ source .ci/scripts/utils.sh
71+ install_executorch "--use-pt-pinned-commit"
72+ echo "::endgroup::"
73+
74+ echo "::group::Install ARM toolchain"
75+ .ci/scripts/setup-arm-baremetal-tools.sh
76+ source examples/arm/arm-scratch/setup_path.sh
77+ echo "::endgroup::"
78+
79+ echo "::group::Cross-compile ExecuTorch for Cortex-M"
80+ # Stage 1: Build core ExecuTorch with arm-none-eabi-gcc
81+ # This generates required headers (flatbuffers, schema)
82+ backends/arm/scripts/build_executorch.sh
83+ CMAKE_BUILD_DIR="$(pwd)/cmake-out-arm"
84+ echo "::endgroup::"
85+
86+ echo "::group::Determine pack version"
87+ # Derive version from tag, input override, schedule (nightly), or version.txt
88+ BASE_VER="$(cat version.txt | sed 's/a0$//')"
89+ if [[ -n "${{ inputs.version_override || '' }}" ]]; then
90+ PACK_VERSION="${{ inputs.version_override }}"
91+ elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
92+ # Strip leading 'v' and any -rc suffix for release tags
93+ PACK_VERSION="${GITHUB_REF#refs/tags/v}"
94+ elif [[ "${{ github.event_name }}" == "schedule" ]]; then
95+ PACK_VERSION="${BASE_VER}-nightly-$(date -u +%Y%m%d)"
96+ else
97+ PACK_VERSION="${BASE_VER}-dev"
98+ fi
99+ echo "Pack version: ${PACK_VERSION}"
100+ echo "::endgroup::"
101+
102+ echo "::group::Build CMSIS Pack"
103+ backends/arm/cmsis_pack/scripts/build_pack.sh \
104+ --executorch-root "$(pwd)" \
105+ --build-dir "${CMAKE_BUILD_DIR}" \
106+ --version "${PACK_VERSION}" \
107+ --output-dir "$(pwd)/artifacts-to-be-uploaded"
108+ echo "::endgroup::"
109+
110+ # Structural validation and consumer-build smoke are intentionally
111+ # not run in CI yet. See:
112+ # backends/arm/cmsis_pack/test/validate_pack.py (structural)
113+ # backends/arm/cmsis_pack/test/smoke/run.sh (cbuild via
114+ # AVH-MLOps)
115+ # for the local test drivers.
116+
117+ # Attach the pack to the GitHub Release when a non-prerelease release is
118+ # published. Prereleases still build + validate via the release trigger
119+ # but are not published.
120+ publish-cmsis-pack :
121+ if : github.event_name == 'release' && !github.event.release.prerelease
122+ needs : build-cmsis-pack
123+ runs-on : ubuntu-latest
124+ permissions :
125+ contents : write
126+ steps :
127+ - name : Download pack artifact
128+ uses : actions/download-artifact@v4
129+ with :
130+ name : cmsis-pack-artifact
131+ path : pack-output
132+
133+ - name : Upload to GitHub Release
134+ uses : softprops/action-gh-release@v2
135+ with :
136+ files : pack-output/*.pack
137+ tag_name : ${{ github.ref_name }}
0 commit comments