@@ -52,20 +52,161 @@ jobs:
5252 DATE=$(date +%Y-%m-%d)
5353 VERSION="${{ steps.version.outputs.version_number }}"
5454
55- # Create temporary file with new entry
56- echo "# Changelog" > CHANGELOG.tmp
57- echo "" >> CHANGELOG.tmp
58- echo "All notable changes to Simplistic Tetris will be documented in this file." >> CHANGELOG.tmp
59- echo "" >> CHANGELOG.tmp
55+ # Get the previous version tag
56+ PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
57+
58+ # Create temporary file with header
59+ cat > CHANGELOG.tmp << 'HEADER'
60+ # Changelog
61+
62+ All notable changes to Simplistic Tetris V2 will be documented in this file.
63+
64+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
65+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66+
67+ HEADER
68+
6069 echo "## [$VERSION] - $DATE" >> CHANGELOG.tmp
6170 echo "" >> CHANGELOG.tmp
62- echo "### Added" >> CHANGELOG.tmp
63- echo "- Release $VERSION" >> CHANGELOG.tmp
64- echo "" >> CHANGELOG.tmp
6571
66- # Append existing changelog content (skip header)
72+ # Generate changelog from commits
73+ if [ -n "$PREV_TAG" ]; then
74+ # Arrays to store commits by category
75+ declare -a features=()
76+ declare -a fixes=()
77+ declare -a docs=()
78+ declare -a styles=()
79+ declare -a refactors=()
80+ declare -a perfs=()
81+ declare -a tests=()
82+ declare -a others=()
83+
84+ # Get commits between tags
85+ while IFS= read -r commit; do
86+ # Remove conventional commit prefix for cleaner display
87+ clean_commit="$commit"
88+
89+ case "$commit" in
90+ feat:*|feat\(*)
91+ clean_commit="${commit#feat:}"
92+ clean_commit="${clean_commit#feat(*)}"
93+ features+=("$clean_commit")
94+ ;;
95+ fix:*|fix\(*)
96+ clean_commit="${commit#fix:}"
97+ clean_commit="${clean_commit#fix(*)}"
98+ fixes+=("$clean_commit")
99+ ;;
100+ docs:*|docs\(*)
101+ clean_commit="${commit#docs:}"
102+ clean_commit="${clean_commit#docs(*)}"
103+ docs+=("$clean_commit")
104+ ;;
105+ style:*|style\(*)
106+ clean_commit="${commit#style:}"
107+ clean_commit="${clean_commit#style(*)}"
108+ styles+=("$clean_commit")
109+ ;;
110+ refactor:*|refactor\(*)
111+ clean_commit="${commit#refactor:}"
112+ clean_commit="${clean_commit#refactor(*)}"
113+ refactors+=("$clean_commit")
114+ ;;
115+ perf:*|perf\(*)
116+ clean_commit="${commit#perf:}"
117+ clean_commit="${clean_commit#perf(*)}"
118+ perfs+=("$clean_commit")
119+ ;;
120+ test:*|test\(*)
121+ clean_commit="${commit#test:}"
122+ clean_commit="${clean_commit#test(*)}"
123+ tests+=("$clean_commit")
124+ ;;
125+ chore:*|chore\(*)
126+ # Skip chore commits
127+ ;;
128+ Merge*)
129+ # Skip merge commits
130+ ;;
131+ *)
132+ others+=("$commit")
133+ ;;
134+ esac
135+ done < <(git log $PREV_TAG..HEAD --pretty=format:"%s")
136+
137+ # Write categorized commits
138+ if [ ${#features[@]} -gt 0 ]; then
139+ echo "### Added" >> CHANGELOG.tmp
140+ for item in "${features[@]}"; do
141+ echo "- $item" >> CHANGELOG.tmp
142+ done
143+ echo "" >> CHANGELOG.tmp
144+ fi
145+
146+ if [ ${#fixes[@]} -gt 0 ]; then
147+ echo "### Fixed" >> CHANGELOG.tmp
148+ for item in "${fixes[@]}"; do
149+ echo "- $item" >> CHANGELOG.tmp
150+ done
151+ echo "" >> CHANGELOG.tmp
152+ fi
153+
154+ if [ ${#perfs[@]} -gt 0 ]; then
155+ echo "### Performance" >> CHANGELOG.tmp
156+ for item in "${perfs[@]}"; do
157+ echo "- $item" >> CHANGELOG.tmp
158+ done
159+ echo "" >> CHANGELOG.tmp
160+ fi
161+
162+ if [ ${#refactors[@]} -gt 0 ]; then
163+ echo "### Refactored" >> CHANGELOG.tmp
164+ for item in "${refactors[@]}"; do
165+ echo "- $item" >> CHANGELOG.tmp
166+ done
167+ echo "" >> CHANGELOG.tmp
168+ fi
169+
170+ if [ ${#styles[@]} -gt 0 ]; then
171+ echo "### Style" >> CHANGELOG.tmp
172+ for item in "${styles[@]}"; do
173+ echo "- $item" >> CHANGELOG.tmp
174+ done
175+ echo "" >> CHANGELOG.tmp
176+ fi
177+
178+ if [ ${#docs[@]} -gt 0 ]; then
179+ echo "### Documentation" >> CHANGELOG.tmp
180+ for item in "${docs[@]}"; do
181+ echo "- $item" >> CHANGELOG.tmp
182+ done
183+ echo "" >> CHANGELOG.tmp
184+ fi
185+
186+ if [ ${#tests[@]} -gt 0 ]; then
187+ echo "### Tests" >> CHANGELOG.tmp
188+ for item in "${tests[@]}"; do
189+ echo "- $item" >> CHANGELOG.tmp
190+ done
191+ echo "" >> CHANGELOG.tmp
192+ fi
193+
194+ if [ ${#others[@]} -gt 0 ]; then
195+ echo "### Other Changes" >> CHANGELOG.tmp
196+ for item in "${others[@]}"; do
197+ echo "- $item" >> CHANGELOG.tmp
198+ done
199+ echo "" >> CHANGELOG.tmp
200+ fi
201+ else
202+ echo "### Initial Release" >> CHANGELOG.tmp
203+ echo "" >> CHANGELOG.tmp
204+ echo "- First release of Simplistic Tetris" >> CHANGELOG.tmp
205+ echo "" >> CHANGELOG.tmp
206+ fi
207+
208+ # Append existing changelog content (skip header until first version)
67209 if [ -f CHANGELOG.md ]; then
68- # Skip lines until we find the first version entry
69210 sed -n '/^## \[/,$p' CHANGELOG.md >> CHANGELOG.tmp
70211 fi
71212
98239 prerelease : false
99240 env :
100241 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
101-
102- - name : Deploy to Netlify
103- run : npx netlify-cli deploy --dir=dist --prod
104- env :
105- NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }}
106- NETLIFY_SITE_ID : ${{ secrets.NETLIFY_SITE_ID }}
0 commit comments