-
Notifications
You must be signed in to change notification settings - Fork 12
118 lines (106 loc) · 5.02 KB
/
Copy pathrelease.yml
File metadata and controls
118 lines (106 loc) · 5.02 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
name: Create Release
# Triggered by publishing the release, not by the tag push, so the workflow
# can read the release you created and honour the "Previous tag" you picked
# there. GitHub does not expose that choice as a field — the only durable
# trace is the compare link in the notes it generates — so it is recovered
# from the release body below.
on:
release:
types: [published]
permissions:
contents: write
jobs:
release:
name: Build ZIP and create GitHub Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.release.tag_name }}
- name: Get version from tag
id: version
run: |
TAG="${{ github.event.release.tag_name }}"
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
- name: Resolve previous tag from the release notes
id: prev
env:
# Quoted via env rather than inlined, so a body containing quotes or
# backticks cannot break out of the script.
BODY: ${{ github.event.release.body }}
run: |
# "Generate release notes" appends a line of the form:
# **Full Changelog**: https://github.com/OWNER/REPO/compare/v1.5.1...v1.5.2
# The tag before "..." is exactly the previous release that was
# selected in the UI. Take the last occurrence, in case the body
# quotes other compare links above it.
FROM_TAG=$(printf '%s\n' "$BODY" \
| sed -nE 's#.*/compare/([^/[:space:]]+)\.\.\.[^[:space:])]+.*#\1#p' \
| tail -1)
if [ -n "$FROM_TAG" ]; then
echo "Using previous tag from the release notes: $FROM_TAG"
else
echo "No compare link in the release body; letting the changelog"
echo "builder fall back to the most recent tag."
fi
echo "from_tag=$FROM_TAG" >> $GITHUB_OUTPUT
# Tags are created by hand in the GitHub UI, so nothing has written the
# new version into manifest.json by the time this runs — the tagged
# commit still carries the previous one. The ZIP is patched here so the
# shipped manifest matches the tag. This edit is local to the runner and
# is never committed back.
- name: Update version in manifest.json
run: |
sed -i 's/"version": "[^"]*"/"version": "${{ steps.version.outputs.version }}"/' \
custom_components/simple_pid_controller/manifest.json
- name: Create release ZIP
run: |
cd custom_components/simple_pid_controller/
zip ../../simple_pid_controller.zip -r ./
- name: Generate changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v6
with:
# Empty fromTag = keep the action's own "most recent tag" detection.
fromTag: ${{ steps.prev.outputs.from_tag }}
toTag: ${{ github.event.release.tag_name }}
commitMode: true
configuration: |
{
"label_extractor": [
{ "pattern": "^(feat|feature|add)(\\(.+\\))?!?[:\\s]", "target": "feature" },
{ "pattern": "^(fix|bug|bugfix|hotfix)(\\(.+\\))?!?[:\\s]", "target": "bug" },
{ "pattern": "^(docs?|documentation)(\\(.+\\))?[:\\s]", "target": "documentation" },
{ "pattern": "^(ci|github.?actions?)(\\(.+\\))?[:\\s]", "target": "ci" },
{ "pattern": "^(chore|refactor|test|perf|style|build|bump)(\\(.+\\))?[:\\s]", "target": "chore" }
],
"categories": [
{ "title": "## ✨ New features", "labels": ["feature", "enhancement"] },
{ "title": "## 🐛 Bug fixes", "labels": ["bug", "fix"] },
{ "title": "## 📚 Documentation", "labels": ["documentation"] },
{ "title": "## 🔧 Other", "labels": ["chore"] },
{ "title": "## 👷 CI", "labels": ["ci"] },
{ "title": "## 📦 Uncategorized", "labels": [] }
],
"ignore_labels": ["dependabot"],
"template": "#{{CHANGELOG}}\n\n**Full changelog**: #{{RELEASE_DIFF}}"
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
# The release already exists (this runs on publish); naming the tag
# makes it update that one instead of guessing from the ref.
tag_name: ${{ github.event.release.tag_name }}
files: simple_pid_controller.zip
body: |
${{ steps.changelog.outputs.changelog }}
---
## Installation via HACS
Install or update via HACS — the new version will be offered automatically.
## Manual installation
Download `simple_pid_controller.zip`, extract and copy `simple_pid_controller/` to your `custom_components/` directory.
generate_release_notes: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}