From e2c34712e95527a38c792ca20db8d687b1e022a1 Mon Sep 17 00:00:00 2001 From: yunji Date: Wed, 13 Nov 2024 19:13:11 +0800 Subject: [PATCH] chore: add changeset --- .changeset/README.md | 8 +++ .changeset/config.json | 11 +++ .github/workflows/create-bumb-version-pr.yml | 48 +++++++++++++ .github/workflows/release.yml | 74 +++++++++++++++++++- README.md | 2 +- README.zh-CN.md | 2 +- package.json | 9 ++- 7 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 .changeset/README.md create mode 100644 .changeset/config.json create mode 100644 .github/workflows/create-bumb-version-pr.yml diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..e5b6d8d --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..dc04c94 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json", + "changelog": ["@changesets/changelog-github", { "repo": "antvis/GPT-Vis" }], + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.github/workflows/create-bumb-version-pr.yml b/.github/workflows/create-bumb-version-pr.yml new file mode 100644 index 0000000..8d9fc96 --- /dev/null +++ b/.github/workflows/create-bumb-version-pr.yml @@ -0,0 +1,48 @@ +name: Create bump version PR + +on: + workflow_dispatch: + +concurrency: + group: '${{ github.workflow }} - ${{ github.ref }}' + cancel-in-progress: true + +jobs: + bump-version-pr: + name: Bump version PR + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x] + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + uses: ./.github/actions/prepare-install + with: + node-version: ${{ matrix.node-version }} + + - name: Pre build ckeck + run: pnpm build + + - name: Create Version Pull Request + id: changesets + uses: changesets/action@v1 + with: + version: pnpm publish-version + commit: 'chore: version' + title: 'chore: version' + setupGitUser: true + createGithubReleases: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: After changesets + run: | + if [[ ${{ steps.changesets.outputs.hasChangesets }} == false ]]; then + # No changesets + echo "::error title=No changesets found::All changesets are empty, not creating PR, please add changeset" + exit 1 + else + # Created Pull Request + echo "::notice title=PR is created::Created bump version PR address is: https://github.com/${{github.repository}}/pull/${{steps.changesets.outputs.pullRequestNumber}}" + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f3bd84e..839f524 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,9 @@ -name: release +name: Release on: workflow_dispatch: + pull_request_review: + types: [submitted] concurrency: group: '${{ github.workflow }} - ${{ github.head_ref || github.ref }}' @@ -9,10 +11,22 @@ concurrency: jobs: release: + # created version approved PR by changesets bot or manual dispatch + if: | + ( + github.event_name == 'pull_request_review' && + github.event.pull_request.user.type == 'Bot' && + startswith(github.event.pull_request.head.ref, 'changeset-release/') && + github.event.review.state == 'APPROVED' + ) || + github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest strategy: matrix: node-version: [18.x] + outputs: + published: ${{ steps.changesets.outputs.published }} + publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} steps: - uses: actions/checkout@v4 @@ -20,3 +34,61 @@ jobs: uses: ./.github/actions/prepare-install with: node-version: ${{ matrix.node-version }} + + - name: Release NPM and Github + id: changesets + uses: changesets/action@v1 + env: + # need personal access token when Triggering a workflow from a workflow + # triggering release event of Release Notify and Deploy Site + # https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow + GITHUB_TOKEN: ${{ secrets.YJ_GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.YJ_NPM_TOKEN }} + with: + publish: pnpm publish-packages + createGithubReleases: true + + # when release not publish + - name: Released not publish + if: steps.changesets.outputs.published == 'false' + run: | + if [[ ${{ steps.changesets.outputs.hasChangesets }} == false ]]; then + # No changesets + echo "::error title=No changesets found::All changesets are empty, please add changeset" + else + # Released failed + echo "::error title=Publish failed::Released NPM or Github failed" + fi + exit 1 + + # when release published successful + release-succeeded: + needs: release + if: needs.release.outputs.published == 'true' + runs-on: ubuntu-latest + steps: + - name: Release succeeded comment + if: github.event_name == 'pull_request_review' + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Released to successful 🎉 + + - Released [NPM][1] + - Released [Github][2] + + `${{ needs.release.outputs.publishedPackages }}` + + [1]: https://www.npmjs.com/package/@antv/GPT-vis?activeTab=versions + [2]: https://github.com/${{github.repository}}/releases + reactions: 'rocket' + + - name: automerge + if: github.event_name == 'pull_request_review' + uses: 'pascalgn/automerge-action@v0.16.2' + env: + MERGE_LABELS: '' + PULL_REQUEST: ${{ github.event.pull_request.number }} + MERGE_METHOD: 'squash' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 86b5690..5c43866 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Components for GPTs, generative AI, and LLM projects. Not only UI Components. ## 📦 Installation ```bash -$ npm add @antv/gpt-vis --save +$ npm i @antv/gpt-vis --save ``` ## 🔨 Usage diff --git a/README.zh-CN.md b/README.zh-CN.md index b76ce47..c151971 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -28,7 +28,7 @@ Components for GPTs, generative AI, and LLM projects. Not only UI Components. ## 📦 安装 ```bash -$ npm add @antv/gpt-vis --save +$ npm i @antv/gpt-vis --save ``` ## 🔨 使用 diff --git a/package.json b/package.json index 0427a80..b47ce9b 100644 --- a/package.json +++ b/package.json @@ -41,9 +41,10 @@ "lint:ts": "eslint src --ext .ts,.tsx", "lint:ts-fix": "pnpm lint:ts --fix", "test:unit": "jest --config ./jest.config.ts", - "test:size": "limit-size", - "ci": "run-s lint:ts doctor build", - "prepublishOnly": "pnpm ci" + "test:size": "pn build && limit-size", + "changeset": "changeset add", + "publish-version": "changeset version && node scripts/sync-version", + "publish-packages": "pnpm build && changeset publish" }, "dependencies": { "@ant-design/graphs": "^2.0.0-beta.4", @@ -59,6 +60,8 @@ "styled-components": "^6.0.7" }, "devDependencies": { + "@changesets/changelog-github": "^0.5.0", + "@changesets/cli": "^2.27.9", "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", "@types/jest": "^29.5.14",