Skip to content

Commit 3f43445

Browse files
authored
Add release update workflow (#2)
Adds a GHA workflow to refresh ToolHive release docs
1 parent a437003 commit 3f43445

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Update ToolHive Reference Docs
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
update-reference:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Git
20+
run: |
21+
git config --global user.name "github-actions[bot]"
22+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
23+
24+
- name: Run update-toolhive-reference.sh and capture version
25+
id: imports
26+
run: |
27+
chmod +x scripts/update-toolhive-reference.sh
28+
scripts/update-toolhive-reference.sh
29+
30+
- name: Check for changes
31+
id: git-diff
32+
run: |
33+
git add .
34+
if git diff --cached --quiet; then
35+
echo "No changes to commit."
36+
echo "changed=false" >> $GITHUB_OUTPUT
37+
else
38+
echo "Changes detected."
39+
echo "changed=true" >> $GITHUB_OUTPUT
40+
fi
41+
42+
- name: Create branch, commit, and push
43+
if: steps.git-diff.outputs.changed == 'true'
44+
run: |
45+
BRANCH=update-toolhive-reference-${VERSION}
46+
git checkout -b "$BRANCH"
47+
git commit -am "Update ToolHive reference docs for ${VERSION}"
48+
git push origin "$BRANCH"
49+
env:
50+
VERSION: ${{ steps.imports.outputs.version }}
51+
52+
- name: Create Pull Request
53+
if: steps.git-diff.outputs.changed == 'true'
54+
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6
55+
with:
56+
branch: update-toolhive-reference-${{ steps.imports.outputs.version }}
57+
title: |
58+
Update ToolHive reference docs for ${{ steps.imports.outputs.version }}
59+
body: |
60+
This PR updates the ToolHive CLI and API reference documentation to the latest release: ${{ steps.imports.outputs.version }}.
61+
commit-message: |
62+
Update ToolHive reference docs for ${{ steps.imports.outputs.version }}
63+
delete-branch: true

scripts/get-imports.sh renamed to scripts/update-toolhive-reference.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,24 @@ if [ ! -d "$STATIC_DIR" ]; then
2020
exit 1
2121
fi
2222

23-
LATEST_RELEASE_TARBALL=$(curl -s https://api.github.com/repos/stacklok/toolhive/releases/latest | grep "tarball_url" | cut -d '"' -f 4)
23+
RELEASE_JSON=$(curl -s https://api.github.com/repos/stacklok/toolhive/releases/latest)
24+
LATEST_RELEASE_TARBALL=$(echo "$RELEASE_JSON" | grep "tarball_url" | cut -d '"' -f 4)
25+
LATEST_RELEASE_VERSION=$(echo "$RELEASE_JSON" | grep '"tag_name"' | cut -d '"' -f 4)
2426

2527
if [ -z "$LATEST_RELEASE_TARBALL" ]; then
26-
echo "Failed to get the latest release tarball URL"
28+
echo "Failed to get the latest release tarball URL for ${LATEST_RELEASE_VERSION}"
2729
exit 1
2830
fi
2931

32+
# Output the latest release version for use in CI workflows
33+
if [ ! -z "$GITHUB_OUTPUT" ]; then
34+
echo "version=$LATEST_RELEASE_VERSION" >> "$GITHUB_OUTPUT"
35+
fi
36+
3037
rm -rf ${IMPORT_DIR}/toolhive
3138
mkdir -p ${IMPORT_DIR}/toolhive
3239

33-
echo "Fetching the latest ToolHive release from: $LATEST_RELEASE_TARBALL"
40+
echo "Fetching the latest ToolHive release (${LATEST_RELEASE_VERSION}) from: $LATEST_RELEASE_TARBALL"
3441
echo "Importing to: $IMPORT_DIR"
3542

3643
curl -sL "$LATEST_RELEASE_TARBALL" | tar xz --strip-components=1 -C ./imports/toolhive

0 commit comments

Comments
 (0)