-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (98 loc) · 2.96 KB
/
Copy pathcreate-release.yaml
File metadata and controls
122 lines (98 loc) · 2.96 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. v1.1.0)'
required: true
type: string
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: main
- name: Parse version
id: version
run: |
VERSION="${{ inputs.version }}"
if [[ "$VERSION" != v* ]]; then
VERSION="v${VERSION}"
fi
echo "tag=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Parse changelog for release notes
run: |
TAG="${{ steps.version.outputs.tag }}"
SECTION=$(awk -v ver="$TAG" '
BEGIN { found=0 }
/^## \[v/ {
if (found) exit
if (index($0, ver)) found=1
next
}
found { print }
' CHANGELOG.md)
if [ -z "$SECTION" ]; then
echo "::error::No changelog entry found for version ${TAG}"
exit 1
fi
BREAKING=$(echo "$SECTION" | awk '
BEGIN { found=0 }
/^### !!! Breaking Changes/ { found=1; next }
/^###/ { if (found) exit }
found && /^- / { print }
')
ADDED=$(echo "$SECTION" | awk '
BEGIN { found=0 }
/^### Added/ { found=1; next }
/^###/ { if (found) exit }
found && /^- / && !/N\/A/ { print }
')
CHANGED=$(echo "$SECTION" | awk '
BEGIN { found=0 }
/^### Changed/ { found=1; next }
/^###/ { if (found) exit }
found && /^- / && !/N\/A/ { print }
')
FIXED=$(echo "$SECTION" | awk '
BEGIN { found=0 }
/^### Fixed/ { found=1; next }
/^###/ { if (found) exit }
found && /^- / && !/N\/A/ { print }
')
NOTES=""
if [ -n "$BREAKING" ]; then
NOTES="### Breaking Changes
${BREAKING}
"
fi
if [ -n "$ADDED" ]; then
NOTES="${NOTES}### Added
${ADDED}
"
fi
if [ -n "$CHANGED" ]; then
NOTES="${NOTES}### Changed
${CHANGED}
"
fi
if [ -n "$FIXED" ]; then
NOTES="${NOTES}### Fixed
${FIXED}
"
fi
NOTES="${NOTES}[Full changelog](https://github.com/anaconda/anaconda-otel-python/blob/main/CHANGELOG.md)"
echo "$NOTES" > /tmp/release_notes.md
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
--title "${{ steps.version.outputs.tag }}" \
--target main \
--notes-file /tmp/release_notes.md