Open a Rust release PR #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Open a Rust release PR | |
on: | |
workflow_dispatch: | |
inputs: | |
crate: | |
description: Crate to release | |
required: true | |
type: choice | |
options: | |
- all | |
- aligned-sized | |
- light-heap | |
- light-utils | |
- light-bounded-vec | |
- light-hasher | |
- light-macros | |
- light-hash-set | |
- light-merkle-tree-reference | |
- light-concurrent-merkle-tree | |
- light-indexed-merkle-tree | |
- light-prover-client | |
- light-verifier | |
- account-compression | |
- light-registry | |
- light-system-program | |
- light-compressed-token | |
- light-test-utils | |
- light-wasm-hasher | |
version: | |
description: Version to release | |
required: true | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
- release | |
- rc | |
- beta | |
- alpha | |
jobs: | |
make-release-pr: | |
permissions: | |
id-token: write | |
pull-requests: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- uses: chainguard-dev/actions/setup-gitsign@main | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Install cargo-release | |
shell: bash | |
run: | | |
VERSION="$(curl --silent "https://api.github.com/repos/crate-ci/cargo-release/releases/latest" | jq -r .tag_name)" | |
pushd /tmp | |
wget https://github.com/crate-ci/cargo-release/releases/download/"$VERSION"/cargo-release-"$VERSION"-x86_64-unknown-linux-gnu.tar.gz | |
tar -xzvf cargo-release-"$VERSION"-x86_64-unknown-linux-gnu.tar.gz --wildcards '*cargo-release' --strip-components=1 | |
cp cargo-release "$HOME"/.cargo/bin | |
popd | |
- name: Setup pnpm | |
uses: pnpm/[email protected] | |
with: | |
run_install: false | |
- name: Bump all crate versions | |
if: inputs.crate == 'all' | |
run: | | |
cargo release version --execute --no-confirm \ | |
"${{ inputs.version }}" | |
- name: Create pull request for all crates | |
if: inputs.crate == 'all' | |
uses: peter-evans/create-pull-request@v6 | |
env: | |
COMMIT_MESSAGE: "chore: Bump version of all Rust projects" | |
with: | |
commit-message: ${{ env.COMMIT_MESSAGE }} | |
title: ${{ env.COMMIT_MESSAGE }} | |
branch: "bump-all-rust" | |
labels: "version bump" | |
- name: Checkout the PR branch all | |
if: inputs.crate == 'all' | |
uses: actions/checkout@v4 | |
with: | |
ref: "bump-all-rust" | |
fetch-depth: 0 | |
- name: Pull latest changes all | |
if: inputs.crate == 'all' | |
run: git pull | |
- name: Show current branch and commit all | |
if: inputs.crate == 'all' | |
run: | | |
echo "Current branch:" | |
git branch --show-current | |
echo "Latest commit:" | |
git log -1 | |
- name: Setup and build nocheck all | |
if: inputs.crate == 'all' | |
uses: ./.github/actions/setup-and-build-nocheck | |
with: | |
branch: "bump-all-rust" | |
- name: Bump crate version for single crate | |
if: inputs.crate != 'all' | |
run: | | |
cargo release version --execute --no-confirm \ | |
-p "${{ inputs.crate }}" "${{ inputs.version }}" | |
- name: Create pull request for single crate | |
if: inputs.crate != 'all' | |
uses: peter-evans/create-pull-request@v6 | |
env: | |
COMMIT_MESSAGE: "chore: Bump version of Rust project ${{ inputs.crate }}" | |
with: | |
commit-message: ${{ env.COMMIT_MESSAGE }} | |
title: ${{ env.COMMIT_MESSAGE }} | |
branch: "bump-${{ inputs.crate }}" | |
labels: "version bump" | |
- name: Checkout the PR branch for single crate | |
if: inputs.crate != 'all' | |
uses: actions/checkout@v4 | |
with: | |
ref: "bump-${{ inputs.crate }}" | |
fetch-depth: 0 | |
- name: Pull latest changes for single crate | |
if: inputs.crate != 'all' | |
run: git pull | |
- name: Show Git Status and Diff for single crate | |
if: inputs.crate != 'all' | |
run: | | |
git status | |
git diff | |
- name: Commit IDL and other changes | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git add -A | |
if git diff --staged --quiet; then | |
echo "No changes to commit." | |
else | |
git commit -m "Include IDL and other changes post build" | |
if [ "${{ github.event.inputs.crate }}" == "all" ]; then | |
BRANCH_NAME="bump-all-rust" | |
else | |
BRANCH_NAME="bump-${{ github.event.inputs.crate }}" | |
fi | |
git push origin "$BRANCH_NAME" | |
fi |