Skip to content

Commit d361a0b

Browse files
committed
update ci/cd workflow
1 parent e49eecb commit d361a0b

File tree

2 files changed

+40
-22
lines changed

2 files changed

+40
-22
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ jobs:
6969
- name: 📦 Install Dependencies
7070
run: bun install --frozen-lockfile
7171

72+
- name: 🔨 Build Package
73+
run: |
74+
echo "Building package for production..."
75+
bun run build
76+
echo "✅ Build completed successfully"
77+
7278
- name: 🧪 Run Full Test Suite
7379
run: |
7480
echo "Running comprehensive test suite before publish..."
7581
bun test:unit
7682
bun test:e2e
7783
echo "✅ All tests passed"
7884
79-
- name: 🔨 Build Package
80-
run: |
81-
echo "Building package for production..."
82-
bun run build
83-
echo "✅ Build completed successfully"
84-
8585
- name: 📋 Validate Build Output
8686
run: |
8787
echo "Validating build artifacts..."
@@ -167,12 +167,6 @@ jobs:
167167
with:
168168
bun-version: latest
169169

170-
- name: 🔧 Setup Node.js for npm
171-
uses: actions/setup-node@v4
172-
with:
173-
node-version: '18'
174-
registry-url: 'https://registry.npmjs.org'
175-
176170
- name: 📦 Install Dependencies
177171
run: bun install --frozen-lockfile
178172

@@ -181,27 +175,41 @@ jobs:
181175

182176
- name: 📝 Update Package Version
183177
run: |
184-
npm version --no-git-tag-version ${{ needs.pre-checks.outputs.version }}
185-
echo "✅ Package version updated to ${{ needs.pre-checks.outputs.version }}"
178+
# Update package.json version using Node
179+
node -e "
180+
const fs = require('fs');
181+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
182+
pkg.version = '${{ needs.pre-checks.outputs.version }}';
183+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
184+
console.log('✅ Package version updated to ${{ needs.pre-checks.outputs.version }}');
185+
"
186186
187187
- name: 🔍 Pre-publish Dry Run
188188
run: |
189-
echo "Running npm publish dry run..."
190-
npm publish --dry-run --tag ${{ needs.pre-checks.outputs.tag }}
189+
echo "Running publish dry run..."
190+
# Create .npmrc for authentication
191+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
192+
# Use bun to create tarball
193+
bun pack
191194
echo "✅ Dry run completed successfully"
195+
env:
196+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
192197

193198
- name: 📤 Publish to npm
194199
run: |
195200
echo "Publishing to npm registry..."
196-
npm publish --tag ${{ needs.pre-checks.outputs.tag }} --access public
201+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
202+
# Use npx for publishing since bun publish is experimental
203+
npx npm@latest publish --tag ${{ needs.pre-checks.outputs.tag }} --access public
197204
echo "✅ Successfully published to npm"
198205
env:
199206
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
200207

201208
- name: 🏷️ Tag Latest Version
202209
if: needs.pre-checks.outputs.tag == 'latest'
203210
run: |
204-
npm dist-tag add elysia-http-exception@${{ needs.pre-checks.outputs.version }} latest
211+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
212+
npx npm@latest dist-tag add elysia-http-exception@${{ needs.pre-checks.outputs.version }} latest
205213
echo "✅ Tagged as latest on npm"
206214
env:
207215
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ jobs:
4444
- name: 📦 Install Dependencies
4545
run: bun install --frozen-lockfile
4646

47+
- name: 📦 Install Example Dependencies
48+
working-directory: ./example
49+
run: bun install --frozen-lockfile
50+
4751
- name: 🎨 Check Code Formatting
4852
run: bun run format --check
4953

50-
- name: 🔧 TypeScript Type Check
54+
- name: 🔨 Build Package
5155
run: bun run build
5256

5357
# Job 2: Unit Tests
@@ -74,6 +78,9 @@ jobs:
7478
- name: 📦 Install Dependencies
7579
run: bun install --frozen-lockfile
7680

81+
- name: 🔨 Build Package
82+
run: bun run build
83+
7784
- name: 🧪 Run Unit Tests
7885
run: bun test:unit
7986

@@ -108,6 +115,9 @@ jobs:
108115
- name: 📦 Install Dependencies
109116
run: bun install --frozen-lockfile
110117

118+
- name: 🔨 Build Package
119+
run: bun run build
120+
111121
- name: 🎯 Run E2E Tests
112122
run: bun test:e2e
113123

@@ -190,10 +200,10 @@ jobs:
190200
- name: 📦 Test Package Installation
191201
run: |
192202
echo "Testing package installation..."
193-
npm pack
203+
bun pack
194204
mkdir test-install && cd test-install
195-
npm init -y
196-
npm install ../elysia-http-exception-*.tgz
205+
bun init -y
206+
bun add ../elysia-http-exception-*.tgz
197207
echo "✅ Package installation test passed"
198208
199209
# Job 6: Security Audit

0 commit comments

Comments
 (0)