-
Notifications
You must be signed in to change notification settings - Fork 6
146 lines (133 loc) · 4.96 KB
/
release.yml
File metadata and controls
146 lines (133 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Publish Release
on:
push:
branches:
- main
paths:
- 'pkg/catalog/*/data/**'
schedule:
- cron: '0 6 * * *' # daily at 6 AM UTC
workflow_dispatch:
permissions:
contents: write
jobs:
release:
name: Publish Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Generate version
id: metadata
run: |
echo "version=0.$(date +'%Y%m%d').0" >> $GITHUB_OUTPUT
echo "date=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT
- name: Check for data changes since last release
id: check_changes
if: github.event_name == 'schedule'
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LATEST_TAG" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
exit 0
fi
# Check if any catalog data files changed since the last release tag
CHANGES=$(git diff --name-only "$LATEST_TAG"..HEAD -- 'pkg/catalog/*/data/**')
if [ -z "$CHANGES" ]; then
echo "No catalog data changes since $LATEST_TAG, skipping release."
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Found changes since $LATEST_TAG:"
echo "$CHANGES"
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Generate release body
if: steps.check_changes.outputs.has_changes != 'false'
id: release_body
run: |
{
echo "body<<EOF"
echo "## ToolHive Catalog Release"
echo ""
echo "**Date**: ${{ steps.metadata.outputs.date }}"
echo ""
for registry_dir in pkg/catalog/*/; do
registry_name=$(basename "$registry_dir")
data_file="$registry_dir/data/registry.json"
[ -f "$data_file" ] || continue
CONTAINER_COUNT=$(jq '.servers | length' "$data_file")
REMOTE_COUNT=$(jq '.remote_servers | length // 0' "$data_file")
TOTAL=$((CONTAINER_COUNT + REMOTE_COUNT))
LAST_UPDATED=$(jq -r '.last_updated' "$data_file")
upstream_file="$registry_dir/data/official-registry.json"
if [ -f "$upstream_file" ]; then
SKILL_COUNT=$(jq '.data.skills | length // 0' "$upstream_file")
else
SKILL_COUNT=0
fi
echo "### Registry: \`$registry_name\`"
echo ""
echo "**Last Updated**: $LAST_UPDATED"
echo ""
echo "| Category | Count |"
echo "|----------|-------|"
echo "| **Total Servers** | $TOTAL |"
echo "| **Container-based** | $CONTAINER_COUNT |"
echo "| **Remote** | $REMOTE_COUNT |"
echo "| **Skills** | $SKILL_COUNT |"
echo ""
echo "\`\`\`sh"
echo "go get github.com/stacklok/toolhive-catalog/pkg/catalog/${registry_name}@latest"
echo "\`\`\`"
echo ""
echo "\`\`\`go"
echo "import \"github.com/stacklok/toolhive-catalog/pkg/catalog/${registry_name}\""
echo ""
echo "// ToolHive legacy format"
echo "data := ${registry_name}.Legacy()"
echo ""
echo "// Upstream MCP format"
echo "data := ${registry_name}.Upstream()"
echo "\`\`\`"
echo ""
done
echo "---"
echo "*This is an automated release triggered by a catalog data update.*"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Collect release artifacts
if: steps.check_changes.outputs.has_changes != 'false'
id: artifacts
run: |
ARTIFACT_LIST=""
for registry_dir in pkg/catalog/*/; do
[ -d "$registry_dir/data" ] || continue
for f in "$registry_dir"/data/*.json; do
[ -f "$f" ] || continue
if [ -n "$ARTIFACT_LIST" ]; then
ARTIFACT_LIST="${ARTIFACT_LIST}
${f}"
else
ARTIFACT_LIST="$f"
fi
done
done
{
echo "files<<EOF"
echo "$ARTIFACT_LIST"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Create or update release
if: steps.check_changes.outputs.has_changes != 'false'
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1
with:
tag: v${{ steps.metadata.outputs.version }}
name: Catalog v${{ steps.metadata.outputs.date }}
body: ${{ steps.release_body.outputs.body }}
artifacts: ${{ steps.artifacts.outputs.files }}
allowUpdates: true
makeLatest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}