Skip to content

Commit 583b48b

Browse files
author
vcart
committed
chore: setup automation workflow for release and publish to npm
1 parent cb88f41 commit 583b48b

4 files changed

Lines changed: 173 additions & 6 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Release and Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version type (prerelease, prepatch, patch, preminor, minor, premajor, major)'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- prerelease
13+
- prepatch
14+
- patch
15+
- preminor
16+
- minor
17+
- premajor
18+
- major
19+
custom_version:
20+
description: 'Custom version (leave empty to use version_type)'
21+
required: false
22+
type: string
23+
dist_tag:
24+
description: 'npm distribution tag (latest, next, beta, etc)'
25+
required: false
26+
default: 'latest'
27+
type: string
28+
29+
jobs:
30+
release-and-publish:
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: write
34+
packages: write
35+
id-token: write
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
token: ${{ secrets.PAT_GITHUB }}
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: '18.x'
47+
registry-url: 'https://registry.npmjs.org'
48+
49+
- name: Setup Bun
50+
uses: oven-sh/setup-bun@v1
51+
with:
52+
bun-version: latest
53+
54+
- name: Install dependencies
55+
run: bun install
56+
57+
- name: Configure Git
58+
run: |
59+
git config --local user.email "action@github.com"
60+
git config --local user.name "GitHub Action"
61+
git config pull.rebase false
62+
63+
- name: Bump version
64+
id: bump_version
65+
run: |
66+
if [ -n "${{ github.event.inputs.custom_version }}" ]; then
67+
echo "Using custom version ${{ github.event.inputs.custom_version }}"
68+
npm version ${{ github.event.inputs.custom_version }} --no-git-tag-version
69+
echo "VERSION=${{ github.event.inputs.custom_version }}" >> $GITHUB_ENV
70+
else
71+
echo "Bumping ${{ github.event.inputs.version_type }} version"
72+
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version)
73+
echo "VERSION=${NEW_VERSION:1}" >> $GITHUB_ENV
74+
fi
75+
echo "New version: ${{ env.VERSION }}"
76+
77+
- name: Generate Changelog
78+
run: |
79+
# Generate the full changelog
80+
npm run changelog
81+
# Generate release notes for just this version
82+
npm run changelog:latest
83+
84+
- name: Build project
85+
run: bun run build && bun run build:http
86+
87+
- name: Commit and push changes
88+
run: |
89+
git pull origin main --no-edit
90+
git add package.json CHANGELOG.md
91+
git commit -m "Bump version to v${{ env.VERSION }}"
92+
git push --force-with-lease
93+
94+
- name: Create and push tag
95+
run: |
96+
# Delete the tag if it already exists locally
97+
git tag -d "v${{ env.VERSION }}" 2>/dev/null || true
98+
# Delete the tag if it exists on the remote
99+
git push origin --delete "v${{ env.VERSION }}" 2>/dev/null || true
100+
# Create and push the new tag
101+
git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}"
102+
git push origin "v${{ env.VERSION }}"
103+
104+
- name: Create GitHub Release
105+
uses: softprops/action-gh-release@v1
106+
with:
107+
tag_name: v${{ env.VERSION }}
108+
name: Release v${{ env.VERSION }}
109+
body_path: RELEASE_NOTES.md
110+
generate_release_notes: false
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
113+
114+
- name: Publish to npm
115+
run: npm publish --access public --provenance --tag ${{ github.event.inputs.dist_tag || 'latest' }}
116+
env:
117+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.

bin/cli.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
import { startServer } from '../build/index.js';
4+
5+
startServer();

package.json

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
{
2-
"name": "mcp-server",
2+
"name": "@mcpdotdirect/starknet-mcp-server",
33
"module": "src/index.ts",
44
"type": "module",
55
"version": "1.0.0",
6-
"description": "Model Context Protocol (MCP) Server",
7-
"private": true,
6+
"description": "Model Context Protocol (MCP) server for interacting with StarkNet",
7+
"private": false,
8+
"main": "build/index.js",
9+
"bin": {
10+
"starknet-mcp-server": "./bin/cli.js"
11+
},
12+
"files": [
13+
"build/",
14+
"bin/",
15+
"README.md",
16+
"LICENSE"
17+
],
818
"scripts": {
919
"start": "bun run src/index.ts",
1020
"build": "bun build src/index.ts --outdir build --target node",
11-
"build:http": "bun build src/server/http-server.ts --outdir build --target node",
21+
"build:http": "bun build src/server/http-server.ts --outdir build --target node --outfile http-server.js",
1222
"dev": "bun --watch src/index.ts",
1323
"start:http": "bun run src/server/http-server.ts",
14-
"dev:http": "bun --watch src/server/http-server.ts"
24+
"dev:http": "bun --watch src/server/http-server.ts",
25+
"prepublishOnly": "bun run build && bun run build:http",
26+
"version:patch": "npm version patch",
27+
"version:minor": "npm version minor",
28+
"version:major": "npm version major",
29+
"release": "npm publish",
30+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
31+
"changelog:latest": "conventional-changelog -p angular -r 1 > RELEASE_NOTES.md"
1532
},
1633
"devDependencies": {
1734
"@types/bun": "latest",
1835
"@types/cors": "^2.8.17",
1936
"@types/express": "^5.0.0",
20-
"@types/node": "^20.17.24"
37+
"@types/node": "^20.17.24",
38+
"conventional-changelog-cli": "^5.0.0"
2139
},
2240
"peerDependencies": {
2341
"typescript": "^5.8.2"
@@ -28,5 +46,29 @@
2846
"express": "^4.21.2",
2947
"starknet": "^6.23.1",
3048
"zod": "^3.24.2"
49+
},
50+
"keywords": [
51+
"mcp",
52+
"model-context-protocol",
53+
"starknet",
54+
"blockchain",
55+
"ai",
56+
"agent"
57+
],
58+
"author": "mcpdotdirect",
59+
"license": "MIT",
60+
"engines": {
61+
"node": ">=18.0.0"
62+
},
63+
"repository": {
64+
"type": "git",
65+
"url": "https://github.com/mcpdotdirect/starknet-mcp-server"
66+
},
67+
"bugs": {
68+
"url": "https://github.com/mcpdotdirect/starknet-mcp-server/issues"
69+
},
70+
"homepage": "https://github.com/mcpdotdirect/starknet-mcp-server#readme",
71+
"publishConfig": {
72+
"access": "public"
3173
}
3274
}

0 commit comments

Comments
 (0)