Skip to content

Commit ec0b267

Browse files
authored
feat: replace semantic-release with github-actions[bot] release workflow (#16)
* feat: replace semantic-release with github-actions[bot] release workflow - Remove semantic-release and all related dependencies - Implement github-actions[bot] based release workflow - Add manual release trigger with patch/minor/major options - Use github-actions[bot] identity for version commits and tags - Maintain dual publishing (npm + GitHub Packages) - Add automatic GitHub release creation with changelog - Simplify release process and remove NPM token authentication issues - Support both automatic (on version change) and manual releases - Inspired by .examples/sample-repo proven pattern * docs: update all semantic-release references to github-actions[bot] - Update README.md release section with new workflow instructions - Update CONTRIBUTING.md with automatic and manual release processes - Regenerate package-lock.json without semantic-release dependencies - Remove all references to semantic-release configuration - Document new github-actions[bot] based release workflow * fix: resolve Biome installation and update PR title check - Reinstall @biomejs/biome to fix missing cli-linux-x64 module - Update PR title check workflow with better configuration - Add subject pattern validation and clearer error messages - Maintain conventional commit enforcement for changelog generation - Fix linting issues that were blocking CI * fix: regenerate clean package-lock.json after dependency cleanup - Remove corrupted node_modules and package-lock.json - Clean npm install to fix Rollup/Vitest dependency issues - All tests now passing (55/55) - Biome linting working correctly - Complete dependency tree cleanup after semantic-release removal
1 parent de0c32e commit ec0b267

File tree

7 files changed

+1579
-8151
lines changed

7 files changed

+1579
-8151
lines changed

.github/workflows/pr-title.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
env:
1313
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1414
with:
15+
# Conventional commit types for better changelog generation
1516
types: |
1617
build
1718
chore
@@ -24,3 +25,11 @@ jobs:
2425
revert
2526
style
2627
test
28+
# Allow any scope
29+
requireScope: false
30+
# Custom subject pattern - allow any descriptive text
31+
subjectPattern: ^.{1,100}$
32+
subjectPatternError: |
33+
The subject "{subject}" found in the pull request title "{title}"
34+
didn't match the configured pattern. Please ensure that the subject
35+
doesn't start with an uppercase character and is descriptive.

.github/workflows/release.yml

Lines changed: 175 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ name: Release
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- next
8-
- beta
9-
- alpha
10-
- dev
5+
branches: [main]
6+
workflow_dispatch:
7+
inputs:
8+
release-type:
9+
description: "Type of release"
10+
required: true
11+
default: "auto"
12+
type: choice
13+
options:
14+
- auto
15+
- patch
16+
- minor
17+
- major
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
1121

1222
permissions:
1323
contents: write
@@ -18,77 +28,180 @@ permissions:
1828
actions: write
1929

2030
jobs:
21-
# Run tests before release
22-
test:
31+
# Pre-release validation
32+
validate:
33+
name: Pre-release Validation
2334
runs-on: ubuntu-latest
35+
timeout-minutes: 20
36+
outputs:
37+
should-release: ${{ steps.check-changes.outputs.should-release }}
38+
2439
steps:
25-
- uses: actions/checkout@v4
26-
- uses: actions/setup-node@v4
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
token: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v4
2748
with:
2849
node-version: 20
2950
cache: "npm"
30-
- run: npm ci
31-
- run: npm run typecheck
32-
- run: npm run lint
33-
- run: npm test
34-
- run: npm run build
3551

36-
# Release job that depends on tests passing
52+
- name: Install dependencies
53+
run: npm ci
54+
55+
- name: Check for version changes
56+
id: check-changes
57+
run: |
58+
# Check if this is a manual release
59+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
60+
echo "should-release=true" >> $GITHUB_OUTPUT
61+
echo "✅ Manual release triggered"
62+
exit 0
63+
fi
64+
65+
# Check if package.json version changed in this push
66+
if git diff HEAD~1 HEAD --name-only | grep -q "package.json"; then
67+
if git diff HEAD~1 HEAD package.json | grep -q '"version"'; then
68+
echo "should-release=true" >> $GITHUB_OUTPUT
69+
echo "✅ Version change detected in package.json"
70+
else
71+
echo "should-release=false" >> $GITHUB_OUTPUT
72+
echo "ℹ️ No version change in package.json"
73+
fi
74+
else
75+
echo "should-release=false" >> $GITHUB_OUTPUT
76+
echo "ℹ️ No package.json changes"
77+
fi
78+
79+
- name: Build packages
80+
run: npm run build
81+
82+
- name: Run tests
83+
run: npm test
84+
timeout-minutes: 10
85+
86+
- name: Verify package can be packed
87+
run: npm pack --dry-run
88+
89+
# Release job - only runs if validation passes and changes detected
3790
release:
38-
needs: test
91+
name: Release
92+
needs: validate
3993
runs-on: ubuntu-latest
94+
if: needs.validate.outputs.should-release == 'true'
4095
outputs:
41-
released: ${{ steps.release.outputs.released }}
42-
version: ${{ steps.release.outputs.version }}
43-
major: ${{ steps.release.outputs.major }}
44-
minor: ${{ steps.release.outputs.minor }}
45-
patch: ${{ steps.release.outputs.patch }}
96+
published: ${{ steps.publish.outputs.published }}
97+
version: ${{ steps.get-version.outputs.version }}
98+
4699
steps:
47-
- uses: actions/checkout@v4
100+
- name: Checkout
101+
uses: actions/checkout@v4
48102
with:
49103
fetch-depth: 0
50104
token: ${{ secrets.GITHUB_TOKEN }}
51105

52-
- uses: actions/setup-node@v4
106+
- name: Setup Node.js
107+
uses: actions/setup-node@v4
53108
with:
54109
node-version: 20
55110
cache: "npm"
56111
registry-url: "https://registry.npmjs.org"
57112

58-
- run: npm ci
59-
- run: npm run build
113+
- name: Install dependencies
114+
run: npm ci
60115

61-
# Verify package can be packed
62-
- run: npm pack --dry-run
116+
- name: Build package
117+
run: npm run build
118+
119+
- name: Handle manual version bump
120+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release-type != 'auto'
121+
run: |
122+
# Bump version based on input
123+
npm version ${{ github.event.inputs.release-type }} --no-git-tag-version
124+
125+
# Commit version change
126+
git config user.name "github-actions[bot]"
127+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
128+
git add package.json package-lock.json
129+
git commit -m "chore: bump version to $(node -p "require('./package.json').version")"
130+
git push origin main
131+
132+
- name: Get current version
133+
id: get-version
134+
run: |
135+
version=$(node -p "require('./package.json').version")
136+
echo "version=$version" >> $GITHUB_OUTPUT
137+
echo "📦 Current version: $version"
63138
64-
- name: Release
65-
id: release
66-
run: npx semantic-release
139+
- name: Create git tag
140+
run: |
141+
version="${{ steps.get-version.outputs.version }}"
142+
tag_name="v$version"
143+
144+
# Check if tag already exists
145+
if git tag -l | grep -q "^${tag_name}$"; then
146+
echo "ℹ️ Tag $tag_name already exists, skipping tag creation"
147+
else
148+
git tag "$tag_name"
149+
git push origin "$tag_name"
150+
echo "✅ Created and pushed tag $tag_name"
151+
fi
152+
153+
- name: Publish to npm
154+
id: publish
155+
run: |
156+
# Check if this version is already published
157+
if npm view docling-sdk@${{ steps.get-version.outputs.version }} version >/dev/null 2>&1; then
158+
echo "ℹ️ Version ${{ steps.get-version.outputs.version }} already published to npm"
159+
echo "published=false" >> $GITHUB_OUTPUT
160+
else
161+
npm publish
162+
echo "✅ Published docling-sdk@${{ steps.get-version.outputs.version }} to npm"
163+
echo "published=true" >> $GITHUB_OUTPUT
164+
fi
67165
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
70-
GIT_AUTHOR_NAME: semantic-release-bot
71-
GIT_AUTHOR_EMAIL: [email protected]
72-
GIT_COMMITTER_NAME: semantic-release-bot
73-
GIT_COMMITTER_EMAIL: [email protected]
166+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
74167

75-
# Optional: Notify on successful release
76-
notify:
77-
needs: release
78-
runs-on: ubuntu-latest
79-
if: needs.release.outputs.released == 'true'
80-
steps:
81-
- name: Notify Release
168+
- name: Create GitHub Release
169+
if: steps.publish.outputs.published == 'true'
82170
run: |
83-
echo "🎉 Successfully released version ${{ needs.release.outputs.version }}"
84-
echo "📦 Package: https://www.npmjs.com/package/docling-sdk"
85-
echo "🏷️ GitHub Release: https://github.com/btwld/docling-sdk/releases/tag/v${{ needs.release.outputs.version }}"
171+
version="${{ steps.get-version.outputs.version }}"
172+
tag_name="v$version"
173+
174+
# Generate release notes from recent commits
175+
release_notes=$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "HEAD~10")..HEAD | head -20)
176+
177+
# Create GitHub release
178+
gh release create "$tag_name" \
179+
--title "Release $version" \
180+
--notes "## Changes in $version
181+
182+
$release_notes
183+
184+
## Installation
185+
186+
\`\`\`bash
187+
npm install docling-sdk@$version
188+
\`\`\`
189+
190+
## Links
191+
- 📦 [npm package](https://www.npmjs.com/package/docling-sdk)
192+
- 📚 [Documentation](https://github.com/btwld/docling-sdk#readme)" \
193+
--latest
194+
195+
echo "✅ Created GitHub release for $tag_name"
196+
env:
197+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86198

87199
# Publish to GitHub Package Registry
88200
github-packages:
201+
name: GitHub Packages
89202
needs: release
90203
runs-on: ubuntu-latest
91-
if: needs.release.outputs.released == 'true'
204+
if: needs.release.outputs.published == 'true'
92205
steps:
93206
- uses: actions/checkout@v4
94207
- uses: actions/setup-node@v4
@@ -116,3 +229,17 @@ jobs:
116229
# Restore original package.json
117230
- name: Restore package.json
118231
run: mv package.json.backup package.json
232+
233+
# Notify on successful release
234+
notify:
235+
name: Notify Success
236+
needs: [release, github-packages]
237+
runs-on: ubuntu-latest
238+
if: needs.release.outputs.published == 'true'
239+
steps:
240+
- name: Notify Release
241+
run: |
242+
echo "🎉 Successfully released docling-sdk@${{ needs.release.outputs.version }}"
243+
echo "📦 npm: https://www.npmjs.com/package/docling-sdk"
244+
echo "📦 GitHub Packages: https://github.com/btwld/docling-sdk/packages"
245+
echo "🏷️ GitHub Release: https://github.com/btwld/docling-sdk/releases/tag/v${{ needs.release.outputs.version }}"

.releaserc.json

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

0 commit comments

Comments
 (0)