Skip to content

Add release update workflow #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/update-toolhive-reference.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Update ToolHive Reference Docs

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-reference:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0

- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Run update-toolhive-reference.sh and capture version
id: imports
run: |
chmod +x scripts/update-toolhive-reference.sh
scripts/update-toolhive-reference.sh

- name: Check for changes
id: git-diff
run: |
git add .
if git diff --cached --quiet; then
echo "No changes to commit."
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Changes detected."
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Create branch, commit, and push
if: steps.git-diff.outputs.changed == 'true'
run: |
BRANCH=update-toolhive-reference-${VERSION}
git checkout -b "$BRANCH"
git commit -am "Update ToolHive reference docs for ${VERSION}"
git push origin "$BRANCH"
env:
VERSION: ${{ steps.imports.outputs.version }}

- name: Create Pull Request
if: steps.git-diff.outputs.changed == 'true'
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6
with:
branch: update-toolhive-reference-${{ steps.imports.outputs.version }}
title: |
Update ToolHive reference docs for ${{ steps.imports.outputs.version }}
body: |
This PR updates the ToolHive CLI and API reference documentation to the latest release: ${{ steps.imports.outputs.version }}.
commit-message: |
Update ToolHive reference docs for ${{ steps.imports.outputs.version }}
delete-branch: true
13 changes: 10 additions & 3 deletions scripts/get-imports.sh → scripts/update-toolhive-reference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@ if [ ! -d "$STATIC_DIR" ]; then
exit 1
fi

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

if [ -z "$LATEST_RELEASE_TARBALL" ]; then
echo "Failed to get the latest release tarball URL"
echo "Failed to get the latest release tarball URL for ${LATEST_RELEASE_VERSION}"
exit 1
fi

# Output the latest release version for use in CI workflows
if [ ! -z "$GITHUB_OUTPUT" ]; then
echo "version=$LATEST_RELEASE_VERSION" >> "$GITHUB_OUTPUT"
fi

rm -rf ${IMPORT_DIR}/toolhive
mkdir -p ${IMPORT_DIR}/toolhive

echo "Fetching the latest ToolHive release from: $LATEST_RELEASE_TARBALL"
echo "Fetching the latest ToolHive release (${LATEST_RELEASE_VERSION}) from: $LATEST_RELEASE_TARBALL"
echo "Importing to: $IMPORT_DIR"

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