Skip to content

Commit a92b5a9

Browse files
committed
chore: add automated release and version bump workflows
1 parent 2c27ec2 commit a92b5a9

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

.github/release-drafter.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Template for the automatically generated release notes
2+
name-template: 'PocketSmith v$RESOLVED_VERSION'
3+
tag-template: 'v$RESOLVED_VERSION'
4+
5+
# Categorise commits into sections based on conventional commit types
6+
categories:
7+
- title: '🚀 New Features'
8+
labels:
9+
- 'feature'
10+
collapse-after: 10
11+
- title: '🐛 Bug Fixes'
12+
labels:
13+
- 'bug'
14+
collapse-after: 10
15+
- title: '🧰 Improvements'
16+
labels:
17+
- 'improvement'
18+
collapse-after: 10
19+
- title: '📝 Documentation'
20+
labels:
21+
- 'documentation'
22+
collapse-after: 10
23+
24+
# Map conventional commit prefixes to labels
25+
autolabeler:
26+
- label: 'feature'
27+
title:
28+
- '/^feat/i'
29+
- label: 'bug'
30+
title:
31+
- '/^fix/i'
32+
- label: 'improvement'
33+
title:
34+
- '/^refactor/i'
35+
- '/^chore/i'
36+
- label: 'documentation'
37+
title:
38+
- '/^docs/i'
39+
40+
# Template for the release body
41+
template: |
42+
## What's Changed
43+
$CHANGES
44+
45+
# Automatically bump version based on commit types
46+
version-resolver:
47+
major:
48+
labels:
49+
- 'breaking-change'
50+
minor:
51+
labels:
52+
- 'feature'
53+
patch:
54+
labels:
55+
- 'bug'
56+
- 'improvement'
57+
- 'documentation'
58+
default: patch

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Automatic Release
2+
3+
# Trigger when a new tag is pushed that starts with 'v'
4+
on:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: read
15+
16+
steps:
17+
# Checkout the repo
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: main
21+
22+
# Use release-drafter to automatically generate and publish the release
23+
# It will use the commit messages to generate the release notes
24+
- uses: release-drafter/release-drafter@v6
25+
with:
26+
# Automatically publish the release instead of saving as draft
27+
publish: true
28+
# Use the tag that triggered this workflow as the release tag
29+
tag: ${{ github.ref_name }}
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Update Manifest Version
2+
3+
# Trigger this workflow whenever a new release is published on GitHub
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
update-version:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# Checkout the main branch so we can make changes to it
13+
- uses: actions/checkout@v4
14+
with:
15+
ref: main
16+
17+
# Strip the 'v' prefix from the tag (e.g. v0.2.4 becomes 0.2.4)
18+
# Then update the version field in manifest.json using jq
19+
- name: Update version in manifest.json
20+
run: |
21+
VERSION=${GITHUB_REF_NAME#v}
22+
jq --arg version "$VERSION" '.version = $version' custom_components/ha_pocketsmith/manifest.json > tmp.json
23+
mv tmp.json custom_components/ha_pocketsmith/manifest.json
24+
25+
# Commit the updated manifest.json back to the main branch
26+
# Uses the github-actions bot as the commit author
27+
- name: Commit and push updated manifest
28+
run: |
29+
git config user.name "github-actions[bot]"
30+
git config user.email "github-actions[bot]@users.noreply.github.com"
31+
git add custom_components/ha_pocketsmith/manifest.json
32+
git commit -m "Bump version to ${GITHUB_REF_NAME}"
33+
git push

0 commit comments

Comments
 (0)