Skip to content

chore: prepare 2.0.2 release #44

chore: prepare 2.0.2 release

chore: prepare 2.0.2 release #44

Workflow file for this run

name: Build & Release (Windows)
on:
push:
tags: [ "v*" ]
pull_request:
branches: [ main ]
workflow_dispatch:
release:
types: [ published ]
permissions:
contents: write
jobs:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Verify APP_VERSION matches the tag
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}" # e.g. v1.1.1
TAG_VER="${TAG#v}" # remove leading "v"
FILE="version.py"
if [ ! -f "$FILE" ]; then
echo "ERROR: $FILE not found"
exit 1
fi
APP_VER="$(awk -F\" '/APP_VERSION *=/ {print $2}' "$FILE")"
echo "Tag version: $TAG_VER"
echo "App version: $APP_VER"
if [ -z "$APP_VER" ]; then
echo "ERROR: APP_VERSION not found in $FILE"
exit 1
fi
if [ "$TAG_VER" != "$APP_VER" ]; then
echo "ERROR: Tag version ($TAG_VER) does not match APP_VERSION ($APP_VER)"
exit 1
fi
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~\AppData\Local\pip\Cache
key: pip-${{ runner.os }}-${{ hashFiles('requirements.txt', 'requirements-build.txt') }}
restore-keys: |
pip-${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-build.txt
- name: Build with PyInstaller
shell: bash
run: |
if [ -f "DIM-Creator.spec" ]; then
pyinstaller -y DIM-Creator.spec
else
pyinstaller app.py \
--noconfirm --onefile --noconsole \
--name DIM-Creator \
--add-data "assets;assets" \
--icon "assets/images/logo/favicon.ico" \
--hidden-import qfluentwidgets
fi
- name: List outputs (before packaging)
shell: pwsh
run: |
if (Test-Path dist) {
Get-ChildItem -Recurse -File dist | Select-Object FullName, Length | Format-Table -AutoSize
} else {
Write-Host "dist folder not found."
}
- name: Ensure canonical docs in dist
shell: pwsh
run: |
$readme = @("README.md","README.MD","README.txt","README","ReadMe.md") |
Where-Object { Test-Path $_ } | Select-Object -First 1
if ($readme) { Copy-Item $readme "dist/README.md" -Force }
$license = @("LICENSE","LICENSE.md","LICENSE.txt","LICENCE","LICENCE.md","LICENCE.txt") |
Where-Object { Test-Path $_ } | Select-Object -First 1
if ($license) { Copy-Item $license "dist/LICENSE" -Force }
- name: Package release ZIP (version + docs, sanitized)
shell: pwsh
run: |
$verRaw = $env:GITHUB_REF_NAME; if (-not $verRaw) { $verRaw = "dev" }
$ver = ($verRaw -replace '[^0-9A-Za-z._-]', '_')
if (!(Test-Path "dist/DIM-Creator.exe")) {
Get-ChildItem -Recurse -File dist | Select-Object FullName, Length | Format-Table -AutoSize
throw "Executable not found at dist/DIM-Creator.exe"
}
$items = @("dist/DIM-Creator.exe")
if (Test-Path "dist/README.md") { $items += "dist/README.md" }
if (Test-Path "dist/LICENSE") { $items += "dist/LICENSE" }
$zipPath = "dist/DIM-Creator_${ver}_win-x64.zip"
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
Compress-Archive -Path $items -DestinationPath $zipPath -Force
- name: Extract changelog section for tag
id: changelog
shell: bash
run: |
TAG="${GITHUB_REF_NAME:-dev}"
if [ ! -f CHANGELOG.md ]; then
echo "notes=" >> "$GITHUB_OUTPUT"
exit 0
fi
NOTES="$(awk -v tag="$TAG" '
BEGIN{found=0}
/^\s*##[[:space:]]+/ {
if(found){exit}
if ($0 ~ ("^\\s*##[[:space:]]+" tag "([[:space:]]|$)")) {found=1}
}
found{print}
' CHANGELOG.md)"
NOTES="$(printf "%s\n" "$NOTES" | awk 'BEGIN{p=0} {if($0!~"^\\s*$"){p=1} if(p){print}}' | tac | awk 'BEGIN{p=0} {if($0!~"^\\s*$"){p=1} if(p){print}}' | tac)"
{
echo 'notes<<EOF'
echo "$NOTES"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Upload artifact (EXE)
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
with:
name: dim-creator-exe
path: dist/DIM-Creator.exe
if-no-files-found: error
retention-days: 14
- name: Upload artifact (docs-only, optional)
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
with:
name: dim-creator-docs
path: |
dist/README.md
dist/LICENSE
if-no-files-found: ignore
retention-days: 14
- name: Attach to Release with CHANGELOG body (on tags)
if: startsWith(github.ref, 'refs/tags/') && steps.changelog.outputs.notes != ''
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.notes }}
files: |
dist/DIM-Creator.exe
dist/*.zip
- name: Attach to Release (auto notes) (on tags)
if: startsWith(github.ref, 'refs/tags/') && steps.changelog.outputs.notes == ''
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/DIM-Creator.exe
dist/*.zip