-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (92 loc) · 3.92 KB
/
Copy pathrelease.yml
File metadata and controls
108 lines (92 loc) · 3.92 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
name: Release
# Publishes the gem to RubyGems.org via Trusted Publishing (OIDC) whenever a
# GitHub Release is published, and attaches the Claude Desktop bundle to the
# release. The release tag (e.g. v0.1.1) is the source of truth for the
# version: the workflow writes it into lib/activeadmin_mcp/version.rb,
# mcpb/manifest.json and mcpb/package.json, publishes the gem, uploads
# activeadmin-mcp-<version>.mcpb as a release asset, then commits the version
# bumps back to the default branch. No API key is stored — RubyGems verifies
# this workflow via OIDC. See RELEASING.md for the one-time RubyGems setup.
on:
release:
types: [published]
permissions:
contents: read
jobs:
release:
runs-on: ubuntu-latest
environment: rubygems
permissions:
contents: write # upload the release asset, commit the version bumps back
id-token: write # exchange the OIDC token with RubyGems
steps:
- name: Derive version from release tag
id: version
run: |
tag="${{ github.event.release.tag_name }}"
version="${tag#v}"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.]+)?$ ]]; then
echo "::error::Release tag '$tag' is not a valid version (expected vX.Y.Z)"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Check out default branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "4.0.7"
bundler-cache: true
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Write version files
run: |
version="${{ steps.version.outputs.version }}"
sed -i -E "s/VERSION = \".*\"/VERSION = \"${version}\"/" lib/activeadmin_mcp/version.rb
grep -q "VERSION = \"${version}\"" lib/activeadmin_mcp/version.rb
# The leading quote in the pattern keeps this off "manifest_version".
for json in mcpb/manifest.json mcpb/package.json; do
sed -i -E "s/^(\s*)\"version\": \".*\",$/\\1\"version\": \"${version}\",/" "$json"
grep -q "\"version\": \"${version}\"," "$json"
done
- name: Run specs
run: bundle exec rspec
- name: Run proxy tests
run: npm test
working-directory: mcpb
- name: Pack the bundle
run: |
version="${{ steps.version.outputs.version }}"
npx --yes @anthropic-ai/mcpb pack . "../activeadmin-mcp-${version}.mcpb"
working-directory: mcpb
- name: Configure RubyGems credentials (OIDC)
uses: rubygems/configure-rubygems-credentials@v2.1.0
- name: Build and push gem
run: |
version="${{ steps.version.outputs.version }}"
gem build activeadmin_mcp.gemspec
gem push "activeadmin_mcp-${version}.gem"
- name: Attach the bundle to the release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version="${{ steps.version.outputs.version }}"
gh release upload "${{ github.event.release.tag_name }}" \
"activeadmin-mcp-${version}.mcpb" --clobber
- name: Commit version bumps to default branch
run: |
version="${{ steps.version.outputs.version }}"
versioned_files="lib/activeadmin_mcp/version.rb mcpb/manifest.json mcpb/package.json"
if git diff --quiet -- $versioned_files; then
echo "version files already at ${version}; nothing to commit."
else
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add $versioned_files
git commit -m "Bump version to ${version}"
git push origin "HEAD:${{ github.event.repository.default_branch }}"
fi