From 4a4f2e99d02897a84c58f4946e4be24c48612934 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 7 Nov 2022 20:49:15 +0000 Subject: [PATCH] chore: update github action workflows --- .github/workflows/ci.yml | 29 ++++++--------- .github/workflows/release.yml | 68 +++++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a4b137f..7337ebe8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,9 @@ -name: CI +name: ci on: push: branches: - main - pull_request: branches: - main @@ -14,19 +13,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set node - uses: actions/setup-node@v3 + - run: corepack enable + - uses: actions/setup-node@v3 with: - node-version: 16.x - - - name: Setup - run: npm i -g @antfu/ni + node-version: 16 + cache: 'pnpm' - name: Install - run: nci + run: pnpm install - name: Lint - run: nr lint + run: pnpm lint test: runs-on: ${{ matrix.os }} @@ -44,14 +41,10 @@ jobs: with: node-version: ${{ matrix.node }} - - name: Setup - run: npm i -g @antfu/ni - - - name: Install - run: nci - - name: Build - run: nr build + run: pnpm build - name: Test - run: nr test + run: pnpm test --coverage + + - uses: codecov/codecov-action@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 216ba3b7..a8354de1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,22 +1,68 @@ -name: Release - on: push: - tags: - - 'v*' - + branches: + - main +name: Release jobs: - release: + release-pr: runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: node + token: ${{ secrets.RELEASE_PR_TOKEN }} + changelog-types: |- + [ + { "type": "feat", "section": "๐Ÿ”– Features", "hidden": false }, + { "type": "fix", "section": "๐Ÿ› Bug Fixes", "hidden": false }, + { "type": "chore", "section": "๐Ÿงน Miscellaneous", "hidden": false } + ] + + # Format changelog, workaround for https://github.com/google-github-actions/release-please-action/issues/542 + # Taken from https://github.com/remarkablemark/release-please-extra-files-demo/blob/master/.github/workflows/release-please.yml - uses: actions/checkout@v3 + if: ${{ steps.release.outputs.pr }} with: - fetch-depth: 0 + ref: ${{ fromJson(steps.release.outputs.pr).headBranchName }} + + - name: Configure Git user + if: ${{ steps.release.outputs.pr }} + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git --no-pager show --name-only + - name: Format CHANGELOG.md + if: ${{ steps.release.outputs.pr }} + run: npx prettier --write CHANGELOG.md + + - name: Commit and push + if: ${{ steps.release.outputs.pr }} + run: | + git add CHANGELOG.md + git commit -m 'chore: Format CHANGELOG.md with Prettier' --no-verify + git push + + publish_npm: + name: Publish to npm + runs-on: ubuntu-latest + needs: [release-pr] + if: needs.release-pr.outputs.release_created + steps: + - uses: actions/checkout@v3 + - run: corepack enable - uses: actions/setup-node@v3 with: - node-version: 16.x - - - run: npx changelogithub + node-version: 16 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install + - name: Config npm + run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Publish to npm + run: pnpm publish --access public --no-git-checks