From ef8d7a5b19cf52423de84d9a8fa515e4f6db60da Mon Sep 17 00:00:00 2001 From: aelf-lxy Date: Thu, 1 Aug 2024 14:28:47 +0800 Subject: [PATCH] feat: add publish.yml --- .github/workflows/coverage.yml | 5 +++-- .github/workflows/publish.yml | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c35179ff..927c8581 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -4,12 +4,13 @@ on: push: branches: - release/refactor-3.0.0 + - feature/badge-new pull_request: branches: - release/refactor-3.0.0 jobs: - test: + coverage: runs-on: ubuntu-latest strategy: @@ -23,7 +24,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: '18' + node-version: '20' - name: Install pnpm run: npm install -g pnpm diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..175c19dc --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,40 @@ +name: publish to npm +env: + CI: true +on: + push: + branches: + - release/refactor-3.0.0 + - feature/badge-new + tags: + - '!*' + pull_request: + branches: + - release/refactor-3.0.0 +jobs: + release: + name: Setup + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + registry-url: 'https://npm.pkg.github.com' + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + + - name: Publish to npm + run: | + npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN + pnpm release || (echo "pnpm publish failed" && exit 1) + env: + NPM_TOKEN: ${{secrets.NPM_TOKEN}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}