-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (40 loc) · 1.49 KB
/
Copy pathcreate-release.yml
File metadata and controls
47 lines (40 loc) · 1.49 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
name: Create Release
# Push a v* tag (e.g. v0.1.0) to cut a release. The tag name is the version.
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
# Full history + tags so conventional-changelog can diff this tag
# against the previous one.
fetch-depth: 0
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
- name: Create the GitHub release
env:
TAG: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Build the changelog for just this release (latest tag .. previous tag),
# grouped into Features / Bug Fixes by conventional-commit type. Strip
# the auto-generated version header — the release title already shows the
# version. Fall back to GitHub's generated notes if it comes back empty.
NOTES="$(bunx conventional-changelog-cli -p conventionalcommits -r 1 \
| sed -E '/^#+ \[?v?[0-9]+\.[0-9]+\.[0-9]+/d')"
if [ -n "$(printf '%s' "$NOTES" | tr -d '[:space:]')" ]; then
printf '%s\n' "$NOTES" > "$RUNNER_TEMP/notes.md"
gh release create "$TAG" --title "$TAG" --notes-file "$RUNNER_TEMP/notes.md"
else
gh release create "$TAG" --title "$TAG" --generate-notes
fi