-
-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (67 loc) · 2.24 KB
/
release-on-version-change.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Release on Version Change
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Node.js (if needed for JSON processing)
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Detect changes to manifest.json
id: detect-changes
run: |
if git diff --name-only HEAD^ HEAD | grep -q "custom_components/eldom/manifest.json"; then
echo "manifest.json was modified."
echo "changed=true" >> $GITHUB_ENV
else
echo "manifest.json was not modified."
echo "changed=false" >> $GITHUB_ENV
fi
- name: Extract new version
id: extract-version
if: env.changed == 'true'
run: |
VERSION=$(jq -r '.version' custom_components/eldom/manifest.json)
echo "Extracted version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
- name: Get previous tag
id: previous-tag
if: env.changed == 'true'
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
echo "Previous tag: $PREVIOUS_TAG"
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_ENV
- name: Generate changelog
id: generate-changelog
if: env.changed == 'true'
run: |
echo "Generating changelog..."
CHANGELOG=$(git log ${{ env.previous_tag }}..HEAD --pretty=format:"- %s (%h)")
echo "Changelog: $CHANGELOG"
echo "changelog<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create GitHub Release
if: env.changed == 'true'
uses: actions/create-release@v1
with:
tag_name: "${{ env.version }}"
release_name: "${{ env.version }}"
body: |
## Changelog
${{ env.changelog }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Log no release
if: env.changed == 'false'
run: echo "No changes to manifest.json. Skipping release creation."