-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (87 loc) · 2.58 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: CI Build & Release
on:
push:
branches:
- main
pull_request:
schedule:
- cron: "0 0 * * 0" # Every Sunday at midnight UTC for token refresh
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Validate commit messages
run: |
npx --no-install commitlint --from=$(git rev-list --max-parents=0 HEAD) --to=HEAD
- name: Lint code
run: npm run lint
- name: Run jsdom tests
run: npm run test
- name: Run node tests
run: npm run test:node
- name: Run coverage
run: npm run test:coverage
release:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Git configuration
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
- name: Install dependencies
run: npm install
- name: Configure NPM registry
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Generate changelog and bump version
run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push changes and tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin main --follow-tags
- name: Publish to NPM
if: github.ref == 'refs/heads/main'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
refresh-token:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
- name: Install dependencies
run: npm install
- name: Refresh NPM Token
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_NAME: ${{ github.repository }}
run: node scripts/refresh-npm-token.js