Skip to content

Commit

Permalink
ci: refactor workflows (#404)
Browse files Browse the repository at this point in the history
* ci: no need to set publish script for each package
* ci: sync github release in ci
* ci: use setup-node build-in cache
* ci: run test both linux and windows, tweaks

---------

Co-authored-by: Neko <neko@ayaka.moe>
  • Loading branch information
northword and nekomeowww authored Feb 13, 2025
1 parent 544b473 commit d88eaf8
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 160 deletions.
28 changes: 7 additions & 21 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches:
- main

env:
STORE_PATH: ''

jobs:
build:
strategy:
Expand Down Expand Up @@ -39,28 +36,17 @@ jobs:
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# registry-url required. Learn more at
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
registry-url: 'https://registry.npmjs.org'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down
85 changes: 25 additions & 60 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,31 @@ on:
branches:
- main

env:
STORE_PATH: ''

jobs:
unittest:
strategy:
matrix:
node-version: ['20.x', '22.x']
os: [ubuntu-latest, windows-latest]

name: Unit Tests - ${{ matrix.node-version }}
runs-on: 'ubuntu-latest'
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# registry-url required. Learn more at
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
registry-url: 'https://registry.npmjs.org'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand All @@ -68,28 +55,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: '22.x'

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: 22.x
# registry-url required. Learn more at
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
registry-url: 'https://registry.npmjs.org'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand All @@ -105,28 +81,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: '22.x'

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: 22.x
# registry-url required. Learn more at
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
registry-url: 'https://registry.npmjs.org'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/production-docs-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches:
- 'main'

env:
STORE_PATH: ''

jobs:
build:
name: Build
Expand All @@ -21,28 +18,17 @@ jobs:
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# registry-url required. Learn more at
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
registry-url: 'https://registry.npmjs.org'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down
39 changes: 18 additions & 21 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ on:
tags:
- 'v*'

env:
STORE_PATH: ''
permissions:
contents: write
issues: write
pull-requests: write
id-token: write

jobs:
release:
Expand All @@ -15,6 +18,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js 22.x
uses: actions/setup-node@v4
Expand All @@ -23,24 +31,7 @@ jobs:
# registry-url required. Learn more at
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand All @@ -49,6 +40,12 @@ jobs:
run: pnpm run packages:build

- name: Packages publish
run: pnpm run packages:publish
run: pnpm publish -r --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_CONFIG_PROVENANCE: true

- name: Sync GitHub Release
run: pnpx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"packages:dev": "pnpm cleanup:dist && pnpm -r --filter=./packages/* run dev",
"packages:stub": "pnpm -r --filter=./packages/* run stub",
"packages:build": "pnpm cleanup:dist && pnpm -r --filter=./packages/* run build",
"packages:publish": "pnpm cleanup:dist && pnpm -r --filter=./packages/* run package:publish",
"cleanup:dist": "rimraf --glob **/dist",
"cleanup:node_modules": "rimraf --glob **/node_modules",
"test": "vitest --coverage",
Expand Down
3 changes: 1 addition & 2 deletions packages/markdown-it-bi-directional-links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"scripts": {
"stub": "unbuild --stub",
"dev": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"markdown-it": ">=14.1.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/markdown-it-element-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"scripts": {
"stub": "unbuild --stub",
"dev": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"markdown-it": ">=14.1.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/markdown-it-unlazy-img/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
"scripts": {
"stub": "unbuild --stub",
"dev": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"markdown-it": ">=14.1.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/ui-asciinema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
"scripts": {
"dev": "unbuild --stub",
"stub": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"asciinema-player": "^3.8.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/ui-rive-canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
"scripts": {
"dev": "unbuild --stub",
"stub": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"@rive-app/canvas": "^2.25.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
"scripts": {
"dev": "unbuild --stub",
"stub": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"vitepress": "catalog:"
Expand Down
3 changes: 1 addition & 2 deletions packages/vitepress-plugin-breadcrumbs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"scripts": {
"dev": "unbuild --stub",
"stub": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"vitepress": "catalog:"
Expand Down
3 changes: 1 addition & 2 deletions packages/vitepress-plugin-enhanced-mark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"scripts": {
"dev": "unbuild --stub",
"stub": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"vitepress": "catalog:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"scripts": {
"dev": "unbuild --stub",
"stub": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"vitepress": "catalog:"
Expand Down
3 changes: 1 addition & 2 deletions packages/vitepress-plugin-git-changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
"scripts": {
"dev": "unbuild --stub",
"stub": "unbuild --stub",
"build": "unbuild",
"package:publish": "pnpm build && pnpm publish --access public --no-git-checks"
"build": "unbuild"
},
"peerDependencies": {
"vitepress": "catalog:"
Expand Down
Loading

0 comments on commit d88eaf8

Please sign in to comment.