Skip to content

Commit 01d0a3d

Browse files
authored
Merge pull request #2 from simllll/claude/docs-and-github-actions-J17y4
docs: comprehensive documentation update and GitHub Actions improvements
2 parents 6581375 + 916111e commit 01d0a3d

37 files changed

Lines changed: 2442 additions & 904 deletions

.github/workflows/publish.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: Release and Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version bump type (auto = determined by conventional commits)'
8+
required: true
9+
default: 'auto'
10+
type: choice
11+
options:
12+
- auto
13+
- patch
14+
- minor
15+
- major
16+
dry_run:
17+
description: 'Dry run (preview changes without publishing)'
18+
required: false
19+
default: false
20+
type: boolean
21+
22+
jobs:
23+
release:
24+
name: Release and Publish
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
id-token: write
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: '20'
41+
registry-url: 'https://registry.npmjs.org'
42+
cache: 'npm'
43+
44+
- name: Configure Git
45+
run: |
46+
git config --global user.name "github-actions[bot]"
47+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
48+
49+
- name: Install dependencies
50+
run: npm ci
51+
52+
- name: Build
53+
run: npm run build
54+
55+
- name: Run tests
56+
run: npm run test
57+
env:
58+
CI: true
59+
60+
- name: Check for changes
61+
id: check
62+
run: |
63+
CHANGED=$(npx lerna changed --json 2>/dev/null || echo "[]")
64+
if [ "$CHANGED" == "[]" ]; then
65+
echo "changed=false" >> $GITHUB_OUTPUT
66+
echo "No packages have changed since last release"
67+
else
68+
echo "changed=true" >> $GITHUB_OUTPUT
69+
echo "Changed packages:"
70+
echo "$CHANGED" | jq -r '.[].name'
71+
fi
72+
73+
- name: Dry Run - Preview Changes
74+
if: inputs.dry_run == true
75+
run: |
76+
echo "=== DRY RUN MODE ==="
77+
echo ""
78+
echo "Version type: ${{ inputs.version_type }}"
79+
if [ "${{ inputs.version_type }}" == "auto" ]; then
80+
echo " (auto = determined by conventional commits)"
81+
echo " - fix: commits → patch bump"
82+
echo " - feat: commits → minor bump"
83+
echo " - BREAKING CHANGE → major bump"
84+
fi
85+
echo ""
86+
echo "=== Changed packages ==="
87+
npx lerna changed -l || echo "No packages changed"
88+
echo ""
89+
echo "=== Preview version bumps ==="
90+
VERSION_ARG=""
91+
if [ "${{ inputs.version_type }}" != "auto" ]; then
92+
VERSION_ARG="${{ inputs.version_type }}"
93+
fi
94+
npx lerna version $VERSION_ARG --conventional-commits --no-git-tag-version --no-push --yes 2>/dev/null || true
95+
echo ""
96+
echo "=== Files that would change ==="
97+
git diff --name-only
98+
git checkout -- .
99+
100+
- name: Version packages
101+
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
102+
id: version
103+
run: |
104+
# Determine version argument (empty for auto = let conventional commits decide)
105+
VERSION_ARG=""
106+
if [ "${{ inputs.version_type }}" != "auto" ]; then
107+
VERSION_ARG="${{ inputs.version_type }}"
108+
fi
109+
110+
# Version packages with conventional commits
111+
# When VERSION_ARG is empty (auto), lerna uses conventional commits to determine version:
112+
# fix: → patch, feat: → minor, BREAKING CHANGE → major
113+
npx lerna version $VERSION_ARG \
114+
--yes \
115+
--conventional-commits \
116+
--changelog-preset angular \
117+
--message "chore(release): publish"
118+
119+
# Get the new version for release notes
120+
NEW_VERSION=$(node -p "require('./lerna.json').version || 'independent'")
121+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
122+
env:
123+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
125+
- name: Generate Release Notes
126+
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
127+
id: release_notes
128+
run: |
129+
# Get the latest tag
130+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
131+
132+
# Generate changelog from commits
133+
if [ -n "$LATEST_TAG" ]; then
134+
PREV_TAG=$(git describe --tags --abbrev=0 ${LATEST_TAG}^ 2>/dev/null || echo "")
135+
if [ -n "$PREV_TAG" ]; then
136+
COMMITS=$(git log ${PREV_TAG}..${LATEST_TAG} --pretty=format:"- %s (%h)" --no-merges)
137+
else
138+
COMMITS=$(git log ${LATEST_TAG} --pretty=format:"- %s (%h)" --no-merges -20)
139+
fi
140+
else
141+
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
142+
fi
143+
144+
# Create release notes file
145+
cat > release_notes.md << 'NOTES_EOF'
146+
## What's Changed
147+
148+
NOTES_EOF
149+
150+
# Add package versions
151+
echo "### Published Packages" >> release_notes.md
152+
echo "" >> release_notes.md
153+
npx lerna ls -l --json | jq -r '.[] | "- \(.name)@\(.version)"' >> release_notes.md
154+
echo "" >> release_notes.md
155+
156+
# Add commits
157+
echo "### Commits" >> release_notes.md
158+
echo "" >> release_notes.md
159+
if [ -n "$COMMITS" ]; then
160+
echo "$COMMITS" >> release_notes.md
161+
else
162+
echo "- Initial release" >> release_notes.md
163+
fi
164+
echo "" >> release_notes.md
165+
166+
# Add install instructions
167+
echo "### Installation" >> release_notes.md
168+
echo "" >> release_notes.md
169+
echo '```bash' >> release_notes.md
170+
echo 'npm install @hokify/node-ts-cache' >> release_notes.md
171+
echo '```' >> release_notes.md
172+
173+
cat release_notes.md
174+
175+
- name: Publish to npm
176+
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
177+
run: |
178+
npx lerna publish from-git --yes
179+
env:
180+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
181+
182+
- name: Create GitHub Release
183+
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
184+
run: |
185+
# Get the latest tag created by lerna
186+
LATEST_TAG=$(git describe --tags --abbrev=0)
187+
188+
# Create the GitHub release
189+
gh release create "$LATEST_TAG" \
190+
--title "Release $LATEST_TAG" \
191+
--notes-file release_notes.md
192+
env:
193+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194+
195+
- name: Summary
196+
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
197+
run: |
198+
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
199+
echo "" >> $GITHUB_STEP_SUMMARY
200+
echo "Successfully released the following packages:" >> $GITHUB_STEP_SUMMARY
201+
echo "" >> $GITHUB_STEP_SUMMARY
202+
npx lerna ls -l --json | jq -r '.[] | "- **\(.name)** @ \(.version)"' >> $GITHUB_STEP_SUMMARY
203+
echo "" >> $GITHUB_STEP_SUMMARY
204+
LATEST_TAG=$(git describe --tags --abbrev=0)
205+
echo "GitHub Release: https://github.com/${{ github.repository }}/releases/tag/$LATEST_TAG" >> $GITHUB_STEP_SUMMARY
206+
207+
- name: No changes to release
208+
if: steps.check.outputs.changed == 'false'
209+
run: |
210+
echo "## No Changes" >> $GITHUB_STEP_SUMMARY
211+
echo "" >> $GITHUB_STEP_SUMMARY
212+
echo "No packages have changed since the last release. Nothing to publish." >> $GITHUB_STEP_SUMMARY

.github/workflows/test.yml

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,64 @@
1-
name: Run Test
2-
on: [push, pull_request, workflow_dispatch]
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
workflow_dispatch:
39

410
jobs:
5-
build:
11+
test:
12+
name: Test on Node.js ${{ matrix.node-version }}
613
runs-on: ubuntu-latest
714
strategy:
815
matrix:
9-
node-version: [18.19.0]
16+
node-version: ['20', '22', '24']
17+
fail-fast: false
18+
1019
steps:
11-
- name: Git checkout
12-
uses: actions/checkout@v2
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
1322

14-
- name: Use Node.js ${{ matrix.node-version }}
15-
uses: actions/setup-node@v2
23+
- name: Setup Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
1625
with:
1726
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
1828

19-
- name: Cache node modules
20-
uses: actions/cache@v2
21-
env:
22-
cache-name: cache-node-modules
23-
with:
24-
# npm cache files are stored in `~/.npm` on Linux/macOS
25-
path: ~/.npm
26-
key: ${{ runner.os }}-build-nodetscache-${{ hashFiles('**/package-lock.lock') }}
27-
restore-keys: |
28-
${{ runner.os }}-build-nodetscache-
29-
30-
- name: Update npm
31-
run: npm -g install npm@latest
32-
33-
- name: Install Packages
29+
- name: Install dependencies
3430
run: npm ci
3531

3632
- name: Build
3733
run: npm run build
3834

39-
- name: Test
35+
- name: Run tests
4036
run: npm run test
4137
env:
4238
CI: true
39+
40+
lint:
41+
name: Lint & Format
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: '20'
52+
cache: 'npm'
53+
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Build (required for type-aware linting)
58+
run: npm run build
59+
60+
- name: Run ESLint
61+
run: npm run lint
62+
63+
- name: Check Prettier formatting
64+
run: npm run format

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)