-
-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (73 loc) · 2.37 KB
/
Copy pathrelease.yml
File metadata and controls
86 lines (73 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: "Release type"
required: true
default: "auto"
type: choice
options:
- auto
- patch
- minor
- major
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and generate changelog
id: version
run: |
if [ "${{ inputs.release_type }}" = "auto" ]; then
pnpm release
else
pnpm release -- --release-as ${{ inputs.release_type }}
fi
# Extract the new version from package.json
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
# Extract release notes for this version from CHANGELOG.md
if [ -f "RELEASE_NOTES.md" ]; then
echo "Release notes extracted"
else
echo "No release notes file found, extracting from CHANGELOG..."
# Fallback: extract section between first two ## headers
sed -n "/^## \[${VERSION}\]/,/^## \[/{ /^## \[${VERSION}\]/d; /^## \[/d; p; }" CHANGELOG.md > RELEASE_NOTES.md
fi
- name: Push changes and tag
run: |
git push --follow-tags origin ${{ github.ref_name }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
body_path: RELEASE_NOTES.md
generate_release_notes: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup
run: rm -f RELEASE_NOTES.md