66 description : ' Version to release'
77 required : true
88 type : string
9-
109permissions :
1110 contents : write
12-
1311jobs :
1412 bump-version-and-release :
13+ name : Bump version and release
1514 runs-on : ubuntu-latest
1615 steps :
1716 - name : Checkout repository
1817 uses : actions/checkout@v4
1918 with :
2019 fetch-depth : 0 # Fetch full history & tags for proper release notes
21-
2220 - name : Show current version
2321 run : |
2422 echo "Current version is:"
2523 grep '^version=' library.properties || echo "Not found"
26-
2724 - name : Set up Git user
2825 run : |
2926 git config --global user.name "github-actions[bot]"
3027 git config --global user.email "github-actions[bot]@users.noreply.github.com"
31-
3228 - name : Bump library.properties version
3329 env :
3430 NEW_VERSION : ${{ github.event.inputs.new_version }}
3531 run : |
3632 sed -i "s/^version=.*/version=${NEW_VERSION}/" library.properties
37-
3833 - name : Bump library.json version
3934 env :
4035 NEW_VERSION : ${{ github.event.inputs.new_version }}
4136 run : |
4237 jq ".version = \"${NEW_VERSION}\"" library.json > tmp.json && mv tmp.json library.json
43-
4438 - name : Commit & push version bump
4539 env :
4640 NEW_VERSION : ${{ github.event.inputs.new_version }}
4741 run : |
4842 git add library.properties library.json
4943 git commit -m "Bump version to ${NEW_VERSION}" || echo "No changes to commit"
5044 git push
51-
5245 - name : Create and push tag
5346 env :
5447 NEW_VERSION : ${{ github.event.inputs.new_version }}
5548 run : |
56- git tag "v${NEW_VERSION}"
57- git push origin "v${NEW_VERSION}"
58-
49+ git tag "${NEW_VERSION}"
50+ git push origin "${NEW_VERSION}"
5951 - name : Build release notes
6052 env :
6153 NEW_VERSION : ${{ github.event.inputs.new_version }}
6254 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6355 run : |
6456 set -euo pipefail
6557 git fetch --tags || true
66-
67- # Determine range for changelog
6858 PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)
6959 if [ -n "$PREV_TAG" ]; then
7060 RANGE="${PREV_TAG}..HEAD"
7161 else
7262 RANGE="--no-merges HEAD"
7363 fi
74-
75- # Collect commits
7664 git log $RANGE --pretty=format:'%h %s (%an)' > commits.raw
77-
78- # Start notes file
79- printf "# Release v%s\n\n" "${NEW_VERSION}" > release_notes.md
80-
81- # Conventional-commit grouping
65+ printf "# Release %s\n\n" "${NEW_VERSION}" > release_notes.md
8266 for type in feat fix docs chore perf refactor test; do
8367 if grep -Ei "^(.*: )?${type}(\(.+\))?: " commits.raw >/dev/null 2>&1; then
8468 header=$(case $type in
@@ -97,42 +81,19 @@ jobs:
9781 echo >> release_notes.md
9882 fi
9983 done
100-
101- # Other changes
10284 if grep -Eiv "^(.*: )?(feat|fix|docs|chore|perf|refactor|test)(\(.+\))?: " commits.raw >/dev/null 2>&1; then
10385 printf "## Other changes\n\n" >> release_notes.md
10486 grep -Eiv "^(.*: )?(feat|fix|docs|chore|perf|refactor|test)(\(.+\))?: " commits.raw \
10587 | sed -E 's/^[0-9a-f]+ //; s/\s+\([^)]+\)$//' \
10688 | sed 's/^/- /' >> release_notes.md
10789 echo >> release_notes.md
10890 fi
109-
110- # Optional AI summary
111- if command -v gh >/dev/null 2>&1 && gh help ai >/dev/null 2>&1; then
112- echo "Generating AI summary..."
113- SUMMARY=$(gh ai chat --repo "${{ github.repository }}" <<'EOF'
114- Please read the following commit entries and produce a short (4-8 bullet) user-facing release summary grouped by type: Features, Fixes, Others. Keep bullets concise and single-line.
115-
116- Commit entries:
117- $(cat commits.raw)
118- EOF
119- ) || true
120-
121- if [ -n "$SUMMARY" ]; then
122- printf "## Summary\n\n%s\n\n" "$SUMMARY" > head.md
123- cat head.md release_notes.md > tmp.md && mv tmp.md release_notes.md
124- fi
125- fi
126-
127- # Fallback if nothing generated
128- [ -s release_notes.md ] || echo -e "# Release v${NEW_VERSION}\n\nNo changes detected." > release_notes.md
129-
91+ [ -s release_notes.md ] || echo -e "# Release ${NEW_VERSION}\n\nNo changes detected." > release_notes.md
13092 - name : Create GitHub Release with notes-file
13193 env :
13294 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
13395 NEW_VERSION : ${{ github.event.inputs.new_version }}
13496 run : |
135- # Authenticate and publish
13697 echo "${GITHUB_TOKEN}" | gh auth login --with-token >/dev/null 2>&1 || true
13798 gh release create "${NEW_VERSION}" \
13899 --notes-file release_notes.md \
0 commit comments