-
Notifications
You must be signed in to change notification settings - Fork 14
60 lines (51 loc) · 2.02 KB
/
release-drafter.yml
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
name: Release Drafter
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- name: Generate CalVer version
id: calver
shell: python
run: |
import json
import urllib.request
from datetime import date
dat = date.today().strftime("%Y%m%d")
req_rel = urllib.request.Request(
"https://api.github.com/repos/bimmerconnected/ha_custom_component/releases/latest",
headers={"Accept": "application/vnd.github+json"}
)
with urllib.request.urlopen(req_rel) as f:
rel = json.loads(f.read())
major, minor = rel["tag_name"].split(".")
if major == dat:
minor = int(minor) + 1
else:
major = dat
minor = 1
version = f"{major}.{minor}"
print(f"::set-output name=version::{version}")
print(f"Version set to {version}")
req_com = urllib.request.Request(
f"https://api.github.com/repos/bimmerconnected/ha_custom_component/commits?since={rel['created_at']}",
headers={"Accept": "application/vnd.github+json"}
)
with urllib.request.urlopen(req_com) as f:
com = json.loads(f.read())
changes = "%0A".join(["* {} ({})".format(next(iter(c["commit"]["message"].split("\n"))), c["sha"]) for c in com[:-1]])
print(f"::set-output name=changes::{changes}")
print(f"Changes set to:\n{changes}")
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/[email protected]
with:
tag: ${{ steps.calver.outputs.version }}
name: ${{ steps.calver.outputs.version }}
version: ${{ steps.calver.outputs.version }}
footer: ${{ steps.calver.outputs.changes }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}