Skip to content

Commit 2b42ff2

Browse files
authored
Merge pull request #1 from zenstackhq/dev
feat: add GitHub Actions workflow for publishing and releasing packages
2 parents 09172ce + 30abd74 commit 2b42ff2

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Publish and Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
publish-and-release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@v2
22+
with:
23+
version: 10.12.1
24+
25+
- name: Use Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20.x
29+
cache: 'pnpm'
30+
registry-url: 'https://registry.npmjs.org'
31+
32+
- name: Install dependencies
33+
run: pnpm install --frozen-lockfile
34+
35+
- name: Build
36+
run: |
37+
pnpm run build
38+
39+
- name: Get version from package.json
40+
id: version
41+
run: |
42+
VERSION=$(node -p "require('./package.json').version")
43+
echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
45+
46+
- name: Publish packages
47+
run: pnpm publish --access public
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
51+
- name: Generate changelog
52+
id: changelog
53+
run: |
54+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
55+
56+
if [ -z "$PREVIOUS_TAG" ]; then
57+
CHANGELOG=$(git log --oneline --no-merges --format="* %s" HEAD)
58+
else
59+
CHANGELOG=$(git log --oneline --no-merges --format="* %s" ${PREVIOUS_TAG}..HEAD)
60+
fi
61+
62+
if [ -z "$CHANGELOG" ]; then
63+
CHANGELOG="* Automated release"
64+
fi
65+
66+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
67+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
68+
echo "EOF" >> $GITHUB_OUTPUT
69+
70+
- name: Create GitHub Release
71+
uses: softprops/action-gh-release@v2
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
with:
75+
tag_name: ${{ steps.version.outputs.tag }}
76+
name: ZenStack Studio MCP Remote Release ${{ steps.version.outputs.tag }}
77+
body: |
78+
## Changes in this release
79+
80+
${{ steps.changelog.outputs.changelog }}
81+
draft: true

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc && chmod +x dist/cli.js",
17+
"build": "tsc && chmod +x dist/index.js",
1818
"test": "vitest run",
1919
"format": "prettier --write \"**/*.{ts,tsx,md}\""
2020
},

0 commit comments

Comments
 (0)