Mark Ku's Blog

Dev Workflow Series — No More Manual Release Notes, Use PowerShell + git log

The Problem

When a feature is finished and ready to deploy to the next environment, we usually have to "manually log" what changed, so if the next environment hits an issue, we can quickly trace it back to a release. To let developers stay focused on dev, I built a PowerShell automation script that creates a Git tag and produces the Release Note.

Current Versioning Scheme

Trigger CI/CD via git tag to build automatically.
b-3.0.1 => b-3.0.2
b is the beta environment, 3.0 is the major version, the last digit is the minor version.

Before Writing the Script — Get Familiar with Git Commands

Find all commit logs between two tags

git log --pretty="%s (%h - %an)" "b-0.0.1..b-0.0.2" | grep -i -E '(bug|feature|support|study|task|design) #[0-9]+ '

P.S. You can append filter conditions to find matching logs.

Find the previous version tag in the Beta environment

git describe --tags --abbrev=0 --match  "b-[0-9]*

Gotcha — running git log in PowerShell shows garbled Chinese

  1. Git's default encoding is UTF-8, but our commit messages need to be set to big5 via git config.
git config --global core.quotepath false 
git config --global gui.encoding big5
git config --global i18n.commit.encoding big5
git config --global i18n.logoutputencoding big5 
  1. On English-locale OS, you need to go to Control Panel > Administrative > Region and adjust the language encoding. Windows Region Settings dialog showing Traditional Chinese language encoding

P.S. You can also use the chcp 950 command to test whether the OS supports big5 encoding.

Execution Screenshots

  1. On run, the script shows the previous Beta version and asks you to enter the new Beta version PowerShell script showing previous Git version and prompting for new tag

  2. After completion PowerShell console showing git log and successful release note generation

  3. Result The Git log commit messages are auto-prepended to the Release Note Notepad displaying auto-generated release notes from git log commits

Auto generate release note script

I originally wrote this with DOS commands and it was painful. After a colleague's suggestion I switched to PowerShell — the code is much cleaner and saves a lot of time and effort.

git config --global core.quotepath false 
git config --global gui.encoding big5
git config --global i18n.commit.encoding big5
git config --global i18n.logoutputencoding big5 
$OutputEncoding = New-Object -typename System.Text.UTF8Encoding

$lastVersion = git describe --tags --abbrev=0 --match  "b-[0-9]*"
Write-Host "Last Version $lastVersion"

$newTag = Read-Host 'Please Enter New Git Tag Name. EX:b-3.0.48  '
# $lastVersion = Read-Host 'Please Enter lastVersion  '


# $newTag= "b-3.0.1"
# $lastVersion = git describe --tags --abbrev=0 --match  "b-[0-9]*"
Write-Host "$lastVersion "
git tag -f $newTag
$fullVersionNo = $newTag.Split("-")[1]
$versionCharArray =$fullVersionNo.Split(".")


$bigVersion = ($versionCharArray[0],$versionCharArray[1]) -join "."
Write-Host $bigVersion

[string[]]$lines = git log --pretty="%n|%h|%ai|%s" "$lastVersion..$newTag"
$datetimeNow = Get-Date -Format "dddd MM/dd/yyyy HH:mm K"
$owner = git config user.name
$newReleaseNote = New-Object System.Collections.ArrayList

# $newReleaseNote.Add("$lastVersion - $newTag")

$newReleaseNote.Add("Date: $datetimeNow")
$newReleaseNote.Add("Version: $fullVersionNo")
$newReleaseNote.Add("Owner: $owner")
$newReleaseNote.Add("")
$newReleaseNote.Add("Feature:")
foreach ($line in $lines) {
     $line = $line.Trim()
	 # $newReleaseNote.Add("$line")
     if ([String]::IsNullOrEmpty($line)) {
       continue
     }
     else
	 {
	 $Matches = $line.Split("|")
       $hash = $Matches[1]
       $datetime = $Matches[2]
       $subject = $Matches[3]
	   $newReleaseNote.Add("$datetime : $subject")
	   Write-Host "$hash / $datetime / $subject"
     }
     
 }
$newReleaseNote.Add("")
$newReleaseNote.Add("===================================")

@($newReleaseNote) +  (Get-Content -Encoding utf8  "./ReleaseNote/ChangeLog/$bigVersion.txt")  | Set-Content -Encoding utf8  "./ReleaseNote/ChangeLog/$bigVersion.txt"  

Write-Host "ReleaseNote 產生成功"

git config --global gui.encoding utf8
git config --global i18n.commit.encoding utf8
git config --global i18n.logoutputencoding utf8

Author

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。Read More

Found this useful?

The author's free tools, daily podcasts and newsletter are all here.

Mark Ku · This article is licensed under CC BY 4.0. Credit the author and link back to the original when reusing it.

Comments

Subscribe to Newsletter

Subscribe to get new posts delivered instantly — never miss a tech share.

By submitting, you agree to receive emails. You can anytime.

Popular Posts

View all
Mark Ku
··602

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution
Mark Ku
··490

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.
Mark Ku
··333

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki
Mark Ku
··264

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning
Mark Ku
··221

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1
Mark Ku
··215

Setting Up Samba on Ubuntu to Share Folders with Windows 11

Setting Up Samba on Ubuntu to Share Folders with Windows 11