Skip to content

Commit 6d9a6d4

Browse files
committed
ci: run deploy-site after release and improve changelog format
- Trigger deploy-site.yml via workflow_run after Release completes instead of independently on push to master - Generate structured changelogs grouped by category (Features, Bug Fixes, Refactors) with linked commit hashes matching CHANGELOG.md format
1 parent fa70234 commit 6d9a6d4

2 files changed

Lines changed: 60 additions & 2 deletions

File tree

.github/workflows/deploy-site.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Deploy Site
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: [Release]
6+
types: [completed]
57
branches: [master]
68
workflow_dispatch:
79

@@ -17,6 +19,7 @@ concurrency:
1719
jobs:
1820
build:
1921
runs-on: ubuntu-latest
22+
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
2023
steps:
2124
- uses: actions/checkout@v4
2225

.github/workflows/release.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,39 @@ jobs:
7373
exit 0
7474
fi
7575
76+
# Collect commits since last tag for changed packages
77+
REPO_URL="https://github.com/${{ github.repository }}"
78+
FEATURES=""
79+
FIXES=""
80+
REFACTORS=""
81+
OTHER=""
82+
83+
for pkg in $CHANGED_PACKAGES; do
84+
pkg_dir=$(echo "$pkg" | sed 's|@[^/]*/||') # e.g. @tiny-design/react -> react
85+
pkg_path="packages/$pkg_dir"
86+
while IFS= read -r line; do
87+
[ -z "$line" ] && continue
88+
hash=$(echo "$line" | cut -d' ' -f1)
89+
msg=$(echo "$line" | cut -d' ' -f2-)
90+
short_hash=$(echo "$hash" | cut -c1-7)
91+
link="[$short_hash]($REPO_URL/commit/$hash)"
92+
93+
# Strip conventional commit prefix and optional scope for the description
94+
desc=$(echo "$msg" | sed -E 's/^(feat|fix|refactor|chore|docs|style|perf|test|ci|build)(\([^)]*\))?[!]?:\s*//')
95+
96+
case "$msg" in
97+
feat*) FEATURES="$FEATURES
98+
* $desc ($link)" ;;
99+
fix*) FIXES="$FIXES
100+
* $desc ($link)" ;;
101+
refactor*) REFACTORS="$REFACTORS
102+
* $desc ($link)" ;;
103+
*) OTHER="$OTHER
104+
* $desc ($link)" ;;
105+
esac
106+
done <<< "$(git log "$LAST_TAG"..HEAD --pretty=format:'%H %s' -- "$pkg_path/src" | awk '!seen[$0]++')"
107+
done
108+
76109
# Build the changeset file
77110
RANDOM_ID=$(head -c 8 /dev/urandom | od -An -tx1 | tr -d ' \n')
78111
CHANGESET_FILE=".changeset/auto-${RANDOM_ID}.md"
@@ -84,7 +117,29 @@ jobs:
84117
done
85118
echo "---"
86119
echo ""
87-
echo "Auto-detected changes since $LAST_TAG"
120+
if [ -n "$FEATURES" ]; then
121+
echo "### Features"
122+
echo "$FEATURES"
123+
echo ""
124+
fi
125+
if [ -n "$FIXES" ]; then
126+
echo "### Bug Fixes"
127+
echo "$FIXES"
128+
echo ""
129+
fi
130+
if [ -n "$REFACTORS" ]; then
131+
echo "### Refactors"
132+
echo "$REFACTORS"
133+
echo ""
134+
fi
135+
if [ -n "$OTHER" ]; then
136+
echo "$OTHER"
137+
echo ""
138+
fi
139+
# Fallback if no commits found
140+
if [ -z "$FEATURES" ] && [ -z "$FIXES" ] && [ -z "$REFACTORS" ] && [ -z "$OTHER" ]; then
141+
echo "* Patch updates"
142+
fi
88143
} > "$CHANGESET_FILE"
89144

90145
echo "Generated $CHANGESET_FILE for:$CHANGED_PACKAGES"

0 commit comments

Comments
 (0)