Skip to content

Commit f0f5036

Browse files
authored
chore: ci & scripts optimizations (#17)
1 parent 897ec7c commit f0f5036

File tree

10 files changed

+39
-36
lines changed

10 files changed

+39
-36
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,8 @@ jobs:
2828
with:
2929
node-version-file: package.json
3030

31-
- name: Cache lint results
32-
uses: actions/cache@v4
33-
with:
34-
key: ${{ runner.os }}-lint-${{ hashFiles('bun.lock', 'packages/eslint-config/src/index.ts', 'packages/stylelint-config/src/index.ts') }}
35-
path: |
36-
.eslintcache
37-
.stylelintcache
38-
3931
- name: Install dependencies
40-
run: bun install --frozen-lockfile --ignore-scripts
32+
run: bun install --frozen-lockfile
4133

4234
- name: Build
4335
run: bun run build
@@ -46,10 +38,17 @@ jobs:
4638
run: bun run check:unused
4739

4840
- name: Lint
49-
run: bun run check:eslint --cache-strategy content && bun run check:stylelint --cache-strategy content
41+
run: bun run check:eslint && bun run check:stylelint
5042

5143
- name: Type check
5244
run: bun run check:types
5345

5446
- name: Unit tests
5547
run: bun run test --coverage
48+
49+
- name: Cache build
50+
if: github.event_name == 'push'
51+
uses: actions/cache/save@v4
52+
with:
53+
path: packages/*/dist
54+
key: ${{ runner.os }}-build-${{ hashFiles('packages/*/dist/**') }}

.github/workflows/release.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ jobs:
3030
registry-url: https://registry.npmjs.org
3131

3232
- name: Install dependencies
33-
run: bun install --frozen-lockfile --ignore-scripts
33+
run: bun install --frozen-lockfile
3434

35-
- name: Build
36-
run: bun run build
35+
- name: Restore build cache
36+
uses: actions/cache/restore@v4
37+
with:
38+
path: packages/*/dist
39+
key: ${{ runner.os }}-build
40+
restore-keys: |
41+
${{ runner.os }}-build-
3742
38-
- name: Copy license
39-
run: bun scripts/copyLicense.ts
43+
- name: Prepublish
44+
run: bun run prepublish
4045

4146
- name: Publish
4247
run: npm publish -w packages --access public

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
.cache
22
.DS_Store
33
.env*
4-
.eslintcache
54
.idea
6-
.stylelintcache
75
.temp
86
*.local
97
*.log

bump.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { defineConfig } from 'bumpp'
55
export default defineConfig({
66
all: true,
77
execute: async ({ state: { newVersion } }) => {
8-
const lockFile = await fs.readFile('bun.lock', 'utf8')
8+
const lockFile = await fs.readFile('bun.lock', 'utf-8')
99
await fs.writeFile('bun.lock', lockFile.replace(
1010
/"version": "(.*?)"/g,
1111
`"version": "${newVersion}"`,

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
"build": "bun scripts/build.ts",
1515
"clean": "bun scripts/clean.ts",
1616
"check": "bun run check:unused && bun run check:eslint && bun run check:stylelint && bun run check:types",
17-
"check:eslint": "eslint --cache .",
18-
"check:stylelint": "stylelint --cache '**/*.{css,scss,vue}' --ignorePath .gitignore",
17+
"check:eslint": "eslint .",
18+
"check:stylelint": "stylelint '**/*.{css,scss,vue}' --ignorePath .gitignore",
1919
"check:types": "vue-tsc --noEmit",
2020
"check:unused": "knip",
2121
"lint": "bun run check:eslint && bun run check:stylelint",
2222
"lint:inspect": "bunx @eslint/config-inspector",
23-
"postinstall": "bun run build",
23+
"postinstall": "bun scripts/postinstall.ts",
24+
"prepublish": "bun scripts/prepublish.ts",
2425
"release": "bumpp",
2526
"test": "vitest",
2627
"test:ui": "vitest --ui"

packages/create-app/template/.github/workflows/ci.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jobs:
1212
check:
1313
name: Check
1414
runs-on: ubuntu-latest
15-
if: |
16-
!startsWith(github.event.head_commit.message, 'chore: release')
1715
steps:
1816
- name: Checkout
1917
uses: actions/checkout@v4
@@ -28,22 +26,14 @@ jobs:
2826
with:
2927
node-version-file: package.json
3028

31-
- name: Cache lint results
32-
uses: actions/cache@v4
33-
with:
34-
key: ${{ runner.os }}-lint-${{ hashFiles('bun.lock', 'eslint.config.ts', 'stylelint.config.ts') }}
35-
path: |
36-
.eslintcache
37-
.stylelintcache
38-
3929
- name: Install dependencies
4030
run: bun install --frozen-lockfile
4131

4232
- name: Check unused files, dependencies, and exports
4333
run: bun run check:unused
4434

4535
- name: Lint
46-
run: bun run check:eslint --cache-strategy content && bun run check:stylelint --cache-strategy content
36+
run: bun run check:eslint && bun run check:stylelint
4737

4838
- name: Type check
4939
run: bun run check:types

packages/create-app/template/gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
.cache
22
.DS_Store
33
.env*
4-
.eslintcache
54
.idea
6-
.stylelintcache
75
.temp
86
*.local
97
*.log

packages/create-app/template/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
],
1414
"scripts": {
1515
"check": "bun run check:unused && bun run check:eslint && bun run check:stylelint && bun run check:types",
16-
"check:eslint": "eslint --cache .",
17-
"check:stylelint": "stylelint --cache '**/*.{css,scss,vue}' --ignorePath .gitignore",
16+
"check:eslint": "eslint .",
17+
"check:stylelint": "stylelint '**/*.{css,scss,vue}' --ignorePath .gitignore",
1818
"check:types": "vue-tsc --noEmit",
1919
"check:unused": "knip",
2020
"lint": "bun run check:eslint && bun run check:stylelint",

scripts/postinstall.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import process from 'node:process'
2+
3+
if (process.env.CI) {
4+
console.log('CI environment detected, skipping build')
5+
process.exit(0)
6+
}
7+
8+
await import('./build')

scripts/copyLicense.ts renamed to scripts/prepublish.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import fs from 'node:fs/promises'
22

33
import { glob } from 'tinyglobby'
44

5+
import { version } from '../package.json'
6+
57
const pkgPaths = await glob('packages/*', { onlyDirectories: true })
68

79
await Promise.all(pkgPaths.map(async (pkgPath) => {
10+
const pkgJson = await fs.readFile(`${pkgPath}/package.json`, 'utf-8')
11+
await fs.writeFile(`${pkgPath}/package.json`, pkgJson.replace('workspace:*', `^${version}`))
812
await fs.cp('LICENSE', `${pkgPath}/LICENSE`)
913
}))

0 commit comments

Comments
 (0)