diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 000000000..0c48f8ae6 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json", + "changelog": false, + "commit": false, + "linked": [], + "access": "restricted", + "baseBranch": "main", + "fixed": [["@rslib/*"]], + "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { + "onlyUpdatePeerDependentsWhenOutOfRange": true, + "updateInternalDependents": "always" + }, + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml new file mode 100644 index 000000000..3b3362b26 --- /dev/null +++ b/.github/workflows/release-nightly.yml @@ -0,0 +1,48 @@ +name: Release Nightly + +on: + workflow_dispatch: + # Nightly release disabled + # schedule: + # 00:00 AM Beijing Time. + # - cron: "0 16 * * *" + +permissions: + # To publish packages with provenance + id-token: write + +jobs: + release: + name: Release Nightly + if: github.repository == 'web-infra-dev/rslib' + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + 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 + + - name: Release + uses: web-infra-dev/actions@v2 + with: + version: nightly + branch: main + type: 'release' + 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-pull-request.yml b/.github/workflows/release-pull-request.yml new file mode 100644 index 000000000..e7c76daac --- /dev/null +++ b/.github/workflows/release-pull-request.yml @@ -0,0 +1,53 @@ +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 new file mode 100644 index 000000000..73e4046e7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + type: choice + description: 'Release Version (next, beta, alpha, latest)' + required: true + default: 'next' + options: + - next + - beta + - alpha + - latest + branch: + description: 'Release Branch (confirm release branch)' + required: true + default: 'main' + issue_comment: + types: [created] + +permissions: + id-token: write + +jobs: + release: + name: Release + if: github.repository == 'web-infra-dev/rslib' && github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 25 + + - 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 + + - name: Release + uses: web-infra-dev/actions@v2 + with: + version: ${{ github.event.inputs.version }} + branch: ${{ github.event.inputs.branch }} + type: 'release' + tools: 'changeset' + env: + GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + REPOSITORY: ${{ github.repository }} + REF: ${{ github.ref }} diff --git a/package.json b/package.json index 201300620..0aaef33d0 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,15 @@ { "name": "rslib-monorepo", "private": true, + "workspaces": { + "packages": [ + "packages/*" + ] + }, "scripts": { "build": "cross-env NX_DAEMON=false nx run-many -t build --exclude @examples/* --parallel=10", "build:examples": "cross-env NX_DAEMON=false nx run-many -t build --projects @examples/* --parallel=10", + "change": "changeset", "check-dependency-version": "check-dependency-version-consistency .", "check-spell": "npx cspell", "lint": "biome check . --diagnostic-level=warn && pnpm run check-spell", @@ -29,6 +35,7 @@ }, "devDependencies": { "@biomejs/biome": "^1.8.3", + "@changesets/cli": "^2.27.7", "@modern-js/module-tools": "^2.55.0", "@types/fs-extra": "^11.0.4", "@types/node": "~18.19.39", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ccadb3f0e..e31324908 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@biomejs/biome': specifier: ^1.8.3 version: 1.8.3 + '@changesets/cli': + specifier: ^2.27.7 + version: 2.27.7 '@modern-js/module-tools': specifier: ^2.55.0 version: 2.55.0(typescript@5.5.4)