-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (45 loc) · 1.31 KB
/
Copy pathrelease.yml
File metadata and controls
51 lines (45 loc) · 1.31 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
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to release, for example v1.4.0"
required: true
type: string
permissions:
contents: write
jobs:
github-release:
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract release notes
run: |
TAG="${RELEASE_TAG}"
git rev-parse "$TAG" >/dev/null
awk -v tag="$TAG" '
index($0, "## [" tag "]") == 1 { found = 1; next }
found && /^## \[/ { exit }
found { print }
' changelog.md > release_notes.md
if [ ! -s release_notes.md ]; then
echo "Release $TAG" > release_notes.md
fi
- name: Create or update GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${RELEASE_TAG}"
if gh release view "$TAG" >/dev/null 2>&1; then
gh release edit "$TAG" --title "$TAG" --notes-file release_notes.md
else
gh release create "$TAG" --title "$TAG" --notes-file release_notes.md
fi