-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (61 loc) · 2.07 KB
/
Copy pathrelease.yml
File metadata and controls
68 lines (61 loc) · 2.07 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
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: vars
run: |
version="${GITHUB_REF#refs/tags/v}"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Verify tag matches manifest versions
run: |
set -euo pipefail
expected="${{ steps.vars.outputs.version }}"
mismatch=0
while IFS= read -r entry; do
path=$(echo "$entry" | jq -r '.path')
field=$(echo "$entry" | jq -r '.field')
jq_path=$(echo "$field" | sed -E 's/\.([0-9]+)/[\1]/g')
actual=$(jq -r ".${jq_path}" "$path" 2>/dev/null || echo "")
if [[ "$actual" != "$expected" ]]; then
echo "::error::$path .${jq_path} is '$actual', expected '$expected'"
mismatch=1
fi
done < <(jq -c '.files[]' .version-bump.json)
if [[ $mismatch -ne 0 ]]; then
echo
echo "Run './scripts/bump-version.sh ${expected}' locally, commit, retag."
exit 1
fi
- name: Extract release notes from CHANGELOG
run: |
set -euo pipefail
version="${{ steps.vars.outputs.version }}"
awk -v ver="$version" '
BEGIN { capture = 0 }
$0 ~ "^## \\[?" ver "\\]?" { capture = 1; next }
capture && /^## / { exit }
capture { print }
' CHANGELOG.md > /tmp/release-notes.md
if [[ ! -s /tmp/release-notes.md ]]; then
echo "Release v$version" > /tmp/release-notes.md
fi
echo "--- Notes ---"
cat /tmp/release-notes.md
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.vars.outputs.version }}" \
--title "v${{ steps.vars.outputs.version }}" \
--notes-file /tmp/release-notes.md