Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement release process for rustup #84

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
00e1a90
Fix error message when parsing actions
jdno May 20, 2024
0a64d25
Create action for rustup
jdno May 20, 2024
8d4a447
Implement release process for rustup
jdno May 22, 2024
d40ff45
Extract channel check for Rustup into function
jdno Jun 27, 2024
b803170
Get latest commit from Rustup's stable branch
jdno Jun 27, 2024
da3164d
Fetch next Rustup version from GitHub
jdno Jun 27, 2024
49980a3
Download Rustup artifacts for a given commit
jdno Jun 27, 2024
c4cff77
Pass Rustup version to archive and manifest
jdno Jun 27, 2024
7ccff04
Update documentation for Rustup release process
jdno Jun 27, 2024
ede844c
Refactor run script to execute different local releases
jdno Sep 24, 2024
1e516af
Support other platforms than Linux
jdno Sep 25, 2024
b1dd2a2
Download Rustup files from CDN
jdno Oct 1, 2024
b843e51
Build promote-release inside the container if necessary
jdno Oct 1, 2024
f5c3c5e
Get download path from config
jdno Oct 1, 2024
a947033
Fix upload directory
jdno Oct 1, 2024
883b5ed
Get version from user-provided commit
jdno Oct 1, 2024
ad86e13
Don't require GitHub credentials to fetch Rustup metadata
jdno Oct 1, 2024
694e3a4
Create rustup-builds bucket in local environment
jdno Oct 1, 2024
8132d69
Fix upload destination for Rustup archives
jdno Oct 1, 2024
89f7324
Fix upload destination for stable Rustup release
jdno Oct 1, 2024
f82d531
Fix upload destination for Rustup manifest
jdno Oct 1, 2024
9b7dba8
Configure environment to run Rustup releases locally
jdno Oct 1, 2024
5aad90d
Set up CI workflows for refactored actions
jdno Oct 1, 2024
a52f975
Fix required jobs for deployments
jdno Oct 1, 2024
839b35d
Merge branch 'master' into promote-rustup
jdno Oct 2, 2024
ad0c357
Fix unnecessary borrow warnings
jdno Oct 3, 2024
fd3f06d
Cut beta releases for Rustup from the stable branch
jdno Oct 3, 2024
a3a0d89
Allow Rustup version to be overridden in tests
jdno Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

local:
release:
name: Local release
runs-on: ubuntu-latest

Expand All @@ -48,7 +48,7 @@ jobs:
run: docker compose up -d

- name: Run the local release process for channel ${{ matrix.channel }}
run: ./run.sh ${{ matrix.channel }}
run: ./run.sh release ${{ matrix.channel }}

- name: Validate the generated signatures
run: docker compose exec -T local /src/local/check-signature.sh ${{ matrix.channel }}
Expand All @@ -61,6 +61,36 @@ jobs:
env:
RUSTUP_DIST_SERVER: http://localhost:9000/static

rustup:
name: Local rustup
runs-on: ubuntu-latest

env:
PROMOTE_RELEASE_RUSTUP_OVERRIDE_VERSION: 99.0.0

strategy:
fail-fast: false
matrix:
channel: [stable, beta]

steps:
- name: Clone the source code
uses: actions/checkout@v3

- name: Ensure Rust Stable is up to date
run: rustup self update && rustup update stable

- name: Start the local environment
run: docker compose up -d

- name: Run the local release process for channel ${{ matrix.channel }}
run: ./run.sh rustup ${{ matrix.channel }}

- name: Update Rustup from the local environment
run: rustup self update
env:
RUSTUP_UPDATE_ROOT: http://localhost:9000/static/rustup

docker:
name: Build Docker image
runs-on: ubuntu-latest
Expand Down Expand Up @@ -90,7 +120,7 @@ jobs:
permissions:
id-token: write

needs: [test, local, docker]
needs: [test, release, rustup, docker]
if: github.event_name == 'push' && github.repository == 'rust-lang/promote-release' && github.ref == 'refs/heads/master'

steps:
Expand Down
8 changes: 5 additions & 3 deletions local/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
git \
gnupg \
jq \
libssl-dev \
openssl \
pkg-config \
python3 \
socat

# Install rustup while removing the pre-installed stable toolchain.
RUN curl https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init >/tmp/rustup-init && \
chmod +x /tmp/rustup-init && \
/tmp/rustup-init -y --no-modify-path --profile minimal --default-toolchain stable && \
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable && \
/root/.cargo/bin/rustup toolchain remove stable
ENV PATH=/root/.cargo/bin:$PATH

Expand Down
8 changes: 8 additions & 0 deletions local/run.sh → local/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ for file in "${DOWNLOAD_STANDALONE[@]}"; do
download "${file}"
done

# Build the promote-release binary if it hasn't been pre-built
if [[ ! -f "/src/target/release/promote-release" ]]; then
echo "==> building promote-release"
cd /src
cargo build --release
cd ..
fi

echo "==> configuring the environment"
# Point to the right GnuPG environment
export GNUPGHOME=/persistent/gpg-home
Expand Down
98 changes: 98 additions & 0 deletions local/rustup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

# This script is executed at the start of each local release for Rustup, and
# prepares the environment by copying the artifacts built by CI onto the MinIO
# instance. Then, it starts promote-release with the right flags.

set -euo pipefail
IFS=$'\n\t'

RUSTUP_REPO="https://github.com/rust-lang/rustup"
RUSTUP_DEFAULT_BRANCH="master"

# S3 bucket from which to download the Rustup artifacts
S3_BUCKET="rustup-builds"

# CDN from which to download the CI artifacts
DOWNLOAD_BASE="https://rustup-builds.rust-lang.org"

# The artifacts for the following targets will be downloaded and copied during
# the release process. At least one target is required.
DOWNLOAD_TARGETS=(
"x86_64-unknown-linux-gnu"
)

# The following files will be downloaded and put into the local MinIO instance.
DOWNLOAD_FILES=(
"rustup-init"
"rustup-init.sha256"
"rustup-setup"
"rustup-setup.sha256"
)

channel="$1"
override_commit="$2"

if [[ "${override_commit}" = "" ]]; then
echo "==> detecting the last Rustup commit on the default branch"
commit="$(git ls-remote "${RUSTUP_REPO}" | grep "refs/heads/${RUSTUP_DEFAULT_BRANCH}" | awk '{print($1)}')"
else
echo "=>> using overridden commit ${override_commit}"
commit="${override_commit}"
fi

for target in "${DOWNLOAD_TARGETS[@]}"; do
if ! mc stat "local/artifacts/builds/${commit}/dist/${target}" >/dev/null 2>&1; then
echo "==> copying ${target} from S3"

for file in "${DOWNLOAD_FILES[@]}"; do
if curl -Lo /tmp/component "${DOWNLOAD_BASE}/${commit}/dist/${target}/${file}" --fail; then
mc cp /tmp/component "local/artifacts/builds/${commit}/dist/${target}/${file}" >/dev/null
fi
done
else
echo "==> reusing cached ${target} target"
fi
done

# Build the promote-release binary if it hasn't been pre-built
if [[ ! -f "/src/target/release/promote-release" ]]; then
echo "==> building promote-release"
cd /src
cargo build --release
cd ..
fi

echo "==> configuring the environment"

# Release Rustup
export PROMOTE_RELEASE_ACTION="promote-rustup"

# Point to the right GnuPG environment
export GNUPGHOME=/persistent/gpg-home

## Environment variables also used in prod releases
export AWS_ACCESS_KEY_ID="access_key"
export AWS_SECRET_ACCESS_KEY="secret_key"
export PROMOTE_RELEASE_CHANNEL="${channel}"
export PROMOTE_RELEASE_CLOUDFRONT_DOC_ID=""
export PROMOTE_RELEASE_CLOUDFRONT_STATIC_ID=""
export PROMOTE_RELEASE_DOWNLOAD_BUCKET="rustup-builds"
export PROMOTE_RELEASE_DOWNLOAD_DIR="builds"
export PROMOTE_RELEASE_GPG_KEY_FILE=""
export PROMOTE_RELEASE_GPG_PASSWORD_FILE=""
export PROMOTE_RELEASE_UPLOAD_ADDR=""
export PROMOTE_RELEASE_UPLOAD_BUCKET="static"
export PROMOTE_RELEASE_UPLOAD_STORAGE_CLASS="STANDARD"
export PROMOTE_RELEASE_UPLOAD_DIR="rustup"

## Environment variables used only by local releases
export PROMOTE_RELEASE_S3_ENDPOINT_URL="http://minio:9000"

# Conditional environment variables
if [[ "${override_commit}" != "" ]]; then
export PROMOTE_RELEASE_OVERRIDE_COMMIT="${override_commit}"
fi

echo "==> starting promote-release"
/src/target/release/promote-release /persistent/release "${channel}"
8 changes: 4 additions & 4 deletions local/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MINIO_URL="http://${MINIO_HOST}:${MINIO_PORT}"
MINIO_ACCESS_KEY="access_key"
MINIO_SECRET_KEY="secret_key"

MINIO_BUCKETS=( "static" "artifacts" )
MINIO_BUCKETS=( "static" "artifacts" "rustup-builds" )

# Quit immediately when docker-compose receives a Ctrl+C
trap exit EXIT
Expand Down Expand Up @@ -77,9 +77,9 @@ cat <<EOF

To start the release process locally, run either:

./run.sh nightly
./run.sh beta
./run.sh stable
./run.sh release nightly
./run.sh release beta
./run.sh release stable

To use a release produced locally, set this environment variable when
interacting with rustup:
Expand Down
32 changes: 25 additions & 7 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,28 @@
set -euo pipefail
IFS=$'\n\t'

if [[ "$#" -lt 1 ]] || [[ "$#" -gt 2 ]]; then
echo "Usage: $0 <channel> [commit]"
if [[ "$#" -lt 1 ]]; then
echo "Usage: $0 <release|rustup>"
exit 1
fi
command="$1"

if [[ "${command}" == "release" ]]; then
if [[ "$#" -lt 2 ]] || [[ "$#" -gt 3 ]]; then
echo "Usage: $0 release <stable|dev|nightly> [commit]"
exit 1
fi
fi
channel="$1"
override_commit="${2-}"

if [[ "${command}" == "rustup" ]]; then
if [[ "$#" -ne 2 ]]; then
echo "Usage: $0 rustup <stable|dev> [commit]"
exit 1
fi
fi

channel="$2"
override_commit="${3-}"

container_id="$(docker compose ps -q local)"
if [[ "${container_id}" == "" ]]; then
Expand All @@ -27,8 +43,10 @@ if [[ "${container_status}" != "running" ]]; then
exit 1
fi

# Ensure the release build is done
cargo build --release
# Pre-built the binary if the host and Docker environments match
if [[ "$(uname)" == "Linux" ]]; then
cargo build --release
fi

# Run the command inside the docker environment.
docker compose exec -T local /src/local/run.sh "${channel}" "${override_commit}"
docker compose exec -T local "/src/local/${command}.sh" "${channel}" "${override_commit}"
12 changes: 11 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ impl std::fmt::Display for Channel {
}
}

// Allow all variant names to start with `Promote`
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub(crate) enum Action {
/// This is the default action, what we'll do if the environment variable
Expand All @@ -64,6 +66,13 @@ pub(crate) enum Action {
/// * Create a rust-lang/cargo branch for the appropriate beta commit.
/// * Post a PR against the newly created beta branch bump src/ci/channel to `beta`.
PromoteBranches,

/// This promotes a new rustup release:
///
/// * Copy binaries into archives
/// * Copy binaries from dev-static to production
/// * Update dev release number
PromoteRustup,
}

impl FromStr for Action {
Expand All @@ -73,7 +82,8 @@ impl FromStr for Action {
match input {
"promote-release" => Ok(Action::PromoteRelease),
"promote-branches" => Ok(Action::PromoteBranches),
_ => anyhow::bail!("unknown channel: {}", input),
"promote-rustup" => Ok(Action::PromoteRustup),
_ => anyhow::bail!("unknown action: {}", input),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod discourse;
mod fastly;
mod github;
mod recompress;
mod rustup;
mod sign;
mod smoke_test;

Expand Down Expand Up @@ -76,6 +77,7 @@ impl Context {
match self.config.action {
config::Action::PromoteRelease => self.do_release()?,
config::Action::PromoteBranches => self.do_branching()?,
config::Action::PromoteRustup => self.promote_rustup()?,
}
Ok(())
}
Expand Down
Loading
Loading