-
Notifications
You must be signed in to change notification settings - Fork 3
60 lines (55 loc) · 1.62 KB
/
Copy pathrelease.yaml
File metadata and controls
60 lines (55 loc) · 1.62 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
on:
push:
branches: [CRAN]
name: release
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Collect tags at pushed commit
id: tags
run: |
tags=$(git tag --points-at HEAD)
{
echo "tags<<EOF"
echo "$tags"
echo "EOF"
} >> "$GITHUB_OUTPUT"
if [ -z "$tags" ]; then
echo "No tags point at HEAD; nothing to release."
fi
- name: Create releases from NEWS.md
if: steps.tags.outputs.tags != ''
env:
TAGS: ${{ steps.tags.outputs.tags }}
run: |
set -euo pipefail
while IFS= read -r tag; do
[ -z "$tag" ] && continue
version="${tag#v}"
notes=$(awk -v ver="$version" '
/^# version / {
if (found) exit
if ($3 == ver) { found = 1; next }
}
found { print }
' NEWS.md)
if [ -z "$(printf "%s" "$notes" | tr -d "[:space:]")" ]; then
echo "::warning::No NEWS.md entry matched version $version; release body will be empty."
fi
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag already exists; skipping."
continue
fi
printf "%s" "$notes" | gh release create "$tag" \
--title "$tag" \
--notes-file -
done <<< "$TAGS"