Skip to content

Commit a0d8bc4

Browse files
committed
chore: bump version number (v2024.3.5 -> v2024.3.6)
feat: added automatic release notes generation fix: fixed version generation refactor: removed redundant tag creation action
1 parent 7640d77 commit a0d8bc4

File tree

2 files changed

+64
-16
lines changed

2 files changed

+64
-16
lines changed

.github/workflows/prerelease_on_version_bump.yaml

+63-15
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,79 @@ jobs:
3535
id: previous_version
3636
run: echo "PREVIOUS_VERSION=$(git show HEAD~:custom_components/$DOMAIN/manifest.json | jq -r '.version')" >> $GITHUB_ENV
3737

38-
- name: Create Tag
38+
- name: Collect Changes
3939
if: ${{ env.CURRENT_VERSION != env.PREVIOUS_VERSION }}
40-
uses: actions/github-script@v7
41-
with:
42-
script: |
43-
const version = '${{ steps.current_version.outputs.version }}';
44-
github.rest.git.createRef({
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
ref: `refs/tags/v${version}`,
48-
sha: '${{ github.sha }}'
49-
});
40+
id: collect_changes
41+
run: |
42+
PREVIOUS_TAG=$(git rev-list -n 1 v${{ env.PREVIOUS_VERSION }})
43+
CURRENT_SHA=${{ github.sha }}
44+
if [ -z "$PREVIOUS_TAG" ]; then
45+
# Fallback in case there's no previous tag
46+
CHANGELOG=$(git log --pretty=format:"%s%n%b" $(git rev-list --max-parents=0 HEAD)..$CURRENT_SHA)
47+
else
48+
CHANGELOG=$(git log --pretty=format:"%s%n%b" $PREVIOUS_TAG..$CURRENT_SHA)
49+
fi
50+
51+
# Initialize section variables
52+
ALL_FEATURES=""
53+
ALL_FIXES=""
54+
ALL_CHANGES=""
55+
ALL_OTHER=""
56+
57+
# Process each commit message
58+
echo "Processing changelog"
59+
echo "$CHANGELOG" | while IFS= read -r line; do
60+
if [[ "$line" == "feat"* ]]; then
61+
echo "Adding features line: $line"
62+
ALL_FEATURES+="- $line\n"
63+
elif [[ "$line" == "fix"* ]]; then
64+
echo "Adding fixes line: $line"
65+
ALL_FIXES+="- $line\n"
66+
elif [[ "$line" == "refactor"* ]]; then
67+
echo "Adding changes line: $line"
68+
ALL_CHANGES+="- $line\n"
69+
elif [[ ! -z "$line" ]]; then
70+
echo "Adding others line: $line"
71+
ALL_OTHER+="- $line\n"
72+
fi
73+
done
74+
75+
# Start with an empty formatted changelog
76+
CHANGELOG=""
77+
78+
# Add sections if not empty
79+
if [ ! -z "$ALL_FEATURES" ]; then
80+
CHANGELOG+="## :new: Нововведения\n\n${ALL_FEATURES}\n"
81+
fi
82+
if [ ! -z "$ALL_FIXES" ]; then
83+
CHANGELOG+="## :bug: Исправления\n\n${ALL_FIXES}\n"
84+
fi
85+
if [ ! -z "$ALL_CHANGES" ]; then
86+
CHANGELOG+="## :wrench: Изменения\n\n${ALL_CHANGES}"
87+
fi
88+
if [ ! -z "$ALL_OTHER" ]; then
89+
CHANGELOG+="## :information_source: Примечания\n\n${ALL_OTHER}"
90+
fi
91+
92+
# Save to GITHUB_ENV
93+
{
94+
echo 'CHANGELOG<<EOF'
95+
echo -e "$CHANGELOG" | sed '$d'
96+
echo 'EOF'
97+
} >> $GITHUB_ENV
5098
5199
- name: Create Pre-release
52100
if: ${{ env.CURRENT_VERSION != env.PREVIOUS_VERSION }}
53101
uses: actions/github-script@v7
54102
with:
55103
script: |
56-
const version = '${{ steps.current_version.outputs.version }}';
104+
const {CHANGELOG, CURRENT_VERSION} = process.env;
57105
github.rest.repos.createRelease({
58106
owner: context.repo.owner,
59107
repo: context.repo.repo,
60-
tag_name: `v${version}`,
61-
name: `v${version}`,
62-
body: "## :new: Нововведения\n\n<!-- ... -->\n\n## :bug: Исправления\n\n<!-- ... -->\n\n## :wrench: Изменения\n\n<!-- ... -->\n\n## :information_source: Примечания\n\n<!-- ... -->",
108+
tag_name: `v${CURRENT_VERSION}`,
109+
name: `v${CURRENT_VERSION}`,
110+
body: `${CHANGELOG}`,
63111
draft: false,
64112
prerelease: true,
65113
});

custom_components/pandora_cas/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"haversine~=2.8.0",
1515
"pandora-cas==0.0.7"
1616
],
17-
"version": "2024.3.5"
17+
"version": "2024.3.6"
1818
}

0 commit comments

Comments
 (0)