Skip to content

Commit bcac1df

Browse files
committed
feat: improve release workflow with proper changelog generation
1 parent ba563a9 commit bcac1df

File tree

1 file changed

+1
-117
lines changed

1 file changed

+1
-117
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1 @@
1-
name: Release Workflow
2-
3-
on:
4-
push:
5-
branches: [main]
6-
paths:
7-
- 'package.json'
8-
workflow_dispatch:
9-
inputs:
10-
version_type:
11-
description: 'Version bump type'
12-
required: true
13-
type: choice
14-
options:
15-
- patch
16-
- minor
17-
- major
18-
default: patch
19-
20-
jobs:
21-
release:
22-
runs-on: ubuntu-latest
23-
# Skip if commit is from github-actions bot or contains [skip ci]
24-
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'github-actions[bot]'"
25-
26-
permissions:
27-
contents: write
28-
29-
steps:
30-
- name: Checkout repository
31-
uses: actions/checkout@v4
32-
with:
33-
fetch-depth: 0
34-
token: ${{ secrets.GA_TOKEN }}
35-
36-
- name: Setup Node.js
37-
uses: actions/setup-node@v4
38-
with:
39-
node-version: '18'
40-
41-
- name: Setup pnpm
42-
uses: pnpm/action-setup@v2
43-
with:
44-
version: latest
45-
46-
- name: Install dependencies
47-
run: pnpm install
48-
49-
- name: Get current version
50-
id: current-version
51-
run: |
52-
VERSION=$(node -p "require('./package.json').version")
53-
echo "version=$VERSION" >> $GITHUB_OUTPUT
54-
echo "Current version: $VERSION"
55-
56-
- name: Check if tag exists
57-
id: check-tag
58-
run: |
59-
VERSION="${{ steps.current-version.outputs.version }}"
60-
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
61-
echo "exists=true" >> $GITHUB_OUTPUT
62-
echo "Tag v$VERSION already exists"
63-
else
64-
echo "exists=false" >> $GITHUB_OUTPUT
65-
echo "Tag v$VERSION does not exist"
66-
fi
67-
68-
- name: Generate changelog
69-
if: steps.check-tag.outputs.exists == 'false'
70-
run: |
71-
npm run changelog
72-
73-
- name: Create and push tag
74-
if: steps.check-tag.outputs.exists == 'false'
75-
run: |
76-
VERSION="${{ steps.current-version.outputs.version }}"
77-
78-
git config --global user.name 'github-actions[bot]'
79-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
80-
81-
# Add changelog if it was updated
82-
git add CHANGELOG.md
83-
84-
# Check if there are changes to commit
85-
if ! git diff --staged --quiet; then
86-
git commit -m "docs: auto-update changelog for v$VERSION [skip ci]"
87-
git push origin main
88-
fi
89-
90-
# Create annotated tag
91-
git tag -a "v$VERSION" -m "Release v$VERSION"
92-
git push origin "v$VERSION"
93-
94-
echo "✅ Created and pushed tag v$VERSION"
95-
96-
- name: Create GitHub Release
97-
if: steps.check-tag.outputs.exists == 'false'
98-
uses: actions/create-release@v1
99-
env:
100-
GITHUB_TOKEN: ${{ secrets.GA_TOKEN }}
101-
with:
102-
tag_name: v${{ steps.current-version.outputs.version }}
103-
release_name: Release v${{ steps.current-version.outputs.version }}
104-
body: |
105-
🚀 **Release v${{ steps.current-version.outputs.version }}**
106-
107-
## What's Changed
108-
Check the [CHANGELOG.md](https://github.com/chess-labs/core/blob/main/CHANGELOG.md) for detailed changes.
109-
110-
**Full Changelog**: https://github.com/chess-labs/core/compare/v${{ steps.current-version.outputs.version }}...HEAD
111-
draft: false
112-
prerelease: false
113-
114-
- name: Skip message
115-
if: steps.check-tag.outputs.exists == 'true'
116-
run: |
117-
echo "⏭️ Tag v${{ steps.current-version.outputs.version }} already exists, skipping release"
1+

0 commit comments

Comments
 (0)