Skip to content

Add release notes generation to GitHub Actions workflow #23

Add release notes generation to GitHub Actions workflow

Add release notes generation to GitHub Actions workflow #23

Workflow file for this run

name: Build and Release
on:
push:
branches:
- main
tags:
- 'v*'
jobs:
build-and-release:
runs-on: windows-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Build with PyInstaller
run: |
pyinstaller --onedir --windowed --name "ChiselPDF" --add-data "style.qss;." main.py
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Generate version number
id: version
run: |
$version = "1.0.${{ github.run_number }}"
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "Version: $version"
- name: Generate release notes
id: release_notes
run: |
$tag = "v${{ steps.version.outputs.VERSION }}"
# Get the previous tag
$previousTag = git describe --tags --abbrev=0 HEAD^ 2>$null
if ($previousTag) {
# Generate commit log between tags
$commits = git log "$previousTag..HEAD" --pretty=format:"- %s (%h)" --no-merges
} else {
# First release - show recent commits
$commits = git log -10 --pretty=format:"- %s (%h)" --no-merges
}
$releaseNotes = @"
## What's Changed
$commits
**Full Changelog**: https://github.com/${{ github.repository }}/compare/$previousTag...$tag
"@ -replace "`r`n", "`n"
# Escape for GitHub Actions
$releaseNotes = $releaseNotes -replace '%', '%25' -replace "`n", '%0A' -replace "`r", '%0D'
echo "NOTES=$releaseNotes" >> $env:GITHUB_OUTPUT
- name: Create version info file
run: |
@"
VSVersionInfo(
ffi=FixedFileInfo(
filevers=(1, 0, ${{ github.run_number }}, 0),
prodvers=(1, 0, ${{ github.run_number }}, 0),
mask=0x3f,
flags=0x0,
OS=0x40004,
fileType=0x1,
subtype=0x0,
date=(0, 0)
),
kids=[
StringFileInfo([
StringTable(
u'040904B0',
[StringStruct(u'CompanyName', u'kelltom'),
StringStruct(u'FileDescription', u'ChiselPDF - PDF Page Selector'),
StringStruct(u'FileVersion', u'1.0.${{ github.run_number }}.0'),
StringStruct(u'InternalName', u'ChiselPDF'),
StringStruct(u'LegalCopyright', u'Copyright (c) 2025 kelltom'),
StringStruct(u'OriginalFilename', u'ChiselPDF.exe'),
StringStruct(u'ProductName', u'ChiselPDF'),
StringStruct(u'ProductVersion', u'1.0.${{ github.run_number }}.0')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)
"@ | Out-File -FilePath version_info.txt -Encoding UTF8
- name: Create Velopack Release
run: |
dotnet tool install -g vpk
vpk download github --repoUrl https://github.com/${{ github.repository }} --token ${{ secrets.GITHUB_TOKEN }}
vpk pack --packId ChiselPDF --packVersion ${{ steps.version.outputs.VERSION }} --packDir .\dist\ChiselPDF --mainExe ChiselPDF.exe
vpk upload github --repoUrl https://github.com/${{ github.repository }} --publish --releaseName "ChiselPDF ${{ steps.version.outputs.VERSION }}" --tag v${{ steps.version.outputs.VERSION }} --releaseNotes "${{ steps.release_notes.outputs.NOTES }}" --token ${{ secrets.GITHUB_TOKEN }}