Skip to content

Commit 1ba798f

Browse files
authored
ci(release): pin OPENSHELL_IMAGE_TAG to version for tagged releases (#297)
1 parent 19c3230 commit 1ba798f

File tree

5 files changed

+123
-83
lines changed

5 files changed

+123
-83
lines changed

.github/workflows/docker-build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ on:
2727
required: false
2828
type: string
2929
default: "build-amd64"
30+
cargo-version:
31+
description: "Pre-computed cargo version (skips internal git-based computation)"
32+
required: false
33+
type: string
34+
default: ""
3035

3136
env:
3237
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -69,7 +74,11 @@ jobs:
6974
id: version
7075
run: |
7176
set -eu
72-
echo "cargo_version=$(uv run python tasks/scripts/release.py get-version --cargo)" >> "$GITHUB_OUTPUT"
77+
if [[ -n "${{ inputs.cargo-version }}" ]]; then
78+
echo "cargo_version=${{ inputs.cargo-version }}" >> "$GITHUB_OUTPUT"
79+
else
80+
echo "cargo_version=$(uv run python tasks/scripts/release.py get-version --cargo)" >> "$GITHUB_OUTPUT"
81+
fi
7382
7483
- name: Log in to GHCR
7584
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin

.github/workflows/release-dev.yml

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,52 @@ defaults:
1414
shell: bash
1515

1616
jobs:
17+
# ---------------------------------------------------------------------------
18+
# Compute all versions once at the start to avoid git-describe race conditions
19+
# ---------------------------------------------------------------------------
20+
compute-versions:
21+
name: Compute Versions
22+
runs-on: build-amd64
23+
timeout-minutes: 5
24+
container:
25+
image: ghcr.io/nvidia/openshell/ci:latest
26+
credentials:
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
outputs:
30+
python_version: ${{ steps.v.outputs.python }}
31+
cargo_version: ${{ steps.v.outputs.cargo }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Mark workspace safe for git
38+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
39+
40+
- name: Fetch tags
41+
run: git fetch --tags --force
42+
43+
- name: Compute all versions
44+
id: v
45+
run: |
46+
set -euo pipefail
47+
echo "python=$(uv run python tasks/scripts/release.py get-version --python)" >> "$GITHUB_OUTPUT"
48+
echo "cargo=$(uv run python tasks/scripts/release.py get-version --cargo)" >> "$GITHUB_OUTPUT"
49+
1750
build-gateway:
51+
needs: [compute-versions]
1852
uses: ./.github/workflows/docker-build.yml
1953
with:
2054
component: gateway
55+
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
2156

2257
build-cluster:
58+
needs: [compute-versions]
2359
uses: ./.github/workflows/docker-build.yml
2460
with:
2561
component: cluster
62+
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
2663

2764
tag-ghcr-dev:
2865
name: Tag GHCR Images as Dev
@@ -47,11 +84,11 @@ jobs:
4784
4885
build-python-wheels:
4986
name: Stage Python Wheels
50-
needs: [build-gateway, build-cluster]
87+
needs: [compute-versions, build-gateway, build-cluster]
5188
runs-on: build-amd64
5289
timeout-minutes: 120
5390
outputs:
54-
wheel_version: ${{ steps.version.outputs.wheel_version }}
91+
wheel_version: ${{ needs.compute-versions.outputs.python_version }}
5592
s3_prefix: ${{ steps.upload.outputs.s3_prefix }}
5693
container:
5794
image: ghcr.io/nvidia/openshell/ci:latest
@@ -83,30 +120,21 @@ jobs:
83120
- name: Mark workspace safe for git
84121
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
85122

86-
- name: Fetch tags
87-
run: git fetch --tags --force
88-
89-
- name: Compute Python version
90-
id: version
91-
run: |
92-
set -euo pipefail
93-
WHEEL_VERSION=$(uv run python tasks/scripts/release.py get-version --python)
94-
echo "wheel_version=${WHEEL_VERSION}" >> "$GITHUB_OUTPUT"
123+
- name: Sync Python dependencies
124+
run: uv sync
95125

96126
- name: Build Python wheels
97127
run: |
98128
set -euo pipefail
99-
WHEEL_VERSION="${{ steps.version.outputs.wheel_version }}"
100-
CARGO_VERSION=$(uv run python tasks/scripts/release.py get-version --cargo)
101-
OPENSHELL_CARGO_VERSION="$CARGO_VERSION" mise run python:build:multiarch
102-
OPENSHELL_CARGO_VERSION="$CARGO_VERSION" mise run python:build:macos
129+
OPENSHELL_CARGO_VERSION="${{ needs.compute-versions.outputs.cargo_version }}" mise run python:build:multiarch
130+
OPENSHELL_CARGO_VERSION="${{ needs.compute-versions.outputs.cargo_version }}" mise run python:build:macos
103131
ls -la target/wheels/*.whl
104132
105133
- name: Upload wheels to S3
106134
id: upload
107135
run: |
108136
set -euo pipefail
109-
WHEEL_VERSION="${{ steps.version.outputs.wheel_version }}"
137+
WHEEL_VERSION="${{ needs.compute-versions.outputs.python_version }}"
110138
S3_PREFIX="openshell/${WHEEL_VERSION}"
111139
aws s3 cp target/wheels/ "s3://${NAV_PYPI_S3_BUCKET}/${S3_PREFIX}/" --recursive --exclude "*" --include "*.whl"
112140
aws s3 ls "s3://${NAV_PYPI_S3_BUCKET}/${S3_PREFIX}/"
@@ -190,6 +218,7 @@ jobs:
190218
# ---------------------------------------------------------------------------
191219
build-cli-linux:
192220
name: Build CLI (Linux ${{ matrix.arch }})
221+
needs: [compute-versions]
193222
strategy:
194223
matrix:
195224
include:
@@ -232,13 +261,6 @@ jobs:
232261
cache-directories: .cache/sccache
233262
cache-targets: "true"
234263

235-
- name: Compute version
236-
id: version
237-
run: |
238-
set -euo pipefail
239-
CARGO_VERSION=$(uv run python tasks/scripts/release.py get-version --cargo)
240-
echo "cargo_version=${CARGO_VERSION}" >> "$GITHUB_OUTPUT"
241-
242264
- name: Install musl toolchain
243265
run: |
244266
set -euo pipefail
@@ -258,10 +280,10 @@ jobs:
258280
sed -i 's|members = \["crates/\*"\]|members = ["crates/openshell-cli", "crates/openshell-core", "crates/openshell-bootstrap", "crates/openshell-policy", "crates/openshell-providers", "crates/openshell-tui"]|' Cargo.toml
259281
260282
- name: Patch workspace version
261-
if: steps.version.outputs.cargo_version != ''
283+
if: needs.compute-versions.outputs.cargo_version != ''
262284
run: |
263285
set -euo pipefail
264-
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${{ steps.version.outputs.cargo_version }}"'"/}' Cargo.toml
286+
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${{ needs.compute-versions.outputs.cargo_version }}"'"/}' Cargo.toml
265287
266288
- name: Build ${{ matrix.target }}
267289
run: mise x -- cargo build --release --target ${{ matrix.target }} -p openshell-cli
@@ -290,6 +312,7 @@ jobs:
290312
# ---------------------------------------------------------------------------
291313
build-cli-macos:
292314
name: Build CLI (macOS)
315+
needs: [compute-versions]
293316
runs-on: build-amd64
294317
timeout-minutes: 60
295318
container:
@@ -320,19 +343,12 @@ jobs:
320343
- name: Set up Docker Buildx
321344
uses: ./.github/actions/setup-buildx
322345

323-
- name: Compute version
324-
id: version
325-
run: |
326-
set -euo pipefail
327-
CARGO_VERSION=$(uv run python tasks/scripts/release.py get-version --cargo)
328-
echo "cargo_version=${CARGO_VERSION}" >> "$GITHUB_OUTPUT"
329-
330346
- name: Build macOS binary via Docker
331347
run: |
332348
set -euo pipefail
333349
docker buildx build \
334350
--file deploy/docker/Dockerfile.cli-macos \
335-
--build-arg OPENSHELL_CARGO_VERSION="${{ steps.version.outputs.cargo_version }}" \
351+
--build-arg OPENSHELL_CARGO_VERSION="${{ needs.compute-versions.outputs.cargo_version }}" \
336352
--build-arg OPENSHELL_IMAGE_TAG=dev \
337353
--build-arg CARGO_TARGET_CACHE_SCOPE="${{ github.sha }}" \
338354
--target binary \

0 commit comments

Comments
 (0)