Skip to content

Commit e4bcf97

Browse files
committed
chore: update swagger and generated files by renovate and gh action
1 parent 1b33465 commit e4bcf97

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Renovate Post-Upgrade
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- "scripts/generate-swagger.ts"
8+
9+
permissions:
10+
contents: write
11+
pull-requests: read
12+
13+
jobs:
14+
regenerate-client:
15+
name: Regenerate API Client
16+
runs-on: ubuntu-latest
17+
# Only run for Renovate PRs
18+
if: github.actor == 'renovate[bot]'
19+
steps:
20+
- name: Checkout PR branch
21+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
22+
with:
23+
ref: ${{ github.head_ref }}
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Setup
27+
uses: ./.github/actions/setup
28+
29+
- name: Generate API Client
30+
run: pnpm run generate-client
31+
32+
- name: Format
33+
run: pnpm run format
34+
35+
- name: Check for changes
36+
id: changes
37+
run: |
38+
if [[ -n $(git status --porcelain) ]]; then
39+
echo "has_changes=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "has_changes=false" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Commit and push changes
45+
if: steps.changes.outputs.has_changes == 'true'
46+
run: |
47+
git config --global user.name "github-actions[bot]"
48+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
49+
git add swagger.json src/generated/
50+
git commit -m "chore: regenerate API client for updated registry server version"
51+
git push

renovate.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,20 @@
44
"labels": ["dependencies"],
55
"prConcurrentLimit": 3,
66
"timezone": "Europe/London",
7-
"schedule": ["after 01:00 and before 07:00 every weekday"]
7+
"schedule": ["after 01:00 and before 07:00 every weekday"],
8+
"customManagers": [
9+
{
10+
"customType": "regex",
11+
"fileMatch": ["^scripts/generate-swagger\\.ts$"],
12+
"matchStrings": [
13+
"renovate: datasource=(?<datasource>\\S+) depName=(?<depName>\\S+) versioning=(?<versioning>\\S+)\\s*\\n\\s*\\*/\\s*\\n.*?=\\s*[\"'](?<currentValue>v[\\d.]+)[\"']"
14+
]
15+
}
16+
],
17+
"packageRules": [
18+
{
19+
"description": "Auto-regenerate API client via GitHub Actions workflow",
20+
"matchDepNames": ["stacklok/toolhive-registry-server"]
21+
}
22+
]
823
}

scripts/generate-swagger.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ import { execSync } from "node:child_process";
33
import { writeFile } from "node:fs/promises";
44
import * as path from "node:path";
55

6+
/**
7+
* ToolHive Registry Server version.
8+
* This is managed by Renovate and updated automatically when new versions are released.
9+
* renovate: datasource=github-releases depName=stacklok/toolhive-registry-server versioning=semver
10+
*/
11+
const REGISTRY_SERVER_VERSION = "v0.3.9";
12+
613
(async () => {
7-
const url =
8-
"https://raw.githubusercontent.com/stacklok/toolhive-registry-server/refs/heads/main/docs/thv-registry-api/swagger.json";
14+
const url = `https://raw.githubusercontent.com/stacklok/toolhive-registry-server/refs/tags/${REGISTRY_SERVER_VERSION}/docs/thv-registry-api/swagger.json`;
915
const dest = path.resolve("./swagger.json");
1016

1117
console.log(`Fetching OpenAPI spec from: ${url}`);

0 commit comments

Comments
 (0)