1- name : CI
1+ name : Build and Test
22
33on :
44 push :
5- branches : [main]
5+ branches : [main, develop ]
66 pull_request :
77 branches : [main]
88
1212
1313 strategy :
1414 matrix :
15- node-version : [20 .x]
15+ node-version : [18.x, 20.x, 22 .x]
1616
1717 steps :
1818 - uses : actions/checkout@v4
@@ -21,25 +21,86 @@ jobs:
2121 uses : actions/setup-node@v4
2222 with :
2323 node-version : ${{ matrix.node-version }}
24+ cache : " yarn"
2425
25- - name : Enable Corepack
26- run : corepack enable
27-
28- - name : Setup Yarn 4
29- run : corepack prepare yarn@4 --activate
26+ - name : Enable Corepack and setup Yarn 4
27+ run : |
28+ corepack enable
29+ corepack prepare yarn@4 --activate
3030
3131 - name : Install dependencies
3232 run : yarn install --frozen-lockfile
3333
34- - name : Lint
34+ - name : Run linting
3535 run : yarn lint
3636
37- - name : Test
37+ - name : Run tests
3838 run : yarn test
3939
40- - name : Upload coverage
40+ - name : Build the project
41+ run : yarn build
42+
43+ - name : Validate build outputs
44+ run : yarn validate:build
45+
46+ - name : Test global installation (CommonJS)
47+ run : |
48+ # Test that the built CJS file can execute
49+ node dist/index.cjs --help || echo "Expected: needs env vars"
50+
51+ - name : Test global installation (ESM)
52+ run : |
53+ # Test that the built ESM file can execute
54+ node dist/index.mjs --help || echo "Expected: needs env vars"
55+
56+ - name : Upload build artifacts
57+ uses : actions/upload-artifact@v4
58+ with :
59+ name : build-artifacts-node-${{ matrix.node-version }}
60+ path : |
61+ dist/
62+ !dist/**/*.map
63+ retention-days : 7
64+
65+ - name : Upload coverage (if present)
4166 if : success()
4267 uses : actions/upload-artifact@v4
4368 with :
4469 name : coverage-report
4570 path : coverage
71+
72+ # Job to test publishing (dry run)
73+ publish-test :
74+ runs-on : ubuntu-latest
75+ needs : build
76+ if : github.event_name == 'pull_request'
77+
78+ steps :
79+ - uses : actions/checkout@v4
80+
81+ - name : Use Node.js 20.x
82+ uses : actions/setup-node@v4
83+ with :
84+ node-version : 20.x
85+ cache : " yarn"
86+
87+ - name : Enable Corepack and setup Yarn 4
88+ run : |
89+ corepack enable
90+ corepack prepare yarn@4 --activate
91+
92+ - name : Install dependencies
93+ run : yarn install --frozen-lockfile
94+
95+ - name : Build the project
96+ run : yarn build
97+
98+ - name : Test npm pack
99+ run : |
100+ npm pack --dry-run
101+ echo "✅ Package can be packed successfully"
102+
103+ - name : Verify package contents
104+ run : |
105+ echo "📦 Package contents that would be published:"
106+ npm pack --dry-run 2>/dev/null | grep -E "^\s*[0-9]+" || true
0 commit comments