Skip to content

Commit d31c6bd

Browse files
Workflow for bump rust templates sdk dependency (#3255)
Signed-off-by: Brian Hardock <[email protected]>
1 parent 9be1c92 commit d31c6bd

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-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-template-sdk.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-template-sdk.sh

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