Skip to content

Commit

Permalink
Add release drafter
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe committed Aug 14, 2022
1 parent 15cb0ab commit 7471995
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
template: |
## What's changed
replacers:
- search: '|||'
replace: '<br>'
60 changes: 60 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 = "|||".join(["* {} ({})".format(next(iter(c["commit"]["message"].split("\n"))), c["sha"]) for c in com])
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 }}

0 comments on commit 7471995

Please sign in to comment.