Skip to content

Commit

Permalink
chore: update github action workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Nov 7, 2022
1 parent baa8e6f commit 4a4f2e9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 29 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: CI
name: ci

on:
push:
branches:
- main

pull_request:
branches:
- main
Expand All @@ -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 }}
Expand All @@ -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
68 changes: 57 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4a4f2e9

Please sign in to comment.