Skip to content

Commit f46ef13

Browse files
oladayo21claude
andcommitted
Enhance CI/CD workflows with professional release management
- Update CI workflow to include npm publishing on release - Add manual release workflow with version management - Implement automatic changelog generation - Add npm provenance for security - Support patch/minor/major/prerelease versioning - Improve dependency caching and lockfile handling - Based on best practices from lambda-adapter-kit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d5b41f6 commit f46ef13

File tree

2 files changed

+176
-62
lines changed

2 files changed

+176
-62
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,92 @@
1-
name: CI
1+
name: CI/CD Pipeline
22

33
on:
44
push:
5-
branches: [main, develop]
5+
branches: [main]
66
pull_request:
77
branches: [main]
8+
release:
9+
types: [published]
10+
11+
env:
12+
NODE_VERSION: '22'
813

914
jobs:
1015
test:
11-
name: Test
16+
name: Test & Lint
1217
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
node-version: [20, 22]
16-
1718
steps:
1819
- name: Checkout code
1920
uses: actions/checkout@v4
20-
21-
- name: Install pnpm
21+
22+
- name: Setup pnpm
2223
uses: pnpm/action-setup@v4
2324
with:
24-
version: 9
25-
26-
- name: Setup Node.js ${{ matrix.node-version }}
25+
version: latest
26+
27+
- name: Setup Node.js
2728
uses: actions/setup-node@v4
2829
with:
29-
node-version: ${{ matrix.node-version }}
30+
node-version: ${{ env.NODE_VERSION }}
3031
cache: 'pnpm'
31-
32+
3233
- name: Install dependencies
3334
run: pnpm install --frozen-lockfile
34-
35-
- name: Run type check
35+
36+
- name: Type check
3637
run: pnpm typecheck
37-
38-
- name: Run linter
38+
39+
- name: Lint code
3940
run: pnpm lint
40-
41-
- name: Run tests
42-
run: pnpm test:run
43-
44-
- name: Build package
41+
42+
- name: Run tests with coverage
43+
run: pnpm test:coverage
44+
45+
- name: Test build
4546
run: pnpm build
46-
47-
- name: Upload coverage to Codecov
48-
if: matrix.node-version == 20
49-
uses: codecov/codecov-action@v4
47+
48+
publish:
49+
name: Publish to npm
50+
runs-on: ubuntu-latest
51+
needs: [test]
52+
if: github.event_name == 'release' && github.event.action == 'published'
53+
permissions:
54+
contents: read
55+
id-token: write # for npm provenance
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
60+
- name: Setup pnpm
61+
uses: pnpm/action-setup@v4
5062
with:
51-
file: ./coverage/coverage-final.json
52-
flags: unittests
53-
name: codecov-umbrella
54-
fail_ci_if_error: false
63+
version: latest
64+
65+
- name: Setup Node.js
66+
uses: actions/setup-node@v4
67+
with:
68+
node-version: ${{ env.NODE_VERSION }}
69+
cache: 'pnpm'
70+
registry-url: 'https://registry.npmjs.org'
71+
72+
- name: Install dependencies
73+
run: pnpm install --frozen-lockfile
74+
75+
- name: Build package
76+
run: pnpm build
77+
78+
- name: Update package version
79+
run: |
80+
# Extract version from git tag (remove 'v' prefix if present)
81+
VERSION="${{ github.event.release.tag_name }}"
82+
VERSION="${VERSION#v}"
83+
84+
# Update package.json version
85+
pnpm version "$VERSION" --no-git-tag-version
86+
87+
echo "Updated package.json to version $VERSION"
88+
89+
- name: Publish to npm
90+
run: pnpm publish --access public --provenance
91+
env:
92+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 107 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,130 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Release type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- prerelease
16+
17+
env:
18+
NODE_VERSION: '22'
719

820
jobs:
921
release:
10-
name: Release
22+
name: Create Release
1123
runs-on: ubuntu-latest
1224
permissions:
13-
contents: read
14-
id-token: write # For npm provenance
15-
25+
contents: write
26+
issues: write
27+
pull-requests: write
1628
steps:
1729
- name: Checkout code
1830
uses: actions/checkout@v4
19-
20-
- name: Install pnpm
31+
with:
32+
fetch-depth: 0
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Setup pnpm
2136
uses: pnpm/action-setup@v4
2237
with:
23-
version: 9
24-
38+
version: latest
39+
2540
- name: Setup Node.js
2641
uses: actions/setup-node@v4
2742
with:
28-
node-version: 20
43+
node-version: ${{ env.NODE_VERSION }}
2944
cache: 'pnpm'
30-
registry-url: 'https://registry.npmjs.org'
31-
45+
3246
- name: Install dependencies
3347
run: pnpm install --frozen-lockfile
34-
48+
3549
- name: Run tests
36-
run: pnpm test:run
37-
38-
- name: Build package
39-
run: pnpm build
40-
41-
- name: Publish to npm
42-
run: pnpm publish --access public --provenance
43-
env:
44-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45-
50+
run: |
51+
pnpm typecheck
52+
pnpm lint
53+
pnpm test:run
54+
pnpm build
55+
56+
- name: Configure git
57+
run: |
58+
git config --local user.email "[email protected]"
59+
git config --local user.name "GitHub Action"
60+
61+
- name: Bump version and create tag
62+
id: version
63+
run: |
64+
# Get current version
65+
CURRENT_VERSION=$(node -p "require('./package.json').version")
66+
echo "Current version: $CURRENT_VERSION"
67+
68+
# Bump version
69+
NEW_VERSION=$(pnpm version ${{ github.event.inputs.release_type }} --no-git-tag-version | tail -1)
70+
NEW_VERSION="${NEW_VERSION#v}" # Remove 'v' prefix if present
71+
72+
echo "New version: $NEW_VERSION"
73+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
74+
echo "tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
75+
76+
- name: Generate changelog
77+
id: changelog
78+
run: |
79+
# Get commits since last tag
80+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
81+
82+
if [ -z "$LAST_TAG" ]; then
83+
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges)
84+
else
85+
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges $LAST_TAG..HEAD)
86+
fi
87+
88+
if [ -z "$COMMITS" ]; then
89+
COMMITS="- Initial release"
90+
fi
91+
92+
# Create changelog
93+
CHANGELOG="## What's Changed
94+
$COMMITS
95+
96+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/$LAST_TAG...v${{ steps.version.outputs.version }}"
97+
98+
# Save to file and output
99+
echo "$CHANGELOG" > changelog.md
100+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
101+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
102+
echo "EOF" >> $GITHUB_OUTPUT
103+
104+
- name: Commit version bump
105+
run: |
106+
git add package.json
107+
git commit -m "chore: bump version to v${{ steps.version.outputs.version }}"
108+
git tag "v${{ steps.version.outputs.version }}"
109+
110+
- name: Push changes
111+
run: |
112+
git push origin main
113+
git push origin "v${{ steps.version.outputs.version }}"
114+
46115
- name: Create GitHub Release
47-
uses: actions/create-release@v1
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
uses: softprops/action-gh-release@v1
50117
with:
51-
tag_name: ${{ github.ref }}
52-
release_name: Release ${{ github.ref }}
118+
tag_name: "v${{ steps.version.outputs.version }}"
119+
name: "Release v${{ steps.version.outputs.version }}"
120+
body: ${{ steps.changelog.outputs.changelog }}
53121
draft: false
54-
prerelease: false
122+
prerelease: ${{ contains(github.event.inputs.release_type, 'prerelease') }}
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
126+
- name: Setup npm registry
127+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
128+
129+
- name: Publish to npm
130+
run: pnpm publish --access public --no-git-checks

0 commit comments

Comments
 (0)