From d78dc4b8c4cb4922b02abccfd690d398805e1a0d Mon Sep 17 00:00:00 2001 From: happy-game Date: Fri, 4 Jul 2025 16:08:30 +0000 Subject: [PATCH 1/2] ci(release): add automated npm publishing workflow --- .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ lerna.json | 10 +++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..7ea0d1146 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Release + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + branches: + - master + workflow_dispatch: + +permissions: + contents: write + id-token: write + +jobs: + release: + name: Release to npm + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build packages + run: yarn build + + - name: Check for changes + id: check-changes + run: | + # 检查是否有待发布的变更 + if yarn lerna changed --json | jq -e 'length > 0' > /dev/null; then + echo "has-changes=true" >> $GITHUB_OUTPUT + echo "Found packages with changes to publish" + else + echo "has-changes=false" >> $GITHUB_OUTPUT + echo "No packages have changes to publish" + fi + + - name: Publish to npm + if: steps.check-changes.outputs.has-changes == 'true' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + yarn lerna publish from-package --yes diff --git a/lerna.json b/lerna.json index 3ac570d92..0f331bfe4 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,15 @@ "version": "independent", "command": { "version": { - "allowBranch": "master" + "allowBranch": "master", + "conventionalCommits": true, + "message": "chore(release): publish", + "push": true, + "createRelease": false + }, + "publish": { + "ignoreChanges": ["**/*.md", "**/test/**", "**/*.test.*"], + "registry": "https://registry.npmjs.org/" } }, "ignoreChanges": ["**/*.md", "**/test/**"] From 752ce710c578c8443a24488ec30e4454c4c9d599 Mon Sep 17 00:00:00 2001 From: happy-game Date: Sat, 5 Jul 2025 02:24:30 +0000 Subject: [PATCH 2/2] ci(release): update release.yml --- .github/workflows/release.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ea0d1146..b7eb57fb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,21 +38,9 @@ jobs: - name: Build packages run: yarn build - - name: Check for changes - id: check-changes - run: | - # 检查是否有待发布的变更 - if yarn lerna changed --json | jq -e 'length > 0' > /dev/null; then - echo "has-changes=true" >> $GITHUB_OUTPUT - echo "Found packages with changes to publish" - else - echo "has-changes=false" >> $GITHUB_OUTPUT - echo "No packages have changes to publish" - fi - - name: Publish to npm - if: steps.check-changes.outputs.has-changes == 'true' + if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | - yarn lerna publish from-package --yes + yarn lerna publish from-package --yes --no-verify-access