Skip to content

Commit 2680935

Browse files
authored
Merge pull request #6 from chaqchase/feat/v1
feat: initial v1.0.0 release with comprehensive middleware system
2 parents c9ae7fa + 2d18d90 commit 2680935

26 files changed

+4223
-3342
lines changed

.github/workflows/ci.yml

Lines changed: 183 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,198 @@ name: CI
22

33
on:
44
push:
5-
branches: ['main']
5+
branches: [main]
66
pull_request:
7-
types: [opened, synchronize]
7+
types: [opened, synchronize, reopened]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
812

913
jobs:
10-
test:
11-
name: Test Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
14+
lint-and-type-check:
15+
name: Lint & Type Check
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
cache: 'pnpm'
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v2
30+
with:
31+
version: 8
32+
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
36+
- name: Type check
37+
run: pnpm type-check
38+
39+
- name: Lint
40+
run: pnpm lint:check
41+
42+
- name: Format check
43+
run: pnpm format:check
44+
45+
build:
46+
name: Build
47+
runs-on: ubuntu-latest
48+
needs: [lint-and-type-check]
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
1253

54+
- name: Setup Node.js
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: 20
58+
cache: 'pnpm'
59+
60+
- name: Setup pnpm
61+
uses: pnpm/action-setup@v2
62+
with:
63+
version: 8
64+
65+
- name: Install dependencies
66+
run: pnpm install --frozen-lockfile
67+
68+
- name: Build
69+
run: pnpm build
70+
71+
- name: Check build output
72+
run: |
73+
if [ ! -f "dist/index.js" ] || [ ! -f "dist/index.cjs" ] || [ ! -f "dist/index.d.ts" ]; then
74+
echo "Build output missing required files"
75+
exit 1
76+
fi
77+
78+
- name: Upload build artifacts
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: build-output
82+
path: dist/
83+
retention-days: 1
84+
85+
test-node-versions:
86+
name: Test Node.js ${{ matrix.node-version }}
87+
runs-on: ubuntu-latest
88+
needs: [lint-and-type-check]
89+
1390
strategy:
1491
matrix:
15-
os: [ubuntu-latest]
16-
node-version: [18.x]
92+
node-version: [18, 20, 21]
93+
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v4
1797

18-
runs-on: ${{ matrix.os }}
98+
- name: Setup Node.js ${{ matrix.node-version }}
99+
uses: actions/setup-node@v4
100+
with:
101+
node-version: ${{ matrix.node-version }}
102+
cache: 'pnpm'
103+
104+
- name: Setup pnpm
105+
uses: pnpm/action-setup@v2
106+
with:
107+
version: 8
108+
109+
- name: Install dependencies
110+
run: pnpm install --frozen-lockfile
19111

112+
- name: Type check
113+
run: pnpm type-check
114+
115+
- name: Build
116+
run: pnpm build
117+
118+
package-validation:
119+
name: Package Validation
120+
runs-on: ubuntu-latest
121+
needs: [build]
122+
20123
steps:
21-
- uses: actions/checkout@v2
22-
- uses: pnpm/[email protected]
124+
- name: Checkout
125+
uses: actions/checkout@v4
126+
127+
- name: Setup Node.js
128+
uses: actions/setup-node@v4
23129
with:
24-
version: 6.34.0
25-
- uses: actions/setup-node@v2
130+
node-version: 20
131+
cache: 'pnpm'
132+
133+
- name: Setup pnpm
134+
uses: pnpm/action-setup@v2
26135
with:
27-
node-version: ${{ matrix.node-version }}
136+
version: 8
137+
138+
- name: Install dependencies
139+
run: pnpm install --frozen-lockfile
140+
141+
- name: Download build artifacts
142+
uses: actions/download-artifact@v4
143+
with:
144+
name: build-output
145+
path: dist/
146+
147+
- name: Pack package
148+
run: pnpm pack
149+
150+
- name: Validate package contents
151+
run: |
152+
tar -tzf *.tgz | grep -E "(dist/|README.md|CHANGELOG.md|package.json)" || {
153+
echo "Package missing required files"
154+
exit 1
155+
}
156+
157+
security-audit:
158+
name: Security Audit
159+
runs-on: ubuntu-latest
160+
161+
steps:
162+
- name: Checkout
163+
uses: actions/checkout@v4
164+
165+
- name: Setup Node.js
166+
uses: actions/setup-node@v4
167+
with:
168+
node-version: 20
28169
cache: 'pnpm'
29-
- name: Install Dependencies
30-
run: pnpm install
170+
171+
- name: Setup pnpm
172+
uses: pnpm/action-setup@v2
173+
with:
174+
version: 8
175+
176+
- name: Install dependencies
177+
run: pnpm install --frozen-lockfile
178+
179+
- name: Audit dependencies
180+
run: pnpm audit --audit-level moderate
181+
182+
all-checks-passed:
183+
name: All Checks Passed
184+
runs-on: ubuntu-latest
185+
needs: [lint-and-type-check, build, test-node-versions, package-validation, security-audit]
186+
if: always()
187+
188+
steps:
189+
- name: Check all jobs
190+
run: |
191+
if [[ "${{ needs.lint-and-type-check.result }}" != "success" ]] || \
192+
[[ "${{ needs.build.result }}" != "success" ]] || \
193+
[[ "${{ needs.test-node-versions.result }}" != "success" ]] || \
194+
[[ "${{ needs.package-validation.result }}" != "success" ]] || \
195+
[[ "${{ needs.security-audit.result }}" != "success" ]]; then
196+
echo "One or more checks failed"
197+
exit 1
198+
fi
199+
echo "All checks passed successfully!"

.github/workflows/release.yml

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,100 @@ name: Release
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [main]
76

8-
concurrency: ${{ github.workflow }}-${{ github.ref }}
7+
concurrency:
8+
group: release-${{ github.ref }}
9+
cancel-in-progress: false
910

1011
jobs:
11-
release:
12-
name: Release
12+
validate-and-release:
13+
name: Validate & Release
1314
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
id-token: write
18+
pull-requests: write
19+
1420
steps:
15-
- name: Checkout Repo
16-
uses: actions/checkout@v2
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
1726

18-
- name: Setup Node.js 20.x
19-
uses: actions/setup-node@v2
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
2029
with:
21-
node-version: 20.x
30+
node-version: 20
31+
cache: 'pnpm'
32+
registry-url: 'https://registry.npmjs.org'
2233

2334
- name: Setup pnpm
24-
run: npm install -g pnpm
35+
uses: pnpm/action-setup@v2
36+
with:
37+
version: 8
38+
39+
- name: Install dependencies
40+
run: pnpm install --frozen-lockfile
41+
42+
- name: Validate code quality
43+
run: pnpm validate
2544

26-
- name: Install Dependencies
27-
run: pnpm i
45+
- name: Build package
46+
run: pnpm build
2847

29-
- name: Create Release PR or Publish Packages
48+
- name: Validate build output
49+
run: |
50+
if [ ! -f "dist/index.js" ] || [ ! -f "dist/index.cjs" ] || [ ! -f "dist/index.d.ts" ]; then
51+
echo "❌ Build output missing required files"
52+
exit 1
53+
fi
54+
echo "✅ Build output validated"
55+
56+
- name: Test package installation
57+
run: |
58+
pnpm pack
59+
mkdir test-install
60+
cd test-install
61+
npm init -y
62+
npm install ../chaqchase-next-middleware-*.tgz
63+
node -e "
64+
try {
65+
const pkg = require('@chaqchase/next-middleware');
66+
console.log('✅ Package imports successfully');
67+
console.log('Available exports:', Object.keys(pkg));
68+
} catch (e) {
69+
console.error('❌ Package import failed:', e.message);
70+
process.exit(1);
71+
}
72+
"
73+
74+
- name: Security audit
75+
run: pnpm audit --audit-level moderate
76+
77+
- name: Create Release Pull Request or Publish
3078
id: changesets
3179
uses: changesets/action@v1
3280
with:
3381
publish: pnpm release
3482
version: pnpm version
35-
commit: 'chore: update package versions'
36-
title: 'chore: update package versions'
83+
commit: 'chore: release package'
84+
title: 'chore: release package'
85+
createGithubReleases: true
3786
env:
3887
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
88+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
89+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
90+
91+
- name: Release Summary
92+
if: steps.changesets.outputs.published == 'true'
93+
run: |
94+
echo "🎉 Package published successfully!"
95+
echo "Published packages: ${{ steps.changesets.outputs.publishedPackages }}"
96+
97+
- name: Notify on Failure
98+
if: failure()
99+
run: |
100+
echo "❌ Release workflow failed"
101+
echo "Please check the logs and fix any issues before retrying"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Version Check
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'package.json'
7+
- 'CHANGELOG.md'
8+
- '.changeset/**'
9+
10+
jobs:
11+
version-consistency:
12+
name: Check Version Consistency
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
24+
- name: Check version in package.json
25+
id: package-version
26+
run: |
27+
VERSION=$(node -p "require('./package.json').version")
28+
echo "package-version=$VERSION" >> $GITHUB_OUTPUT
29+
echo "Package version: $VERSION"
30+
31+
- name: Check if changelog has entry for version
32+
run: |
33+
VERSION="${{ steps.package-version.outputs.package-version }}"
34+
if ! grep -q "## \[$VERSION\]" CHANGELOG.md; then
35+
echo "❌ CHANGELOG.md missing entry for version $VERSION"
36+
echo "Please add a changelog entry for version $VERSION"
37+
exit 1
38+
fi
39+
echo "✅ CHANGELOG.md has entry for version $VERSION"
40+
41+
- name: Validate changeset files
42+
run: |
43+
if [ -d ".changeset" ]; then
44+
CHANGESET_FILES=$(find .changeset -name "*.md" ! -name "README.md" | wc -l)
45+
if [ "$CHANGESET_FILES" -gt 0 ]; then
46+
echo "✅ Found $CHANGESET_FILES changeset file(s)"
47+
else
48+
echo "⚠️ No changeset files found. Make sure to create a changeset for your changes."
49+
fi
50+
fi

0 commit comments

Comments
 (0)