Skip to content

Commit c23f984

Browse files
committed
Workflow for bump rust templates sdk dependency
Signed-off-by: Brian Hardock <[email protected]>
1 parent 9be1c92 commit c23f984

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bump Spin Rust Templates SDK Dependency
2+
3+
on:
4+
repository_dispatch:
5+
types:
6+
- rust-sdk-release
7+
8+
jobs:
9+
create-pr:
10+
name: Create PR with Spin Rust Templates SDK Dependency Bump
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Bump Rust Templates SDK Dependency
16+
shell: bash
17+
run: ./scripts/bump-rust-tpl-sdk-dep.sh ${{ github.event.client_payload.version }}
18+
19+
- name: Import GPG key
20+
uses: crazy-max/ghaction-import-gpg@v6
21+
with:
22+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
23+
passphrase: ${{ secrets.PASSPHRASE }}
24+
git_user_signingkey: true
25+
git_commit_gpgsign: true
26+
27+
- name: Create Pull Request
28+
uses: peter-evans/create-pull-request@v7
29+
with:
30+
commit-message: "chore(rust-templates): bump Spin Rust SDK to ${{ github.event.client_payload.version }}"
31+
title: "chore(rust-templates): bump Spin Rust SDK to ${{ github.event.client_payload.version }}"
32+
body: Update the Spin Rust Templates SDK dependency to ${{ github.event.client_payload.version }}
33+
branch: bump-spin-rust-sdk-${{ github.event.client_payload.version }}
34+
base: main
35+
delete-branch: true
36+
committer: spinframeworkbot <[email protected]>
37+
author: spinframeworkbot <[email protected]>
38+
signoff: true
39+
token: ${{ secrets.PAT }}

scripts/bump-rust-tpl-sdk-dep.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
VERSION=$1
5+
6+
# -i syntax differs between GNU and Mac sed; this usage is supported by both
7+
SED_INPLACE='sed -i.bak'
8+
9+
# cleanup
10+
trap 'find templates -name "*.bak" -delete' EXIT
11+
12+
usage() {
13+
echo "Usage: $0 <VERSION>"
14+
echo "Updates the Rust templates SDK dependency to the specified version"
15+
echo "Example: $0 6.0.0"
16+
}
17+
18+
if [[ $# -ne 1 ]]
19+
then
20+
usage
21+
exit 1
22+
fi
23+
24+
# Ensure version is an 'official' release
25+
if [[ ! "${VERSION}" =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]
26+
then
27+
echo "VERSION doesn't match [0-9]+.[0-9]+.[0-9]+ and may be a prerelease; skipping."
28+
exit 1
29+
fi
30+
31+
32+
# Update the version in the Cargo.toml.tmpl files for each Rust template
33+
# find templates -type f -path "templates/*-rust/content/Cargo.toml.tmpl" -exec $SED_INPLACE "s/spin-sdk = \".*\"/spin-sdk = \"$VERSION\"/" {} +
34+
find templates -type f -path "templates/*-rust/content/Cargo.toml.tmpl" -exec $SED_INPLACE "/^\[dependencies\]/,/^\[/ s/^spin-sdk = \".*\"/spin-sdk = \"${VERSION}\"/" {} +

0 commit comments

Comments
 (0)