forked from cellajs/cella
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (44 loc) · 1.64 KB
/
Copy pathrelease.yml
File metadata and controls
53 lines (44 loc) · 1.64 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
name: Release
permissions:
contents: write
on:
push:
tags:
- "v*" # Runs only when pushing version tags like v1.0.0, v2.3.4
jobs:
release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
fetch-depth: 0 # so changelog sees all commit history
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v5
with:
cache: "pnpm"
- name: Install changelog deps
run: pnpm add -Dw conventional-changelog-cli conventional-changelog-conventionalcommits
- name: Generate release notes
run: |
# Check latest and previous tags
LATEST_TAG=$(if [ "$(git tag | wc -l)" -ge 1 ]; then git describe --tags --abbrev=0; fi)
PREV_TAG=$(if [ "$(git tag | wc -l)" -ge 2 ]; then git tag --sort=creatordate | tail -2 | head -1; fi)
echo "Latest tag: $LATEST_TAG"
echo "Previous tag: $PREV_TAG"
if [ -z "$PREV_TAG" ]; then
echo "First release — include all commits"
npx conventional-changelog -p conventionalcommits -r 0 -o RELEASE_NOTES.md
else
echo "Generating changelog since previous tag $PREV_TAG"
# Use -r 2 and output commits since PREV_TAG
npx conventional-changelog -p conventionalcommits -r 2 -o RELEASE_NOTES.md
fi
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}