Skip to content

Commit d787859

Browse files
authored
feat: CICD (#3)
1 parent 7475bdc commit d787859

File tree

3 files changed

+112
-2
lines changed

3 files changed

+112
-2
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Use Node.js 18.x
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 18.x
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Build
25+
run: npm run build
26+
27+
- name: Upload build artifacts
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: build-artifacts
31+
path: dist/

.github/workflows/publish.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Publish to NPM
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-type:
7+
description: "Release type"
8+
required: true
9+
default: "patch"
10+
type: "choice"
11+
options:
12+
- "patch"
13+
- "minor"
14+
- "major"
15+
- "beta"
16+
- "alpha"
17+
version-increment:
18+
description: "Version increment (beta and alpha)"
19+
required: false
20+
default: "0"
21+
type: "choice"
22+
options:
23+
- "0"
24+
- "1"
25+
- "2"
26+
- "3"
27+
- "4"
28+
- "5"
29+
30+
jobs:
31+
publish:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
ref: main
37+
38+
- name: Set up Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: "18.x"
42+
registry-url: "https://registry.npmjs.org"
43+
44+
- name: Install dependencies
45+
run: npm install
46+
47+
- name: Build project
48+
run: npm run build
49+
50+
- name: Version update (official version)
51+
if: ${{ github.event.inputs.release-type == 'patch' || github.event.inputs.release-type == 'minor' || github.event.inputs.release-type == 'major' }}
52+
run: npm version ${{ github.event.inputs.release-type }} --no-git-tag-version
53+
54+
- name: Version update (Beta version)
55+
if: ${{ github.event.inputs.release-type == 'beta' }}
56+
run: npm version prepatch --preid=beta --no-git-tag-version && npm version prerelease --preid=beta --no-git-tag-version --increment=${{ github.event.inputs.version-increment }}
57+
58+
- name: Version update (Alpha version)
59+
if: ${{ github.event.inputs.release-type == 'alpha' }}
60+
run: npm version prepatch --preid=alpha --no-git-tag-version && npm version prerelease --preid=alpha --no-git-tag-version --increment=${{ github.event.inputs.version-increment }}
61+
62+
- name: Publish to NPM
63+
run: npm publish
64+
env:
65+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66+
67+
- name: Get new version number
68+
id: get-version
69+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
70+
71+
- name: Commit version changes
72+
run: |
73+
git config --local user.email "action@github.com"
74+
git config --local user.name "GitHub Action"
75+
git add package.json
76+
git commit -m "chore: Release v${{ steps.get-version.outputs.version }}"
77+
git tag v${{ steps.get-version.outputs.version }}
78+
git push
79+
git push --tags

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mastergo/magic-mcp",
3-
"version": "0.0.2-beta",
3+
"version": "0.0.3-beta",
44
"description": "MasterGo MCP standalone service",
55
"main": "dist/index.js",
66
"bin": {
@@ -15,7 +15,7 @@
1515
"!**/.vscode"
1616
],
1717
"engines": {
18-
"node": ">=16"
18+
"node": ">=18"
1919
},
2020
"scripts": {
2121
"build": "node build.js",

0 commit comments

Comments
 (0)