mirror of
https://github.com/react/react.git
synced 2026-09-28 21:25:11 +08:00
## Summary - configure the React Compiler Rust crates as a Cargo workspace with shared package metadata and versioned internal dependencies - add workflows to open a signed version-bump pull request and publish the workspace through crates.io trusted publishing - add release scripts and contributor documentation for versioning, validation, and publishing ## Test plan - Run `cargo check --locked --workspace` from `compiler/`. - Run **(Compiler) Publish Rust Crates** from the Actions tab with **Dry run** enabled; confirm every workspace crate packages successfully without publishing. - Run **(Compiler) Update Rust Crate Version** with a test version; confirm it verifies one shared version and opens a signed version-bump pull request containing the updated workspace manifest and lockfile.
63 lines
1.9 KiB
Bash
Executable File
63 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
: "${GH_TOKEN:?GH_TOKEN is required}"
|
|
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
|
|
: "${BASE_SHA:?BASE_SHA is required}"
|
|
: "${VERSION:?VERSION is required}"
|
|
|
|
cd "$(dirname "$0")/../.."
|
|
|
|
branch="automated/rust-crates-$VERSION"
|
|
gh api "repos/$GITHUB_REPOSITORY/git/refs" \
|
|
--method POST \
|
|
--field ref="refs/heads/$branch" \
|
|
--field sha="$BASE_SHA"
|
|
|
|
additions=$(jq -n \
|
|
--arg manifest "$(base64 < compiler/Cargo.toml | tr -d '\n')" \
|
|
--arg lockfile "$(base64 < compiler/Cargo.lock | tr -d '\n')" \
|
|
'[
|
|
{path: "compiler/Cargo.toml", contents: $manifest},
|
|
{path: "compiler/Cargo.lock", contents: $lockfile}
|
|
]')
|
|
graphql_input=$(jq -n \
|
|
--arg query 'mutation($input: CreateCommitOnBranchInput!) {
|
|
createCommitOnBranch(input: $input) {
|
|
commit { oid }
|
|
}
|
|
}' \
|
|
--arg repository "$GITHUB_REPOSITORY" \
|
|
--arg branch "$branch" \
|
|
--arg headline "Update Rust compiler crates to $VERSION" \
|
|
--arg expectedHeadOid "$BASE_SHA" \
|
|
--argjson additions "$additions" \
|
|
'{
|
|
query: $query,
|
|
variables: {
|
|
input: {
|
|
branch: {
|
|
repositoryNameWithOwner: $repository,
|
|
branchName: $branch
|
|
},
|
|
message: {headline: $headline},
|
|
fileChanges: {additions: $additions},
|
|
expectedHeadOid: $expectedHeadOid
|
|
}
|
|
}
|
|
}')
|
|
commit=$(printf '%s' "$graphql_input" | gh api graphql \
|
|
--input - \
|
|
--jq '.data.createCommitOnBranch.commit.oid')
|
|
|
|
if [ "$(gh api "repos/$GITHUB_REPOSITORY/commits/$commit" --jq '.commit.verification.verified')" != "true" ]; then
|
|
echo "GitHub did not sign commit $commit" >&2
|
|
exit 1
|
|
fi
|
|
|
|
gh pr create \
|
|
--base main \
|
|
--head "$branch" \
|
|
--title "Update Rust compiler crates to $VERSION" \
|
|
--body "Update all Rust compiler crates and their internal dependency requirements to \`$VERSION\`." |