Skip to content

Commit 8134609

Browse files
authored
ref: workflows (#390)
* ♻️ snapshot release on any pr and add swc plugin workflows * ✨ snapshot release and upgrade actions * ✨ flat eslint config * 🔧 snapshot release scripts
1 parent 5eb0dac commit 8134609

19 files changed

+372
-154
lines changed

.changeset/few-shoes-glow.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aiou/generator-pnpm-ci": minor
3+
---
4+
5+
use flat eslint config

.changeset/new-lemons-cheat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aiou/generator-pnpm-ci": minor
3+
---
4+
5+
update snapshot release script

.changeset/tricky-papayas-change.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aiou/generator-pnpm-ci": minor
3+
---
4+
5+
snapshot release on pr and upgrade actions

.changeset/two-stingrays-yell.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aiou/preset-aiou": major
3+
---
4+
5+
snapshot-release on pull_request and add swc plugin workflows

packages/generators/pnpm-ci/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ prepack follow parts into your project
1313
> **💡 NOTE**
1414
CI workflows will automatic choose pnpm version and cache `.pnpm-store` via <https://github.com/pnpm/action-setup>.
1515
16+
> **💡 NOTE**
17+
Changesets release required `settings > actions > Workflow permissions`:
18+
- Read and write permissions
19+
- Allow Github Actions to create and approve all pull request
20+
1621
- `release.yml` - publish package with `changeset`
1722
- `snapshot-release.yml` - publish prerelease package with `changeset`
1823
- `husky`

packages/generators/pnpm-ci/assets/eslint/.eslintrc

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { aiou } = require('@aiou/eslint-config')
2+
3+
module.exports = aiou({ ssr: false })

packages/generators/pnpm-ci/assets/workflows/ci.yml

+14-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Node.js CI
33
on:
44
push:
55
pull_request:
6-
branches: [master,release]
6+
branches: [master, release]
77

88
jobs:
99
test:
@@ -12,37 +12,40 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [14.x, 16.x]
15+
node-version: [16.x, 18.x]
1616

1717
steps:
18-
- name: checkout code repository
19-
uses: actions/checkout@v2
18+
- name: Checkout code repository
19+
uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0
2222
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v1
23+
uses: actions/setup-node@v4
2424
with:
2525
node-version: ${{ matrix.node-version }}
26+
# Install pnpm depends on package.json packageManager field
2627
- uses: pnpm/action-setup@v2
2728
name: Install pnpm
2829
id: pnpm-install
2930
with:
3031
run_install: false
31-
- name: get pnpm store directory
32-
id: pnpm-cache
32+
- name: Get pnpm store directory
3333
shell: bash
3434
run: |
35-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
35+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
3636
- uses: actions/cache@v3
37-
name: setup pnpm cache
37+
name: Setup pnpm cache
3838
with:
39-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
39+
path: ${{ env.STORE_PATH }}
4040
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
4141
restore-keys: |
4242
${{ runner.os }}-pnpm-store-
43-
- name: Install
43+
- name: Install
4444
run: |
4545
pnpm install --frozen-lockfile=false
46+
# - name: Build
47+
# run: |
48+
# pnpm build
4649
- name: Test
4750
run: |
4851
pnpm test

packages/generators/pnpm-ci/assets/workflows/release.yml

+14-16
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,45 @@ on:
55
- main
66
- master
77
- 'releases/*'
8-
9-
concurrency: ${{ github.workflow }}-${{ github.ref }}
10-
118
env:
129
CI: true
1310
jobs:
14-
version:
11+
release:
1512
timeout-minutes: 15
1613
runs-on: ubuntu-latest
1714
permissions:
1815
contents: write
1916
packages: write
2017
pull-requests: write
2118
steps:
22-
- name: checkout code repository
23-
uses: actions/checkout@v2
19+
- name: Checkout code repository
20+
uses: actions/checkout@v4
2421
with:
2522
fetch-depth: 0
26-
- name: setup node.js
27-
uses: actions/setup-node@v2
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
2825
with:
29-
node-version: 14
26+
node-version: 18
27+
# Install pnpm depends on package.json packageManager field
3028
- uses: pnpm/action-setup@v2
3129
name: Install pnpm
3230
id: pnpm-install
3331
with:
3432
run_install: false
35-
- name: get pnpm store directory
36-
id: pnpm-cache
33+
- name: Get pnpm store directory
3734
shell: bash
3835
run: |
39-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
36+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
4037
- uses: actions/cache@v3
41-
name: setup pnpm cache
38+
name: Setup pnpm cache
4239
with:
43-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
40+
path: ${{ env.STORE_PATH }}
4441
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
4542
restore-keys: |
4643
${{ runner.os }}-pnpm-store-
47-
- name: install dependencies
48-
run: pnpm install --frozen-lockfile=false
44+
- name: Install
45+
run: |
46+
pnpm install --frozen-lockfile=false
4947
- name: create and publish versions
5048
uses: changesets/action@v1
5149
with:
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
name: Release
1+
name: Snapshot Release
22
on:
33
push:
4+
paths:
5+
- ".changeset/**"
46
branches:
57
- snapshot
6-
7-
concurrency: ${{ github.workflow }}-${{ github.ref }}
8-
8+
pull_request:
9+
paths:
10+
- ".changeset/**"
11+
branches: [master, main, release]
912
env:
1013
CI: true
1114
jobs:
12-
version:
13-
timeout-minutes: 15
15+
snapshot-release:
16+
# Only repo owner can publish snapshot version when create pr target master
17+
if: ${{ github.triggering_actor == github.repository_owner }}
1418
runs-on: ubuntu-latest
15-
permissions:
16-
contents: write
17-
packages: write
18-
pull-requests: write
1919
steps:
2020
- name: checkout code repository
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
2424
- name: setup node.js
25-
uses: actions/setup-node@v2
25+
uses: actions/setup-node@v4
2626
with:
27-
node-version: 14
27+
node-version: 18
2828
- uses: pnpm/action-setup@v2
2929
name: Install pnpm
3030
id: pnpm-install
@@ -34,23 +34,37 @@ jobs:
3434
id: pnpm-cache
3535
shell: bash
3636
run: |
37-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
37+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
3838
- uses: actions/cache@v3
3939
name: setup pnpm cache
4040
with:
41-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
41+
path: ${{ env.STORE_PATH }}
4242
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
4343
restore-keys: |
4444
${{ runner.os }}-pnpm-store-
4545
- name: install dependencies
4646
run: pnpm install --frozen-lockfile=false
47+
- name: Creating .npmrc
48+
run: |
49+
cat << EOF > "$HOME/.npmrc"
50+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
51+
EOF
52+
env:
53+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
# enable it if develop swc plugin
55+
# - name: install Rust
56+
# uses: actions-rs/toolchain@v1
57+
# with:
58+
# profile: minimal
59+
# - name: install wasm target
60+
# shell: bash
61+
# run: |
62+
# rustup target add wasm32-wasi
4763
- name: create and publish versions
48-
uses: changesets/action@v1
49-
with:
50-
version: pnpm ci:snapshot
51-
commit: "chore: update versions"
52-
title: "chore: update versions"
53-
publish: pnpm ci:prerelease
64+
run: |
65+
pnpm ci:snapshot
66+
pnpm changeset pre enter snapshot
67+
pnpm ci:prerelease
5468
env:
5569
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

packages/generators/pnpm-ci/index.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ jobs:
4343
- path: "scripts.ci:publish"
4444
value: "pnpm run build && pnpm changeset publish"
4545
- path: "scripts.ci:snapshot"
46-
value: "pnpm changeset version --snapshot beta"
46+
value: "pnpm changeset version --snapshot snapshot"
4747
- path: "scripts.ci:prerelease"
48-
value: "pnpm run build && pnpm changeset publish --tag beta"
48+
value: "pnpm run build && pnpm changeset publish --no-git-tag --snapshot"
4949
- name: Add lint-staged
5050
uses: json-editor
5151
with:
5252
pairs:
5353
- path: "lint-staged"
5454
value:
55-
"**/**/*.{js,ts,tsx,vue,json,yml,yaml}": ["eslint --fix"]
55+
"**/**/*.{js,ts,tsx,json,yml,yaml,md}": ["eslint --fix"]
5656

5757
- name: Add lint pkgs
5858
uses: json-editor
@@ -61,9 +61,9 @@ jobs:
6161
- path: "devDependencies.typescript"
6262
value: "^4.6.4"
6363
- path: "devDependencies.eslint"
64-
value: "^8.32.0"
64+
value: "^8.56.0"
6565
- path: "devDependencies.@aiou/eslint-config"
66-
value: "^0.10.0"
66+
value: "^1.2.1"
6767
- path: "devDependencies.lint-staged"
6868
value: "^13.1.0"
6969

packages/presets/aiou/assets/workflows/pnpm/ci.yaml

+26-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Node.js CI
33
on:
44
push:
55
pull_request:
6-
branches: [master,release]
6+
branches: [master, release]
77

88
jobs:
99
test:
@@ -12,22 +12,40 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [12.x, 14.x, 16.x]
15+
node-version: [16.x, 18.x]
1616

1717
steps:
18-
- name: checkout code repository
19-
uses: actions/checkout@v2
18+
- name: Checkout code repository
19+
uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0
2222
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v1
23+
uses: actions/setup-node@v4
2424
with:
2525
node-version: ${{ matrix.node-version }}
26-
- name: Install pnpm
27-
run: npm i [email protected] -g
28-
- name: Install
26+
# Install pnpm depends on package.json packageManager field
27+
- uses: pnpm/action-setup@v2
28+
name: Install pnpm
29+
id: pnpm-install
30+
with:
31+
run_install: false
32+
- name: Get pnpm store directory
33+
shell: bash
34+
run: |
35+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
36+
- uses: actions/cache@v3
37+
name: Setup pnpm cache
38+
with:
39+
path: ${{ env.STORE_PATH }}
40+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pnpm-store-
43+
- name: Install
2944
run: |
3045
pnpm install --frozen-lockfile=false
46+
# - name: Build
47+
# run: |
48+
# pnpm build
3149
- name: Test
3250
run: |
3351
pnpm test

0 commit comments

Comments
 (0)