From 9ebf76deb06666d4b659421b90f9609d044ea5a0 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 23 Dec 2024 17:29:15 +0800 Subject: [PATCH 1/6] chore(CI): use new release workflow --- .github/workflows/bench-pr.yml | 87 ---------------------- .github/workflows/lint.yml | 10 +-- .github/workflows/release-pull-request.yml | 53 ------------- .github/workflows/release.yml | 34 ++++----- .github/workflows/test.yml | 12 +-- 5 files changed, 17 insertions(+), 179 deletions(-) delete mode 100644 .github/workflows/bench-pr.yml delete mode 100644 .github/workflows/release-pull-request.yml diff --git a/.github/workflows/bench-pr.yml b/.github/workflows/bench-pr.yml deleted file mode 100644 index a4f511e5a..000000000 --- a/.github/workflows/bench-pr.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Benchmark PR - -# TODO: switch to workflow_dispatch -# on: -# issue_comment: -# types: [created] - -# cancel previous job runs for the same workflow + pr -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} - cancel-in-progress: true - -jobs: - trigger: - runs-on: ubuntu-latest - if: github.repository == 'web-infra-dev/rslib' && (github.event.issue.pull_request && startsWith(github.event.comment.body, '!bench')) - steps: - - uses: actions/github-script@v7 - with: - script: | - const user = context.payload.sender.login - console.log(`Validate user: ${user}`) - - let hasTriagePermission = false - try { - const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ - owner: context.repo.owner, - repo: context.repo.repo, - username: user, - }); - hasTriagePermission = data.user.permissions.triage - } catch (e) { - console.warn(e) - } - - if (hasTriagePermission) { - console.log('Allowed') - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: '+1', - }) - } else { - console.log('Not allowed') - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: '-1', - }) - throw new Error('not allowed') - } - - uses: actions/github-script@v7 - id: get-pr-data - with: - script: | - console.log(`Get PR info: ${context.repo.owner}/${context.repo.repo}#${context.issue.number}`) - const { data: pr } = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number - }) - return { - num: context.issue.number, - branchName: pr.head.ref, - repo: pr.head.repo.full_name - } - - uses: actions/github-script@v7 - id: trigger - with: - github-token: ${{ secrets.REPO_SCOPED_TOKEN }} - result-encoding: string - script: | - const prData = ${{ steps.get-pr-data.outputs.result }} - - await github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: 'web-infra-QoS', - workflow_id: 'pr-bench.yaml', - ref: 'master', - inputs: { - prNumber: '' + prData.num, - product: 'RSLIB', - repo: 'rslib' - } - }) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9b51c54a8..1acbcbfeb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,26 +1,18 @@ name: Lint -# Controls when the action will run. on: - # Triggers the workflow on pull request events but only for the main branch pull_request: branches: [main] push: branches: [main] - merge_group: - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: lint: - # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Checkout uses: actions/checkout@v4 @@ -30,7 +22,7 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 18 + - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 18 diff --git a/.github/workflows/release-pull-request.yml b/.github/workflows/release-pull-request.yml deleted file mode 100644 index dff433f5c..000000000 --- a/.github/workflows/release-pull-request.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Release Pull Request - -on: - workflow_dispatch: - inputs: - version: - type: choice - description: 'Release Type (next, beta, alpha, latest)' - required: true - default: 'latest' - options: - - next - - beta - - alpha - - latest - -jobs: - release: - name: Create Release Pull Request - runs-on: ubuntu-latest - if: github.repository == 'web-infra-dev/rslib' - steps: - - name: Checkout Repo - uses: actions/checkout@master - with: - # This makes Actions fetch only one branch to release - fetch-depth: 10 - - - name: Install Pnpm - run: corepack enable - - - name: Setup Node.js 18 - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install --ignore-scripts - - - name: Create Release Pull Request - uses: web-infra-dev/actions@v2 - with: - # this expects you to have a script called release which does a build for your packages and calls changeset publish - version: ${{ github.event.inputs.version || 'latest' }} - versionNumber: 'auto' - type: 'pull request' - tools: 'changeset' - env: - GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - REPOSITORY: ${{ github.repository }} - REF: ${{ github.ref }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cdda5442b..e523d7124 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,18 +3,19 @@ name: Release on: workflow_dispatch: inputs: - version: + npm_tag: type: choice - description: 'Release Version (next, beta, alpha, latest)' + description: 'Specify npm tag' required: true - default: 'next' + default: 'alpha' options: - - next - - beta - alpha + - beta + - rc + - canary - latest branch: - description: 'Release Branch (confirm release branch)' + description: 'Branch to release' required: true default: 'main' @@ -26,17 +27,18 @@ jobs: name: Release if: github.repository == 'web-infra-dev/rslib' && github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest + environment: production steps: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 25 + fetch-depth: 1 ref: ${{ github.event.inputs.branch }} - name: Install Pnpm run: corepack enable - - name: Setup Node.js 18 + - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 18 @@ -45,15 +47,9 @@ jobs: - name: Install Dependencies run: pnpm install - - name: Release - uses: web-infra-dev/actions@v2 - with: - version: ${{ github.event.inputs.version }} - branch: ${{ github.event.inputs.branch }} - type: 'release' - tools: 'changeset' + - name: Publish to npm env: - GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - REPOSITORY: ${{ github.repository }} - REF: ${{ github.ref }} + NPM_TOKEN: ${{ secrets.RSLIB_NPM_TOKEN }} + run: | + npm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}" + pnpm -r publish --tag ${{ github.event.inputs.npm_tag }} --publish-branch ${{ github.event.inputs.branch }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad2cc8470..00be3358f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,20 +1,14 @@ name: Test -# Controls when the action will run. on: - # Triggers the workflow on pull request events but only for the main branch pull_request: branches: [main] push: branches: [main] - merge_group: - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # ======== calculate changes ======== changes: @@ -25,7 +19,6 @@ jobs: matrix: node-version: [18] - # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Checkout uses: actions/checkout@v4 @@ -35,7 +28,7 @@ jobs: - name: Install Pnpm run: corepack enable - - uses: dorny/paths-filter@v3 + - uses: dorny/paths-filter@v3.0.2 id: changes with: predicate-quantifier: 'every' @@ -59,7 +52,6 @@ jobs: - node-version: 18 os: windows-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Checkout uses: actions/checkout@v4 @@ -100,7 +92,6 @@ jobs: - node-version: 18 os: windows-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Git config if: ${{ matrix.os == 'windows-latest' }} @@ -141,7 +132,6 @@ jobs: matrix: node-version: [20] - # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Checkout uses: actions/checkout@v4 From c67e1fa2670ee9561c0199fed7909fb9fbe4fdf8 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 23 Dec 2024 17:29:43 +0800 Subject: [PATCH 2/6] docs: update --- CONTRIBUTING.md | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7452aec14..becbadb7c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -123,21 +123,13 @@ pnpm run lint For VS Code users, you can install the [Biome VS Code extension](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) to see lints while typing. -# Versioning - -We use [changesets](https://github.com/changesets/changesets) to manage version. Currently, all rslib packages will use a fixed unified version. - -The release notes are automatically generated by [GitHub releases](https://github.com/web-infra-dev/rslib/releases). - ## Releasing -Repository maintainers can publish a new version of all packages to npm. - -Here are the steps to publish (we generally use CI for releases and avoid publishing npm packages locally): - - +Repository maintainers can publish a new version of changed packages to npm. -1. Run `pnpm generate-release-pr` to create a release pull request. -2. [Run the release action on release branch](https://github.com/web-infra-dev/rslib/actions/workflows/release.yml). -3. Merge the release pull request. -4. [Create Git tag on main branch and generate the release notes](https://github.com/web-infra-dev/rslib/releases). +1. Checkout a new release branch, for example `release_v1.2.0` +2. Run [changesets](https://github.com/changesets/changesets) to bump changed packages and commit the changes. +3. Create a pull request, the title should be `release: v1.2.0`. +4. Run the [release action](https://github.com/web-infra-dev/rsbuild/actions/workflows/release.yml) to publish packages to npm. +5. Generate the [release notes](https://github.com/web-infra-dev/rsbuild/releases) via GitHub, see [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) +6. Merge the release pull request to `main`. From 49125d553f34ed698a78295ee25e460b78c377bc Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 23 Dec 2024 17:35:18 +0800 Subject: [PATCH 3/6] fix --- scripts/dictionary.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/dictionary.txt b/scripts/dictionary.txt index da7eef768..3cda1fc03 100644 --- a/scripts/dictionary.txt +++ b/scripts/dictionary.txt @@ -69,6 +69,7 @@ mtsx napi nodenext nolyfill +npmjs ntqry onclosetag onopentag From 0fdaadfd495c970570353881e5b077ffa6821526 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 23 Dec 2024 17:42:54 +0800 Subject: [PATCH 4/6] docs: update --- CONTRIBUTING.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index becbadb7c..d6f30db93 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,9 +127,8 @@ For VS Code users, you can install the [Biome VS Code extension](https://marketp Repository maintainers can publish a new version of changed packages to npm. -1. Checkout a new release branch, for example `release_v1.2.0` -2. Run [changesets](https://github.com/changesets/changesets) to bump changed packages and commit the changes. -3. Create a pull request, the title should be `release: v1.2.0`. -4. Run the [release action](https://github.com/web-infra-dev/rsbuild/actions/workflows/release.yml) to publish packages to npm. -5. Generate the [release notes](https://github.com/web-infra-dev/rsbuild/releases) via GitHub, see [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) -6. Merge the release pull request to `main`. +1. Run `pnpm generate-release-pr` to generate a release pull request. +2. Create a pull request, the title should be `release: v1.2.0`. +3. Run the [release action](https://github.com/web-infra-dev/rsbuild/actions/workflows/release.yml) to publish packages to npm. +4. Generate the [release notes](https://github.com/web-infra-dev/rsbuild/releases) via GitHub, see [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) +5. Merge the release pull request to `main`. From 3c813cff61cff5b9045fa1fb526041bf112bb237 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 23 Dec 2024 17:43:19 +0800 Subject: [PATCH 5/6] docs: update --- CONTRIBUTING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6f30db93..2e9f998f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -128,7 +128,6 @@ For VS Code users, you can install the [Biome VS Code extension](https://marketp Repository maintainers can publish a new version of changed packages to npm. 1. Run `pnpm generate-release-pr` to generate a release pull request. -2. Create a pull request, the title should be `release: v1.2.0`. -3. Run the [release action](https://github.com/web-infra-dev/rsbuild/actions/workflows/release.yml) to publish packages to npm. -4. Generate the [release notes](https://github.com/web-infra-dev/rsbuild/releases) via GitHub, see [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) -5. Merge the release pull request to `main`. +2. Run the [release action](https://github.com/web-infra-dev/rsbuild/actions/workflows/release.yml) to publish packages to npm. +3. Generate the [release notes](https://github.com/web-infra-dev/rsbuild/releases) via GitHub, see [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) +4. Merge the release pull request to `main`. From 2eb5c217524d3596faccb5585058280e60a17934 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 23 Dec 2024 17:43:57 +0800 Subject: [PATCH 6/6] docs: update --- CONTRIBUTING.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e9f998f7..a93b46171 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,7 +127,8 @@ For VS Code users, you can install the [Biome VS Code extension](https://marketp Repository maintainers can publish a new version of changed packages to npm. -1. Run `pnpm generate-release-pr` to generate a release pull request. -2. Run the [release action](https://github.com/web-infra-dev/rsbuild/actions/workflows/release.yml) to publish packages to npm. -3. Generate the [release notes](https://github.com/web-infra-dev/rsbuild/releases) via GitHub, see [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) -4. Merge the release pull request to `main`. +1. Run `pnpm generate-release-pr` to generate a release branch. +2. Create a pull request, the title should be `release: v1.2.0`. +3. Run the [release action](https://github.com/web-infra-dev/rsbuild/actions/workflows/release.yml) to publish packages to npm. +4. Generate the [release notes](https://github.com/web-infra-dev/rsbuild/releases) via GitHub, see [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) +5. Merge the release pull request to `main`.