-
Notifications
You must be signed in to change notification settings - Fork 47
161 lines (145 loc) · 4.71 KB
/
release-pr-rust.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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