From e577728044f6e855061b8f654406de941784956b Mon Sep 17 00:00:00 2001 From: Hanssen0 Date: Mon, 26 Aug 2024 01:09:29 +0800 Subject: [PATCH] chore: ci for publishing --- .github/workflows/check.yaml | 2 +- .github/workflows/publish.yaml | 43 ++++++++++++++++++++++++++++++++++ package.json | 2 ++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index a39f0f11..8f1596c3 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -20,4 +20,4 @@ jobs: - name: Lint run: pnpm lint - name: Build - run: pnpm build + run: pnpm build:all diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..0cb7b58a --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,43 @@ +name: Release to NPM + +permissions: + pull-requests: write + contents: write + +on: + push: + branches: + - master + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Install dependencies + run: pnpm build:prepare + - name: Build + run: pnpm build + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + title: "chore: bump packages version" + commit: "chore: bump packages version" + changeset: pnpm run version + # This expects you to have a script called release which does a build for your packages and calls changeset publish + publish: pnpm run publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 59fa6af7..b5645bb8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "scripts": { "test": "jest", "test:cov": "jest --coverage", + "build:prepare": "pnpm -r --filter !./packages/demo --filter !./packages/faucet install", "build": "pnpm -r --filter !./packages/demo --filter !./packages/faucet run build", + "build:all": "pnpm -r run build", "lint": "pnpm -r run lint", "format": "pnpm -r run format", "sync:config": "pnpm -r --filter !./packages/demo --filter !./packages/faucet -c exec \"cp ../../config/* . && cp ../../config/.* .\"",