Skip to content

Commit 52225d2

Browse files
committed
chore: add changelog
1 parent 1fd69b7 commit 52225d2

File tree

6 files changed

+2011
-30
lines changed

6 files changed

+2011
-30
lines changed

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Generate Changelog & Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
changelog-and-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
persist-credentials: true
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
26+
- name: Enable pnpm (Corepack)
27+
run: |
28+
corepack enable
29+
corepack prepare pnpm@latest --activate
30+
31+
- name: Install deps
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Generate CHANGELOG.md
35+
run: npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0
36+
37+
- name: Configure Git for pushing
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
41+
42+
- name: Commit and push CHANGELOG.md if changed
43+
if: ${{ always() }}
44+
run: |
45+
set -e
46+
if [ -n "$(git status --porcelain CHANGELOG.md)" ]; then
47+
# Determine a branch that contains the tagged commit; fallback to main
48+
BRANCH=$(git branch -r --contains $GITHUB_SHA | sed -n '1p' | sed 's|origin/||')
49+
if [ -z "$BRANCH" ]; then
50+
BRANCH=main
51+
fi
52+
git add CHANGELOG.md
53+
git commit -m "chore(release): update CHANGELOG.md for ${{ github.ref_name }}"
54+
git push origin HEAD:"$BRANCH"
55+
else
56+
echo "No CHANGELOG.md changes to commit"
57+
fi
58+
59+
- name: Read generated changelog into workflow output
60+
id: changelog
61+
run: |
62+
echo "body<<EOF" >> $GITHUB_OUTPUT
63+
cat CHANGELOG.md >> $GITHUB_OUTPUT
64+
echo "EOF" >> $GITHUB_OUTPUT
65+
66+
- name: Create GitHub Release
67+
uses: actions/create-release@v1
68+
with:
69+
tag_name: ${{ github.ref_name }}
70+
release_name: ${{ github.ref_name }}
71+
body: ${{ steps.changelog.outputs.body }}
72+
draft: false
73+
prerelease: false
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)