-
-
Notifications
You must be signed in to change notification settings - Fork 6
96 lines (79 loc) · 2.77 KB
/
Copy pathcreate-release.yml
File metadata and controls
96 lines (79 loc) · 2.77 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
name: Create GitHub release from tag
on:
push:
tags:
- 'v*.*.*'
concurrency:
group: create-release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect prerelease
id: meta
env:
TAG_NAME: ${{ github.ref_name }}
run: |
if [[ "$TAG_NAME" == *-* ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Build release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
REPO: ${{ github.repository }}
IS_PRERELEASE: ${{ steps.meta.outputs.prerelease }}
run: |
set -euo pipefail
AUTO_NOTES=$(gh api "repos/${REPO}/releases/generate-notes" \
-f tag_name="$TAG_NAME" \
--jq '.body')
PRERELEASE_BANNER=""
if [ "$IS_PRERELEASE" = "true" ]; then
PRERELEASE_BANNER=$'> [!WARNING]\n> This is a pre-release. It may contain incomplete features or known issues — pin intentionally.\n\n'
fi
{
printf '%s' "$PRERELEASE_BANNER"
printf '%s\n\n' "$AUTO_NOTES"
cat <<'NOTES'
---
## Install
[](https://my.home-assistant.io/redirect/hacs_repository/?owner=sirkirby&repository=UniFi-network-rules&category=integration)
Or manually copy `custom_components/unifi_network_rules` from the source archive into your Home Assistant `config/custom_components/` directory and restart.
NOTES
} > release-notes.md
echo "Generated release notes:"
echo "------"
cat release-notes.md
echo "------"
- name: Create release if missing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
IS_PRERELEASE: ${{ steps.meta.outputs.prerelease }}
run: |
set -euo pipefail
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
echo "Release ${TAG_NAME} already exists; skipping"
exit 0
fi
args=(
"$TAG_NAME"
--title "$TAG_NAME"
--notes-file release-notes.md
--verify-tag
)
if [ "$IS_PRERELEASE" = "true" ]; then
args+=(--prerelease)
fi
gh release create "${args[@]}"