Skip to content

Commit 9807e57

Browse files
author
Brian
committed
feat: add GitHub Actions CI/CD and release automation
- Add release.yml workflow for npm publishing on tag push - Add ci.yml workflow for tests on push/PR - Add build script with ESM, CJS, and minified outputs - Add release script for version management and tagging - Update package.json with proper exports and build config - Exclude dist/ and scripts/ from pre-commit validators
1 parent 9f48e4a commit 9807e57

10 files changed

Lines changed: 965 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run validation and tests
26+
run: npm run validate:all
27+
28+
- name: Build bundles
29+
run: npm run build
30+
31+
- name: Verify build outputs
32+
run: |
33+
for file in jss.min.js jss.esm.js jss.cjs.js; do
34+
if [ ! -f "dist/$file" ]; then
35+
echo "ERROR: Missing dist/$file"
36+
exit 1
37+
fi
38+
done
39+
echo "Build verified!"

.github/workflows/release.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Release to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
registry-url: 'https://registry.npmjs.org'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run tests
32+
run: npm run test:coverage:check
33+
34+
- name: Build bundles
35+
run: npm run build
36+
37+
- name: Verify build outputs
38+
run: |
39+
echo "Checking build outputs..."
40+
ls -la dist/
41+
42+
for file in jss.min.js jss.min.js.map jss.esm.js jss.esm.js.map jss.cjs.js jss.cjs.js.map; do
43+
if [ ! -f "dist/$file" ]; then
44+
echo "ERROR: Missing dist/$file"
45+
exit 1
46+
fi
47+
done
48+
49+
echo "All build outputs verified!"
50+
51+
- name: Publish to npm
52+
run: npm publish --provenance --access public
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
56+
- name: Get previous tag
57+
id: prev_tag
58+
run: |
59+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
60+
echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT
61+
62+
- name: Generate release notes
63+
id: release_notes
64+
run: |
65+
CURRENT_TAG="${GITHUB_REF_NAME}"
66+
PREV_TAG="${{ steps.prev_tag.outputs.tag }}"
67+
68+
echo "Current tag: $CURRENT_TAG"
69+
echo "Previous tag: $PREV_TAG"
70+
71+
if [ -n "$PREV_TAG" ]; then
72+
COMMITS=$(git log ${PREV_TAG}..${CURRENT_TAG} --pretty=format:"- %s" --no-merges)
73+
else
74+
COMMITS=$(git log --pretty=format:"- %s" --no-merges)
75+
fi
76+
77+
# Write to file for multi-line handling
78+
echo "## What's Changed" > release_notes.md
79+
echo "" >> release_notes.md
80+
echo "$COMMITS" >> release_notes.md
81+
echo "" >> release_notes.md
82+
echo "---" >> release_notes.md
83+
echo "" >> release_notes.md
84+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${CURRENT_TAG}" >> release_notes.md
85+
86+
cat release_notes.md
87+
88+
- name: Create GitHub Release
89+
uses: softprops/action-gh-release@v2
90+
with:
91+
body_path: release_notes.md
92+
files: |
93+
dist/jss.min.js
94+
dist/jss.min.js.map
95+
dist/jss.esm.js
96+
dist/jss.esm.js.map
97+
dist/jss.cjs.js
98+
dist/jss.cjs.js.map
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
coverage/
3+
dist/

.hooks/pre-commit.d/check-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cd "$PROJECT_ROOT"
3131
echo " Checking documentation (README.md & files.md in every folder)..."
3232

3333
# Directories to exclude from checking
34-
EXCLUDED_DIRS="node_modules|\.git|\.hooks|coverage|\.claude"
34+
EXCLUDED_DIRS="node_modules|\.git|\.hooks|coverage|\.claude|dist|scripts"
3535

3636
# Track missing files
3737
MISSING_README=()

.hooks/pre-commit.d/jsdoc-validator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ function main() {
122122
".hooks",
123123
"coverage",
124124
".claude",
125+
"dist",
126+
"scripts",
125127
];
126128

127129
console.log(" Validating JSDoc comments...");

.hooks/pre-commit.d/yoda-validator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ function main() {
106106
".hooks",
107107
"coverage",
108108
".claude",
109+
"dist",
110+
"scripts",
109111
];
110112

111113
console.log(" Validating Yoda conditions...");

0 commit comments

Comments
 (0)