Skip to content

Commit bbf9f08

Browse files
committed
ci: add workflow to create a PR for crate bumps
Changelog-None
1 parent 8ea4439 commit bbf9f08

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/crate-bump.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Bump Rust 🦀 crate versions
2+
3+
on:
4+
push:
5+
tags:
6+
- 'cln-plugin-v[0-9]+.[0-9]+.[0-9]+'
7+
- 'cln-rpc-v[0-9]+.[0-9]+.[0-9]+'
8+
- 'cln-grpc-v[0-9]+.[0-9]+.[0-9]+'
9+
workflow_dispatch:
10+
inputs:
11+
dist-location:
12+
description: 'Distribution location'
13+
type: choice
14+
options:
15+
- rc cln-plugin
16+
- patch cln-plugin
17+
- minor cln-plugin
18+
- major cln-plugin
19+
- rc cln-rpc
20+
- patch cln-rpc
21+
- minor cln-rpc
22+
- major cln-rpc
23+
- rc cln-grpc
24+
- patch cln-grpc
25+
- minor cln-grpc
26+
- major cln-grpc
27+
default: 'rc cln-rpc'
28+
required: false
29+
30+
jobs:
31+
bump:
32+
runs-on: ubuntu-latest
33+
timeout-minutes: 120
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
with:
38+
# Need to fetch entire history in order to locate the version tag
39+
fetch-depth: 0
40+
41+
- name: Check version tag
42+
run: >-
43+
git describe --tags --always --dirty=-modded --abbrev=7
44+
45+
- name: Set up values
46+
id: set-values
47+
run: |
48+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49+
DISTLOCATION=$(echo ${{ github.event.inputs.dist-location }} | cut -d' ' -f1)
50+
CRATE_NAME=$(echo ${{ github.event.inputs.dist-location }} | cut -d' ' -f2)
51+
BRANCH_NAME="bump-$CRATE_NAME-$DISTLOCATION-version-$(date +%Y%m%d-%H%M%S)"
52+
elif [ "${{ github.event_name }}" = "push" ]; then
53+
CRATE_NAME=$(echo ${{ github.ref_name }} | rev | cut -d'-' -f2- | rev)
54+
VERSION=$(echo ${{ github.ref_name }} | rev | cut -d'-' -f1 | rev | sed 's/^v//')
55+
BRANCH_NAME="bump-$CRATE_NAME-version-$VERSION-$(date +%Y%m%d-%H%M%S)"
56+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
57+
else
58+
echo "Neither tag nor workflow dispatch"
59+
exit 1
60+
fi
61+
echo "DISTLOCATION=$DISTLOCATION" >> $GITHUB_OUTPUT
62+
echo "CRATE_NAME=$CRATE_NAME" >> $GITHUB_OUTPUT
63+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
64+
echo "EVENT DISTLOCATION: ${{ github.event.inputs.dist-location }}"
65+
echo "DISTRIBUTION LOCATION: $DISTLOCATION"
66+
67+
- name: Setup rust
68+
uses: dtolnay/rust-toolchain@stable
69+
70+
- name: Install cargo binstall
71+
uses: cargo-bins/cargo-binstall@main
72+
73+
- name: Install cargo release
74+
run: |
75+
cargo binstall cargo-release
76+
77+
- name: Bump unspecific version
78+
if: github.repository == 'ElementsProject/lightning' && steps.set-values.outputs.DISTLOCATION != ''
79+
run: |
80+
cargo release version -p ${{ steps.set-values.outputs.CRATE_NAME }} ${{ steps.set-values.outputs.DISTLOCATION }} --execute --no-confirm
81+
82+
- name: Bump specific release version
83+
if: github.repository == 'ElementsProject/lightning' && steps.set-values.outputs.DISTLOCATION == '' && steps.set-values.outputs.VERSION != ''
84+
run: |
85+
cargo release version -p ${{ steps.set-values.outputs.CRATE_NAME }} ${{ steps.set-values.outputs.VERSION }} --execute --no-confirm
86+
87+
- name: Create Pull Request for workflow_dispatch
88+
if: github.repository == 'ElementsProject/lightning' && github.event_name == 'workflow_dispatch'
89+
uses: peter-evans/create-pull-request@v7
90+
with:
91+
token: ${{ secrets.GITHUB_TOKEN }}
92+
commit-message: "${{ steps.set-values.outputs.CRATE_NAME }}: Bump the ${{ steps.set-values.outputs.DISTLOCATION }} version"
93+
title: "${{ steps.set-values.outputs.CRATE_NAME }}: Bump the ${{ steps.set-values.outputs.DISTLOCATION }} version"
94+
body: |
95+
Triggered manually with option: ${{ github.event.inputs.dist-location }}
96+
branch: "${{ steps.set-values.outputs.BRANCH_NAME }}"
97+
base: master
98+
labels: version-bump, automated
99+
delete-branch: true
100+
101+
- name: Create Pull Request for tag
102+
if: github.repository == 'ElementsProject/lightning' && github.event_name == 'push'
103+
uses: peter-evans/create-pull-request@v7
104+
with:
105+
token: ${{ secrets.GITHUB_TOKEN }}
106+
commit-message: "${{ steps.set-values.outputs.CRATE_NAME }}: Bump to version ${{ steps.set-values.outputs.VERSION }}"
107+
title: "${{ steps.set-values.outputs.CRATE_NAME }}: Bump to version ${{ steps.set-values.outputs.VERSION }}"
108+
body: |
109+
Triggered by tag: ${{ github.ref_name }}
110+
branch: "${{ steps.set-values.outputs.BRANCH_NAME }}"
111+
base: master
112+
labels: version-bump, automated
113+
delete-branch: true

0 commit comments

Comments
 (0)