From 3f63428f4bbfa4a94d6d18c4ffabf3a54dcd61db Mon Sep 17 00:00:00 2001 From: YuShifan <894402575bt@gmail.com> Date: Wed, 8 Nov 2023 16:32:01 +0800 Subject: [PATCH] chore(ci): add release and publish to npm ci action --- .github/workflows/release_publish.yaml | 42 ++++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release_publish.yaml diff --git a/.github/workflows/release_publish.yaml b/.github/workflows/release_publish.yaml new file mode 100644 index 0000000..e3d63c1 --- /dev/null +++ b/.github/workflows/release_publish.yaml @@ -0,0 +1,42 @@ +name: Release and Publish + +on: + push: + tags: + - '*' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.17' + registry-url: 'https://registry.npmjs.org' + + - name: use pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Cache pnpm modules + uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: Install dependencies + run: pnpm install + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + publish: pnpm release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 9bb1d7f..79c3a7e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "dev": "turbo run dev", "build": "turbo run build", "test": "turbo run test", - "format": "prettier --write ." + "format": "prettier --write .", + "release": "turbo run test build && changeset version && changeset publish" }, "devDependencies": { "@changesets/cli": "^2.26.2",