From 500761e6be3a9a20499b328b0f2bb2d3e0538efd Mon Sep 17 00:00:00 2001 From: bd <331677620@qq.com> Date: Thu, 2 May 2024 19:52:17 +0800 Subject: [PATCH] test: changesets --- .github/workflows/changesets-auto-pr.yml | 32 +++++++++++++----------- changeset-status.cjs | 1 + package.json | 1 + 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/changesets-auto-pr.yml b/.github/workflows/changesets-auto-pr.yml index d872c40..ba89f34 100644 --- a/.github/workflows/changesets-auto-pr.yml +++ b/.github/workflows/changesets-auto-pr.yml @@ -4,11 +4,10 @@ name: changesets-auto-pr on: workflow_dispatch: - push: - branches-ignore: + pull_request: + types: [ opened, reopened ] + branches: - master - paths: - - '.changeset/*' jobs: replace-package-json-and-publish: @@ -31,15 +30,18 @@ jobs: id: changesetStatus run: | node ./changeset-status.cjs - - name: changesets-version - id: changesets - uses: changesets/action@v1 - with: - title: Pull Request ${{ steps.changesetStatus.outputs.status }} - version: node ./node_modules/@changesets/cli/bin.js version --snapshot prepublish - publish: npm run pub:only - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: changesets-version + # id: changesets + # uses: changesets/action@v1 + # with: + # title: Pull Request ${{ steps.changesetStatus.outputs.status }} + # version: node ./node_modules/@changesets/cli/bin.js version --snapshot prepublish + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: changesets update version + run: changeset version --snapshot prepublish + - name: Pre Publish + run: npm run pub:pre - name: Dingtalk Notify uses: zcong1993/actions-ding@master if: steps.changesets.outputs.hasChangesets == 'true' @@ -49,8 +51,8 @@ jobs: { "msgtype": "markdown", "markdown": { - "title":"orca-fe PR 创建提示", - "text": "## Orca-Pocket PR 已创建\n 请查看[PR列表](https://github.com/orca-team/pocket/pulls)" + "title":"orca-fe 发布提醒", + "text": "## Orca-Pocket 临时版本已发布\n " }, "at": { "isAtAll": false diff --git a/changeset-status.cjs b/changeset-status.cjs index 9ee66e4..53b37fd 100644 --- a/changeset-status.cjs +++ b/changeset-status.cjs @@ -6,3 +6,4 @@ execSync(`npx changeset status --output changeset-status.json`); const status = JSON.parse(fs.readFileSync('changeset-status.json')); const message = [...new Set(status.changesets.map(({ summary }) => summary))].join('; '); core.setOutput('status', message); +core.setOutput('hasChangesets', String(status.changesets.length > 0)); diff --git a/package.json b/package.json index 324affc..a33c329 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "cv": "changeset && changeset version", "pub": "npm run test && changeset publish && git push", "pub:only": "npm run test && changeset publish", + "pub:pre": "changeset publish --tag prepublish", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", "lint-staged": "lint-staged", "test": "pnpm --filter=@orca-fe/* run test ",