Skip to content

Commit 57ddb86

Browse files
committed
ci: add automatic release workflow for HA integration
When manifest.json version changes, automatically create a GitHub Release so HACS can detect updates without manual intervention.
1 parent 3dbdb3d commit 57ddb86

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Automatically create GitHub Release when HA integration version changes
2+
# 当 HA 插件版本变更时自动创建 GitHub Release
3+
#
4+
# This workflow monitors manifest.json for version changes and creates releases
5+
# so HACS can detect updates automatically.
6+
7+
name: Release Integration
8+
9+
on:
10+
push:
11+
branches: [main, master]
12+
paths:
13+
- 'custom_components/seeed_ha_discovery/manifest.json'
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Get version from manifest
26+
id: version
27+
run: |
28+
VERSION=$(jq -r '.version' custom_components/seeed_ha_discovery/manifest.json)
29+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
30+
echo "Integration version: ${VERSION}"
31+
32+
- name: Check if release exists
33+
id: check
34+
run: |
35+
if gh release view "v${{ steps.version.outputs.version }}" > /dev/null 2>&1; then
36+
echo "exists=true" >> $GITHUB_OUTPUT
37+
echo "Release v${{ steps.version.outputs.version }} already exists"
38+
else
39+
echo "exists=false" >> $GITHUB_OUTPUT
40+
echo "Release v${{ steps.version.outputs.version }} does not exist, will create"
41+
fi
42+
env:
43+
GH_TOKEN: ${{ github.token }}
44+
45+
- name: Generate release notes
46+
if: steps.check.outputs.exists == 'false'
47+
id: notes
48+
run: |
49+
# Get commits since last tag
50+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
51+
if [ -n "$LAST_TAG" ]; then
52+
CHANGES=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s" --no-merges | head -20)
53+
else
54+
CHANGES=$(git log --pretty=format:"- %s" --no-merges -10)
55+
fi
56+
57+
# Create release notes
58+
cat > release_notes.md << EOF
59+
## Seeed HA Discovery v${{ steps.version.outputs.version }}
60+
61+
### Changes
62+
${CHANGES}
63+
64+
---
65+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LAST_TAG}...v${{ steps.version.outputs.version }}
66+
EOF
67+
68+
cat release_notes.md
69+
70+
- name: Create Release
71+
if: steps.check.outputs.exists == 'false'
72+
run: |
73+
gh release create "v${{ steps.version.outputs.version }}" \
74+
--title "v${{ steps.version.outputs.version }}" \
75+
--notes-file release_notes.md
76+
env:
77+
GH_TOKEN: ${{ github.token }}
78+
79+
- name: Release created
80+
if: steps.check.outputs.exists == 'false'
81+
run: |
82+
echo "✅ Release v${{ steps.version.outputs.version }} created successfully!"
83+
echo "HACS will now detect this update."
84+

0 commit comments

Comments
 (0)