Skip to content

Commit 136218e

Browse files
committed
feat: add github actions
1 parent bf07161 commit 136218e

File tree

3 files changed

+89
-62
lines changed

3 files changed

+89
-62
lines changed

.github/workflows/ci.yml

+46-61
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,66 @@
11
name: CI/CD Pipeline
22

33
on:
4-
push:
5-
branches:
6-
- dev
74
pull_request:
5+
types: ['opened', 'edited', 'reopened', 'synchronize']
6+
push:
87
branches:
9-
- dev
8+
- main
109

1110
jobs:
12-
build:
13-
runs-on: ubuntu-latest
14-
11+
typecheck:
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v4 # v4.1.4
15+
- uses: pnpm/[email protected]
16+
- name: Use Node.js
17+
uses: actions/[email protected]
18+
with:
19+
node-version: 20
20+
cache: 'pnpm'
21+
- run: pnpm install
22+
- run: pnpm run build
23+
- run: pnpm install
24+
- run: pnpm typecheck
25+
test:
26+
runs-on: ubuntu-22.04
27+
needs: [typecheck]
1528
strategy:
1629
matrix:
17-
node-version: [16.x, 18.x, 20.x]
18-
30+
node: ['20']
1931
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v2
22-
23-
- name: Set up Node.js
24-
uses: actions/setup-node@v2
32+
- uses: actions/checkout@v4
2533
with:
26-
node-version: ${{ matrix.node-version }}
27-
28-
- name: Install dependencies
29-
run: pnpm install
30-
31-
- name: Run tests
32-
run: pnpm test
33-
34-
- name: Run coverage
35-
run: pnpm run coverage
36-
37-
- name: Build
38-
run: pnpm run build
39-
34+
fetch-depth: '0'
35+
- uses: pnpm/[email protected]
36+
- name: Use Node.js
37+
uses: actions/[email protected]
38+
with:
39+
node-version: ${{ matrix.node }}
40+
cache: 'pnpm'
41+
- run: pnpm install
42+
- run: pnpm run build
43+
- run: pnpm install
44+
- run: pnpm run coverage
4045
- name: Upload coverage report
4146
if: success()
4247
uses: actions/upload-artifact@v2
4348
with:
4449
name: coverage-report
4550
path: coverage/lcov-report/index.html
4651

47-
release:
48-
runs-on: ubuntu-latest
49-
needs: build
50-
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
51-
52+
build:
53+
strategy:
54+
matrix:
55+
node: ['20']
56+
runs-on: ubuntu-22.04
57+
needs: [typecheck]
5258
steps:
53-
- name: Checkout code
54-
uses: actions/checkout@v2
55-
56-
- name: Set up Node.js
57-
uses: actions/setup-node@v2
58-
with:
59-
node-version: 20.x
60-
61-
- name: Install dependencies
62-
run: pnpm install
63-
64-
- name: Build
65-
run: pnpm run build
66-
67-
- name: Create release
68-
id: create_release
69-
uses: actions/create-release@v1
70-
env:
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
- uses: actions/checkout@v4 # v4.1.4
60+
- uses: pnpm/[email protected]
61+
- name: Use Node.js
62+
uses: actions/[email protected]
7263
with:
73-
tag_name: ${{ github.ref }}
74-
release_name: Release ${{ github.ref }}
75-
draft: false
76-
prerelease: false
77-
78-
- name: Publish to npm
79-
run: npm publish
80-
env:
81-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
64+
node-version: ${{ matrix.node }}
65+
- run: pnpm install
66+
- run: pnpm run build

.github/workflows/release.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
permissions: write-all
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- uses: pnpm/[email protected]
19+
- name: Use Node.js
20+
uses: actions/[email protected]
21+
with:
22+
node-version: 20.x
23+
cache: 'pnpm'
24+
- run: pnpm install
25+
- run: pnpm run build
26+
27+
- name: Create release
28+
id: create_release
29+
uses: actions/create-release@v1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
tag_name: ${{ github.ref }}
34+
release_name: Release ${{ github.ref }}
35+
draft: false
36+
prerelease: false
37+
38+
- name: Publish to npm
39+
run: npm publish
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unused-i18n",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"license": "MIT",
55
"type": "module",
66
"release": {
@@ -19,6 +19,7 @@
1919
},
2020
"scripts": {
2121
"build": "rollup -c",
22+
"typecheck": "tsc --noEmit",
2223
"start": "ts-node src/index.ts",
2324
"test": "vitest",
2425
"coverage": "vitest run --coverage"

0 commit comments

Comments
 (0)