From 135ea7b8b2571ba41f41a11afcc71863b80a8a63 Mon Sep 17 00:00:00 2001 From: spencer Date: Sat, 9 Aug 2025 15:24:45 +0800 Subject: [PATCH] ci: add release workflow --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..73a2b27 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: npm-publish + +on: + pull_request: + types: [closed] + branches: + - master + workflow_dispatch: {} + +jobs: + publish: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # for npm provenance + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' + cache: 'pnpm' + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: | + pnpm run --if-present release:build || pnpm run --if-present build + + - name: Test + run: pnpm run --if-present test + + - name: Publish with Changesets (pnpm) + run: pnpm run changeset:publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: true + +