-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathaction.yaml
More file actions
192 lines (177 loc) · 7.3 KB
/
Copy pathaction.yaml
File metadata and controls
192 lines (177 loc) · 7.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Build nemo-platform wheel
description: >
Set up the build toolchain (uv, plus node/pnpm when building nemo-platform
so the hatch hook can compile Studio assets), stamp the SDK version, and
run `uv build --wheel --package <pkg>`. The build itself — including
Studio asset compilation and wheel content force-includes — lives in the
package's hatch_build.py; this action only handles environment setup,
the pre-build version stamp, and capturing the produced wheel.
Both ci.yaml's wheel-test job and release-bundle.yaml's build-sdks matrix
call this action so the test wheel and the published wheel come out of
one code path.
Assumes the repository has already been checked out to `inputs.source-root`
and that any required runtime assets (e.g. policy.wasm via the
build-policy-wasm action) already exist on disk.
inputs:
package:
description: >
Distribution name passed to `uv build --package`. Must match a workspace
package such as `nemo-platform` or `nemo-platform-plugin`.
required: false
default: nemo-platform
out-dir:
description: Absolute path where the wheel is written.
required: true
cadence:
description: >
Forwarded to stamp_sdk_version.py. One of `nightly`, `rc`, `release`.
required: false
default: nightly
release-label:
description: >
Forwarded to stamp_sdk_version.py. Required for `cadence: rc` (e.g.
`1.0.0-rc0`) or `cadence: release` (e.g. `1.0.0`); ignored for `nightly`.
required: false
default: ""
nightly-timestamp:
description: >
Forwarded to stamp_sdk_version.py. Required for `cadence: nightly`. Must
be exactly 14 digits in `YYYYMMDDHHMMSS` form.
required: false
default: "19700101000000"
python-version:
description: Python version for setup-uv.
required: false
default: "3.11"
source-root:
description: >
Path to the checked-out repository. release-bundle.yaml uses `source`;
the ci.yaml test job uses `.`.
required: false
default: "."
studio-web-root:
description: >
Path to the Studio pnpm workspace, relative to source-root. This is the
directory containing package.json and pnpm-lock.yaml.
required: false
default: web
outputs:
wheel-path:
description: Absolute path to the single wheel produced by `uv build`.
value: ${{ steps.build.outputs.wheel-path }}
wheel-version:
description: Resolved version string written into the wheel metadata.
value: ${{ steps.stamp.outputs.wheel-version }}
runs:
using: composite
steps:
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
python-version: ${{ inputs.python-version }}
enable-cache: true
version-file: ${{ inputs.source-root }}/pyproject.toml
cache-dependency-glob: ${{ inputs.source-root }}/uv.lock
# Stamp early, before pnpm/node setup, so bad cadence/label/timestamp
# inputs fail fast instead of after spending ~20s on tool setup. The
# version is written into packages/nmp_common/.../version.py and the
# generated _version.py before `uv build` runs (hatchling reads
# version.py via its regex source but does not write it). The
# --print-version flag emits just the resolved version on stdout;
# the human banner goes to stderr.
- name: Stamp SDK version
id: stamp
shell: bash
env:
SOURCE_ROOT: ${{ inputs.source-root }}
PACKAGE: ${{ inputs.package }}
CADENCE: ${{ inputs.cadence }}
RELEASE_LABEL: ${{ inputs.release-label }}
NIGHTLY_TIMESTAMP: ${{ inputs.nightly-timestamp }}
# Run the stamp script from the action's own checkout (the workflow
# ref), not from inputs.source-root. For ci.yaml these are the same;
# for release-bundle.yaml the source checkout can be at an older
# source_sha (RC/stable rerun of an old tag) and we want today's
# stamping logic to apply.
STAMP_SCRIPT_PATH: ${{ github.action_path }}/../../scripts/stamp_sdk_version.py
run: |
set -euo pipefail
args=(
--source-root "${SOURCE_ROOT}"
--sdk-id "${PACKAGE}"
--cadence "${CADENCE}"
--nightly-timestamp "${NIGHTLY_TIMESTAMP}"
--print-version
)
if [[ -n "${RELEASE_LABEL}" ]]; then
args+=(--release-label "${RELEASE_LABEL}")
fi
wheel_version="$(uv run --no-project python "${STAMP_SCRIPT_PATH}" "${args[@]}")"
echo "wheel-version=${wheel_version}" >>"${GITHUB_OUTPUT}"
# Studio assets are only force-included by the nemo-platform wrapper.
# The hatch hook in packages/nemo_platform/hatch_build.py compiles them
# via pnpm during `uv build`; we set up node/pnpm here so the hook can
# find them. Other packages (nemo-platform-plugin, ...) skip these.
- name: Set up Node.js
if: inputs.package == 'nemo-platform'
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "22"
cache: pnpm
cache-dependency-path: ${{ inputs.source-root }}/${{ inputs.studio-web-root }}/pnpm-lock.yaml
- name: Install pnpm via Corepack
if: inputs.package == 'nemo-platform'
shell: bash
env:
STUDIO_WEB_ROOT: ${{ inputs.source-root }}/${{ inputs.studio-web-root }}
run: |
set -euo pipefail
if [[ ! -d "${STUDIO_WEB_ROOT}" ]]; then
echo "::error::Studio web root not found at ${STUDIO_WEB_ROOT}" >&2
exit 1
fi
studio_web_root="$(cd "${STUDIO_WEB_ROOT}" && pwd -P)"
package_json="${studio_web_root}/package.json"
lockfile="${studio_web_root}/pnpm-lock.yaml"
if [[ ! -f "${package_json}" ]]; then
echo "::error::Studio package.json not found at ${package_json}" >&2
exit 1
fi
if [[ ! -f "${lockfile}" ]]; then
echo "::error::Studio pnpm lockfile not found at ${lockfile}" >&2
exit 1
fi
package_manager="$(PACKAGE_JSON="${package_json}" node -p "JSON.parse(require('fs').readFileSync(process.env.PACKAGE_JSON, 'utf8')).packageManager || ''")"
if [[ "${package_manager}" != pnpm@* ]]; then
echo "::error::Expected ${package_json} to declare packageManager: pnpm@..., got '${package_manager}'" >&2
exit 1
fi
npm i -g corepack@0.31.0
corepack enable pnpm
corepack prepare "${package_manager}" --activate
pnpm --dir "${studio_web_root}" --version
- name: Build wheel
id: build
shell: bash
env:
SOURCE_ROOT: ${{ inputs.source-root }}
OUT_DIR: ${{ inputs.out-dir }}
PACKAGE: ${{ inputs.package }}
run: |
set -euo pipefail
if [[ "${OUT_DIR}" != /* ]]; then
echo "::error::out-dir must be absolute, got: '${OUT_DIR}'" >&2
exit 1
fi
uv build --wheel \
--directory "${SOURCE_ROOT}" \
--package "${PACKAGE}" \
--out-dir "${OUT_DIR}"
shopt -s nullglob
wheels=("${OUT_DIR}"/*.whl)
if [[ "${#wheels[@]}" -ne 1 ]]; then
echo "::error::expected exactly one wheel for ${PACKAGE}, found ${#wheels[@]}" >&2
printf ' %s\n' "${wheels[@]}" >&2
exit 1
fi
echo "wheel-path=${wheels[0]}" >>"${GITHUB_OUTPUT}"