Skip to content

Commit 6a906b4

Browse files
committed
ci: Add Changelog step for the draft releases
1 parent 2d93542 commit 6a906b4

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
run: |
3333
PROPERTIES="$(./gradlew properties --console=plain -q)"
3434
VERSION="$(echo "$PROPERTIES" | grep "^VERSION_NAME:" | cut -f2- -d ' ')"
35+
CHANGELOG="$(./get_changelog.sh)"
3536
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT
3638
3739
# Remove old release drafts by using the curl request for the available releases with a draft flag
3840
- name: Remove Old Release Drafts
@@ -51,3 +53,4 @@
5153
gh release create v${{ steps.properties.outputs.version }} \
5254
--draft \
5355
--title "v${{ steps.properties.outputs.version }}" \
56+
--notes "${{ steps.properties.outputs.changelog }}" \

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog
2+
3+
All notable changes to Mosaic will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
11+
## [0.0.1] - 2024-03-27
12+
13+
### Added
14+
15+
16+
17+
## [0.0.0]
18+
### Added

get_changelog.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Accept the version as a command-line argument
4+
version=$1
5+
6+
# Find the line number where the version is mentioned
7+
start=$(grep -n "\[$version\]" CHANGELOG.md | cut -d : -f 1)
8+
9+
# If the version is not found, use "Unreleased"
10+
if [ -z "$start" ]; then
11+
version="Unreleased"
12+
start=$(grep -n "\[$version\]" CHANGELOG.md | cut -d : -f 1)
13+
fi
14+
15+
# Increment the start line to skip the version line
16+
start=$((start + 1))
17+
18+
# Find the line number of the next version
19+
end=$(awk -v start=$start 'NR > start && /\[.*\]/ {print NR; exit}' CHANGELOG.md)
20+
21+
# If the next version is not found, print until the end of the file
22+
if [ -z "$end" ]; then
23+
awk -v start=$start 'NR >= start' CHANGELOG.md
24+
else
25+
awk -v start=$start -v end=$end 'NR >= start && NR < end' CHANGELOG.md
26+
fi

0 commit comments

Comments
 (0)