Repository navigation
226 lines (205 loc) · 8.06 KB
/
Copy pathrelease-build.yml
File metadata and controls
226 lines (205 loc) · 8.06 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: Build Release
on:
workflow_call:
inputs:
release-tag:
description: Git tag to build and publish
required: true
type: string
expected-source-sha:
description: Qualified source commit that the release tag must resolve to
required: false
default: ""
type: string
is-prerelease:
description: Whether the caller is publishing a pre-release
required: true
type: boolean
outputs:
python_version:
description: Python package version
value: ${{ jobs.compute-versions.outputs.python_version }}
npm_version:
description: TypeScript package version
value: ${{ jobs.compute-versions.outputs.npm_version }}
semver:
description: Release version without the v prefix
value: ${{ jobs.compute-versions.outputs.semver }}
source_sha:
description: Source commit resolved from the release tag
value: ${{ jobs.compute-versions.outputs.source_sha }}
secrets:
CACHIX_AUTH_TOKEN:
required: false
permissions:
contents: read
packages: read
env:
RELEASE_TAG: ${{ inputs.release-tag }}
defaults:
run:
shell: bash
jobs:
compute-versions:
name: Compute Versions
runs-on: linux-amd64-cpu8
timeout-minutes: 5
defaults:
run:
shell: nix develop -c bash -euo pipefail {0}
outputs:
python_version: ${{ steps.v.outputs.python }}
cargo_version: ${{ steps.v.outputs.cargo }}
npm_version: ${{ steps.v.outputs.npm }}
deb_version: ${{ steps.v.outputs.deb }}
rpm_version: ${{ steps.v.outputs.rpm_version }}
rpm_release: ${{ steps.v.outputs.rpm_release }}
# Semver without 'v' prefix (e.g. 0.6.0), used for image tags and release body
semver: ${{ steps.v.outputs.semver }}
# Commit resolved from RELEASE_TAG, used for image tags and downstream metadata
source_sha: ${{ steps.v.outputs.source_sha }}
is_prerelease: ${{ steps.v.outputs.is_prerelease }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ inputs.release-tag }}
- uses: ./.github/actions/setup-nix
with:
prepare-shell: "true"
- name: Fetch tags
run: git fetch --tags --force
- name: Compute all versions
id: v
env:
EXPECTED_PRERELEASE: ${{ inputs.is-prerelease }}
EXPECTED_SOURCE_SHA: ${{ inputs.expected-source-sha }}
run: |
set -euo pipefail
if [[ -n "${EXPECTED_SOURCE_SHA}" && "$(git rev-parse HEAD)" != "${EXPECTED_SOURCE_SHA}" ]]; then
echo "Release tag ${RELEASE_TAG} does not match the qualified commit ${EXPECTED_SOURCE_SHA}." >&2
exit 1
fi
if [[ "${RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-pre\.[1-9][0-9]*$ ]]; then
is_prerelease=true
elif [[ "${RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
is_prerelease=false
else
echo "Unsupported release tag: ${RELEASE_TAG}" >&2
exit 1
fi
if [[ "${is_prerelease}" != "${EXPECTED_PRERELEASE}" ]]; then
echo "Tag ${RELEASE_TAG} does not match this release workflow's prerelease mode." >&2
exit 1
fi
{
echo "is_prerelease=${is_prerelease}"
echo "python=$(uv run --no-project python tasks/scripts/release.py get-version --python)"
echo "cargo=$(uv run --no-project python tasks/scripts/release.py get-version --cargo)"
echo "npm=$(uv run --no-project python tasks/scripts/release.py get-version --npm)"
echo "deb=$(uv run --no-project python tasks/scripts/release.py get-version --deb)"
echo "rpm_version=$(uv run --no-project python tasks/scripts/release.py get-version --rpm-version)"
echo "rpm_release=$(uv run --no-project python tasks/scripts/release.py get-version --rpm-release)"
echo "semver=${RELEASE_TAG#v}"
echo "source_sha=$(git rev-parse HEAD)"
} >> "$GITHUB_OUTPUT"
build-binaries:
needs: compute-versions
permissions:
contents: read
uses: ./.github/workflows/build-binaries.yml
with:
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
supervisor-image-tag: ${{ needs.compute-versions.outputs.semver }}
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
secrets:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
build-vm-driver:
needs: [compute-versions, build-binaries]
permissions:
contents: read
uses: ./.github/workflows/build-vm-driver.yml
with:
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
supervisor-image-tag: ${{ needs.compute-versions.outputs.semver }}
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
secrets:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
package-binaries:
needs: [compute-versions, build-binaries, build-vm-driver]
permissions:
actions: read
contents: read
uses: ./.github/workflows/package-release-binaries.yml
with:
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
build-images:
needs: [compute-versions, build-binaries]
permissions:
contents: read
packages: write
uses: ./.github/workflows/build-images.yml
with:
image-tag: ${{ inputs.is-prerelease && needs.compute-versions.outputs.source_sha || needs.compute-versions.outputs.semver }}
push-images: ${{ inputs.is-prerelease }}
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
build-python-wheel:
name: Build Python Wheel
needs: [compute-versions]
runs-on: linux-amd64-cpu8
timeout-minutes: 20
defaults:
run:
shell: nix develop -c bash -euo pipefail {0}
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENSHELL: ${{ needs.compute-versions.outputs.python_version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ needs.compute-versions.outputs.source_sha }}
- uses: ./.github/actions/setup-nix
with:
prepare-shell: "true"
- name: Sync Python dependencies
run: uv sync --frozen
- name: Build Python wheel
run: |
set -euo pipefail
uv run --frozen python tasks/scripts/generate_python_proto.py
uv build --wheel --out-dir target/wheels
uv run --no-project python tasks/scripts/verify-python-wheel.py target/wheels \
--expected-version "${SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENSHELL}"
ls -la target/wheels/*.whl
- name: Upload wheel artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: python-wheel
path: target/wheels/*.whl
retention-days: 5
build-deb:
name: Build Debian Packages
needs: [compute-versions, build-binaries, build-vm-driver]
uses: ./.github/workflows/deb-package.yml
with:
deb-version: ${{ needs.compute-versions.outputs.deb_version }}
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
build-snap:
name: Build Snap
needs: [compute-versions, build-binaries]
uses: ./.github/workflows/snap-package.yml
with:
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
build-rpm:
name: Build RPM Packages
needs: [compute-versions, build-binaries]
uses: ./.github/workflows/rpm-package.yml
with:
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
rpm-version: ${{ needs.compute-versions.outputs.rpm_version }}
rpm-release: ${{ needs.compute-versions.outputs.rpm_release }}
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}