From 119b2ccdce350c3aee7895ab123a17ccab6be3cd Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 20 May 2026 15:58:41 +0200 Subject: [PATCH 1/6] refactor: Use better formatting for method chain across multiple lines --- x.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x.py b/x.py index f19c190..71658be 100755 --- a/x.py +++ b/x.py @@ -157,11 +157,13 @@ def render_template( rendered_path ): template = read_file(template_path) - rendered = template \ - .replace("%%TAG%%", docker_tag) \ - .replace("%%RUST-VERSION%%", rust_version) \ - .replace("%%RUSTUP-VERSION%%", rustup_version) \ + rendered = ( + template + .replace("%%TAG%%", docker_tag) + .replace("%%RUST-VERSION%%", rust_version) + .replace("%%RUSTUP-VERSION%%", rustup_version) .replace("%%ARCH-CASE%%", arch_cases) + ) write_file(rendered_path, rendered) def update_ci(): From 860f27f5d825003e02d43a6a7b6d3e459bd12e15 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 21 May 2026 16:02:09 +0200 Subject: [PATCH 2/6] feat: Allow overriding RUST_VERSION via Docker build arg --- Dockerfile-alpine.template | 3 ++- Dockerfile-debian.template | 3 ++- Dockerfile-slim.template | 3 ++- nightly/alpine3.21/Dockerfile | 3 ++- nightly/alpine3.22/Dockerfile | 3 ++- nightly/alpine3.23/Dockerfile | 3 ++- nightly/bookworm/Dockerfile | 3 ++- nightly/bookworm/slim/Dockerfile | 3 ++- nightly/bullseye/Dockerfile | 3 ++- nightly/bullseye/slim/Dockerfile | 3 ++- nightly/trixie/Dockerfile | 3 ++- nightly/trixie/slim/Dockerfile | 3 ++- x.py | 11 ++++++++++- 13 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index f26da74..30e51ac 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -7,10 +7,11 @@ RUN apk add --no-cache \ musl-dev \ gcc +%%RUST-VERSION-ARG%% ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=%%RUST-VERSION%% + RUST_VERSION=%%RUST-VERSION-VALUE%% RUN set -eux; \ \ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index f12e088..935f10b 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -2,10 +2,11 @@ FROM buildpack-deps:%%TAG%% LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +%%RUST-VERSION-ARG%% ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=%%RUST-VERSION%% + RUST_VERSION=%%RUST-VERSION-VALUE%% RUN set -eux; \ \ diff --git a/Dockerfile-slim.template b/Dockerfile-slim.template index 0cc8c8b..658346d 100644 --- a/Dockerfile-slim.template +++ b/Dockerfile-slim.template @@ -2,10 +2,11 @@ FROM debian:%%TAG%%-slim LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +%%RUST-VERSION-ARG%% ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=%%RUST-VERSION%% + RUST_VERSION=%%RUST-VERSION-VALUE%% RUN set -eux; \ \ diff --git a/nightly/alpine3.21/Dockerfile b/nightly/alpine3.21/Dockerfile index a1877e8..733db0f 100644 --- a/nightly/alpine3.21/Dockerfile +++ b/nightly/alpine3.21/Dockerfile @@ -7,10 +7,11 @@ RUN apk add --no-cache \ musl-dev \ gcc +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/alpine3.22/Dockerfile b/nightly/alpine3.22/Dockerfile index acee8be..77f9c6e 100644 --- a/nightly/alpine3.22/Dockerfile +++ b/nightly/alpine3.22/Dockerfile @@ -7,10 +7,11 @@ RUN apk add --no-cache \ musl-dev \ gcc +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/alpine3.23/Dockerfile b/nightly/alpine3.23/Dockerfile index 11126c4..de05119 100644 --- a/nightly/alpine3.23/Dockerfile +++ b/nightly/alpine3.23/Dockerfile @@ -7,10 +7,11 @@ RUN apk add --no-cache \ musl-dev \ gcc +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/bookworm/Dockerfile b/nightly/bookworm/Dockerfile index 97d2635..9b052a4 100644 --- a/nightly/bookworm/Dockerfile +++ b/nightly/bookworm/Dockerfile @@ -2,10 +2,11 @@ FROM buildpack-deps:bookworm LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/bookworm/slim/Dockerfile b/nightly/bookworm/slim/Dockerfile index 791317c..fc08dc9 100644 --- a/nightly/bookworm/slim/Dockerfile +++ b/nightly/bookworm/slim/Dockerfile @@ -2,10 +2,11 @@ FROM debian:bookworm-slim LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/bullseye/Dockerfile b/nightly/bullseye/Dockerfile index 3e2e4e0..e7cdc2f 100644 --- a/nightly/bullseye/Dockerfile +++ b/nightly/bullseye/Dockerfile @@ -2,10 +2,11 @@ FROM buildpack-deps:bullseye LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/bullseye/slim/Dockerfile b/nightly/bullseye/slim/Dockerfile index 3682cb8..4e8879a 100644 --- a/nightly/bullseye/slim/Dockerfile +++ b/nightly/bullseye/slim/Dockerfile @@ -2,10 +2,11 @@ FROM debian:bullseye-slim LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/trixie/Dockerfile b/nightly/trixie/Dockerfile index 495a126..5b46261 100644 --- a/nightly/trixie/Dockerfile +++ b/nightly/trixie/Dockerfile @@ -2,10 +2,11 @@ FROM buildpack-deps:trixie LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/nightly/trixie/slim/Dockerfile b/nightly/trixie/slim/Dockerfile index 0841d40..40ee2f7 100644 --- a/nightly/trixie/slim/Dockerfile +++ b/nightly/trixie/slim/Dockerfile @@ -2,10 +2,11 @@ FROM debian:trixie-slim LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust +ARG RUST_VERSION=nightly ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=nightly + RUST_VERSION=${RUST_VERSION} RUN set -eux; \ \ diff --git a/x.py b/x.py index 71658be..f509fe5 100755 --- a/x.py +++ b/x.py @@ -156,11 +156,20 @@ def render_template( arch_cases, rendered_path ): + if rust_version == "nightly": + rust_version_arg = "ARG RUST_VERSION=nightly\n" + rust_version_value = "${RUST_VERSION}" + else: + rust_version_arg = "" + rust_version_value = rust_version + template = read_file(template_path) rendered = ( template .replace("%%TAG%%", docker_tag) - .replace("%%RUST-VERSION%%", rust_version) + # We match with `\n` here so that the line is removed entirely if the argument is not needed + .replace("%%RUST-VERSION-ARG%%\n", rust_version_arg) + .replace("%%RUST-VERSION-VALUE%%", rust_version_value) .replace("%%RUSTUP-VERSION%%", rustup_version) .replace("%%ARCH-CASE%%", arch_cases) ) From 791a4b2959790057f43943850b2e57d1994486ce Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 21 May 2026 16:08:44 +0200 Subject: [PATCH 3/6] feat: Tag nightly images with the specific nightly version --- .github/workflows/nightly.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1280243..7f9268f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -93,6 +93,25 @@ jobs: username: rustopsbot password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Compute nightly date + id: date + run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT" + + - name: Build dated tag list + id: dated_tags + env: + BASE_TAGS: ${{ matrix.tags }} + DATE: ${{ steps.date.outputs.date }} + run: | + { + echo "tags<> "$GITHUB_OUTPUT" + - name: Docker Metadata id: meta uses: docker/metadata-action@v5 @@ -100,7 +119,9 @@ jobs: images: | rustlang/rust ghcr.io/rust-lang/rust - tags: ${{ matrix.tags }} + tags: | + ${{ matrix.tags }} + ${{ steps.dated_tags.outputs.tags }} - name: Build and push image uses: docker/build-push-action@v6 @@ -108,5 +129,7 @@ jobs: context: ${{ matrix.context }} platforms: ${{ matrix.platforms }} push: ${{ github.event_name != 'pull_request' }} + build-args: | + RUST_VERSION=nightly-${{ steps.date.outputs.date }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From eca2fa280f0db4df58194ddbadc044ddc1573dd2 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 21 May 2026 16:08:44 +0200 Subject: [PATCH 4/6] chore: Move nightly workflows runtime to be after the build should've completed --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7f9268f..483cc72 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -12,7 +12,7 @@ on: branches: - master schedule: - - cron: '0 0 * * *' + - cron: '0 6 * * *' jobs: build: From 3c5bab0faeef125071f4d97e480094e1d2b548fb Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 21 May 2026 16:08:44 +0200 Subject: [PATCH 5/6] chore: Allow workflow dispatch for nightly workflow --- .github/workflows/nightly.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 483cc72..3e76d21 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -11,6 +11,7 @@ on: pull_request: branches: - master + workflow_dispatch: schedule: - cron: '0 6 * * *' @@ -80,7 +81,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to GHCR uses: docker/login-action@v3 - if: github.event_name != 'pull_request' + if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master' with: registry: ghcr.io username: rust-lang @@ -88,7 +89,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v3 - if: github.event_name != 'pull_request' + if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master' with: username: rustopsbot password: ${{ secrets.DOCKER_HUB_TOKEN }} @@ -128,8 +129,8 @@ jobs: with: context: ${{ matrix.context }} platforms: ${{ matrix.platforms }} - push: ${{ github.event_name != 'pull_request' }} build-args: | RUST_VERSION=nightly-${{ steps.date.outputs.date }} + push: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 1541e61d80cb4a20fad4baec12277cdcf19958a9 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 21 May 2026 16:08:44 +0200 Subject: [PATCH 6/6] chore: Fail nightly publish runs when today's manifest is unavailable --- .github/workflows/nightly.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 3e76d21..6d5ac81 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -96,7 +96,25 @@ jobs: - name: Compute nightly date id: date - run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT" + env: + EVENT_NAME: ${{ github.event_name }} + run: | + set -euo pipefail + DATE=$(date -u +%Y-%m-%d) + URL="https://static.rust-lang.org/dist/${DATE}/channel-rust-nightly.toml" + if ! curl -fsI -o /dev/null "$URL"; then + case "${EVENT_NAME}" in + push|pull_request) + echo "Today's nightly manifest is not yet published; falling back to yesterday." >&2 + DATE=$(date -u -d 'yesterday' +%Y-%m-%d) + ;; + *) + echo "Today's nightly manifest is not yet published; refusing to publish a stale nightly." >&2 + exit 1 + ;; + esac + fi + echo "date=${DATE}" >> "$GITHUB_OUTPUT" - name: Build dated tag list id: dated_tags