Skip to content

Commit 672a85f

Browse files
committed
feat: migrate to semantic release for automated versioning
- Replace manual tag-based workflow with semantic release - Add conventional commit support for automatic version bumping - Configure release workflow to run on master branch pushes - Add semantic release dependencies and scripts - Enable automated npm publishing and GitHub releases
1 parent f3646c6 commit 672a85f

File tree

4 files changed

+7362
-934
lines changed

4 files changed

+7362
-934
lines changed

.github/workflows/release.yml

Lines changed: 57 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,67 @@
1-
name: Release
1+
name: Semantic Release
22

33
on:
44
push:
5-
tags:
6-
- 'v*'
5+
branches: [master]
6+
workflow_dispatch:
77

88
jobs:
99
release:
1010
runs-on: ubuntu-latest
11+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
1112
permissions:
1213
contents: write
13-
packages: write
14-
14+
1515
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v4
18-
19-
- name: Setup Node.js
20-
uses: actions/setup-node@v4
21-
with:
22-
node-version: '20.x'
23-
cache: 'npm'
24-
registry-url: 'https://registry.npmjs.org'
25-
26-
- name: Install dependencies
27-
run: npm ci
28-
29-
- name: Build project
30-
run: npm run build
31-
32-
- name: Run tests
33-
run: npm run test:ci
34-
35-
- name: Build package
36-
run: ./package.sh
37-
38-
- name: Determine if beta release
39-
id: check_beta
40-
run: |
41-
VERSION=$(node -p "require('./package.json').version")
42-
if [[ $VERSION == *"beta"* ]]; then
43-
echo "is_beta=true" >> $GITHUB_OUTPUT
44-
echo "npm_tag=beta" >> $GITHUB_OUTPUT
45-
else
46-
echo "is_beta=false" >> $GITHUB_OUTPUT
47-
echo "npm_tag=latest" >> $GITHUB_OUTPUT
48-
fi
49-
echo "version=$VERSION" >> $GITHUB_OUTPUT
50-
51-
- name: Publish to NPM
52-
run: |
53-
cd package
54-
npm publish --tag ${{ steps.check_beta.outputs.npm_tag }}
55-
env:
56-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57-
58-
- name: Create GitHub Release
59-
uses: actions/create-release@v1
60-
env:
61-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
with:
63-
tag_name: ${{ github.ref }}
64-
release_name: Release ${{ github.ref }}
65-
draft: false
66-
prerelease: ${{ steps.check_beta.outputs.is_beta }}
67-
body: |
68-
## What's Changed
69-
70-
${{ steps.check_beta.outputs.is_beta == 'true' && '🧪 **This is a beta release** - Please test thoroughly before using in production.' || '' }}
71-
72-
### ✨ Features in this release
73-
74-
- 🔧 **Prisma 6.12+ Support** - Full compatibility with latest Prisma features
75-
- 🛡️ **Uint8Array Support** - Proper handling of Bytes fields (breaking change from Buffer)
76-
- 🚀 **Node.js 18+** - Modern Node.js requirements (18.18+, 20.9+, 22.11+)
77-
- 📝 **TypeScript 5.8** - Latest TypeScript features and optimizations
78-
- 🧪 **Enhanced Testing** - Comprehensive test suite with 95%+ coverage
79-
- ⚡ **Performance** - Faster generation with optimized AST manipulation
80-
81-
For detailed changes, see the [changelog](https://github.com/omar-dulaimi/prisma-class-validator-generator/compare/v5.0.0...${{ github.ref }}).
82-
83-
### Installation
84-
```bash
85-
npm install prisma-class-validator-generator@${{ steps.check_beta.outputs.is_beta == 'true' && 'beta' || 'latest' }}
86-
```
16+
- name: Checkout code
17+
uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20.x'
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Build and test
32+
run: |
33+
npm run build
34+
npm run test:type-check
35+
npm run test:ci
36+
37+
- name: Build package
38+
run: ./package.sh
39+
40+
- name: Semantic Release (with npm lifecycle)
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
run: npm run release
45+
46+
- name: Commit and push workflow mutations (if any)
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
shell: bash
50+
run: |
51+
set -euo pipefail
52+
# Stage docs and common release-mutation files to avoid failing on dirty tree
53+
git config user.name "github-actions[bot]"
54+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
55+
git add -A \
56+
package.json \
57+
package-lock.json \
58+
package/package.json \
59+
CHANGELOG.md || true
60+
# If nothing is staged, skip committing to avoid exit 1 from git commit
61+
if git diff --cached --quiet; then
62+
echo "No changes to commit"
63+
exit 0
64+
fi
65+
LAST_TAG=$(git describe --tags --abbrev=0 || echo "latest")
66+
git commit -m "chore(ci): commit workflow mutations (version bumps, lockfile) for ${LAST_TAG} [skip ci]"
67+
git push origin HEAD:${GITHUB_REF_NAME}

.releaserc.json

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"branches": [
3+
"master",
4+
{
5+
"name": "upgrade/prisma-and-dependencies",
6+
"prerelease": "beta"
7+
}
8+
],
9+
"plugins": [
10+
[
11+
"@semantic-release/commit-analyzer",
12+
{
13+
"preset": "conventionalcommits",
14+
"releaseRules": [
15+
{ "type": "feat", "release": "minor" },
16+
{ "type": "fix", "release": "patch" },
17+
{ "type": "perf", "release": "patch" },
18+
{ "type": "revert", "release": "patch" },
19+
{ "type": "docs", "release": false },
20+
{ "type": "style", "release": false },
21+
{ "type": "chore", "release": false },
22+
{ "type": "refactor", "release": "patch" },
23+
{ "type": "test", "release": false },
24+
{ "type": "build", "release": false },
25+
{ "type": "ci", "release": false },
26+
{ "scope": "breaking", "release": "major" }
27+
]
28+
}
29+
],
30+
[
31+
"@semantic-release/release-notes-generator",
32+
{
33+
"preset": "conventionalcommits",
34+
"presetConfig": {
35+
"types": [
36+
{ "type": "feat", "section": "🚀 Features" },
37+
{ "type": "fix", "section": "🐛 Bug Fixes" },
38+
{ "type": "perf", "section": "⚡ Performance Improvements" },
39+
{ "type": "revert", "section": "⏪ Reverts" },
40+
{ "type": "refactor", "section": "♻️ Code Refactoring" },
41+
{ "type": "docs", "section": "📚 Documentation", "hidden": false },
42+
{ "type": "style", "section": "💄 Styles", "hidden": true },
43+
{ "type": "chore", "section": "🔧 Miscellaneous Chores", "hidden": true },
44+
{ "type": "test", "section": "✅ Tests", "hidden": true },
45+
{ "type": "build", "section": "🏗️ Build System", "hidden": true },
46+
{ "type": "ci", "section": "👷 CI/CD", "hidden": true }
47+
]
48+
}
49+
}
50+
],
51+
[
52+
"@semantic-release/changelog",
53+
{
54+
"changelogFile": "CHANGELOG.md"
55+
}
56+
],
57+
[
58+
"@semantic-release/npm",
59+
{
60+
"pkgRoot": ".",
61+
"npmPublish": false
62+
}
63+
],
64+
[
65+
"@semantic-release/npm",
66+
{
67+
"pkgRoot": "package"
68+
}
69+
],
70+
[
71+
"@semantic-release/git",
72+
{
73+
"assets": [
74+
"package.json",
75+
"package-lock.json",
76+
"package/package.json",
77+
"CHANGELOG.md"
78+
],
79+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
80+
}
81+
],
82+
[
83+
"@semantic-release/github",
84+
{
85+
"assets": [
86+
{
87+
"path": "package/*.tgz",
88+
"label": "Package tarball"
89+
}
90+
]
91+
}
92+
]
93+
]
94+
}

0 commit comments

Comments
 (0)