Workflow file for this run
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-circuitlib-rs | ||
- 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 | ||
with: | ||
submodules: true | ||
- 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: Bump all crate versions | ||
if: inputs.crate == 'all' | ||
run: | | ||
cargo release version --execute --no-confirm \ | ||
"${{ inputs.version }}" | ||
- name: Bump crate version | ||
if: inputs.crate != 'all' | ||
run: | | ||
cargo release version --execute --no-confirm \ | ||
-p "${{ inputs.crate }}" "${{ 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 | ||
if: inputs.crate == 'all' | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "bump-all-rust" | ||
fetch-depth: 0 | ||
- name: Create pull request for 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 specific crate | ||
if: inputs.crate != 'all' | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "bump-${{ inputs.crate }}" | ||
fetch-depth: 0 | ||
- name: Pull latest changes | ||
run: git pull | ||
- name: Show current branch and commit | ||
run: | | ||
echo "Current branch:" | ||
git branch --show-current | ||
echo "Latest commit:" | ||
git log -1 | ||
- name: Setup pnpm | ||
uses: pnpm/[email protected] | ||
with: | ||
version: 8 | ||
run_install: false | ||
- name: Setup and build nocheck | ||
uses: ./.github/actions/setup-and-build-nocheck | ||
with: | ||
branch: ${{ inputs.crate == 'all' ? 'bump-all-rust' : format('bump-{0}', inputs.crate) }} | ||
- name: Show Git Status and Diff | ||
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 |