From 30abd7437e433d6768e8a30e7891a12d7180a928 Mon Sep 17 00:00:00 2001 From: jiasheng Date: Thu, 13 Aug 2026 21:35:28 +0800 Subject: [PATCH] feat: add GitHub Actions workflow for publishing and releasing packages --- .github/workflows/publish-release.yml | 81 +++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..c0dce7c --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,81 @@ +name: Publish and Release + +on: + workflow_dispatch: + push: + branches: + - main + +permissions: + contents: write + +jobs: + publish-and-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 10.12.1 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: 'pnpm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: | + pnpm run build + + - name: Get version from package.json + id: version + run: | + VERSION=$(node -p "require('./package.json').version") + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "tag=v$VERSION" >> $GITHUB_OUTPUT + + - name: Publish packages + run: pnpm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Generate changelog + id: changelog + run: | + PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + if [ -z "$PREVIOUS_TAG" ]; then + CHANGELOG=$(git log --oneline --no-merges --format="* %s" HEAD) + else + CHANGELOG=$(git log --oneline --no-merges --format="* %s" ${PREVIOUS_TAG}..HEAD) + fi + + if [ -z "$CHANGELOG" ]; then + CHANGELOG="* Automated release" + fi + + echo "changelog<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.tag }} + name: ZenStack Studio MCP Remote Release ${{ steps.version.outputs.tag }} + body: | + ## Changes in this release + + ${{ steps.changelog.outputs.changelog }} + draft: true diff --git a/package.json b/package.json index e99377a..f32f3e9 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "dist" ], "scripts": { - "build": "tsc && chmod +x dist/cli.js", + "build": "tsc && chmod +x dist/index.js", "test": "vitest run", "format": "prettier --write \"**/*.{ts,tsx,md}\"" },