-
Notifications
You must be signed in to change notification settings - Fork 3
123 lines (110 loc) · 4.35 KB
/
Copy pathrelease.yml
File metadata and controls
123 lines (110 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Release (Manual)
# Manual-only fallback. The main CI workflow handles automated releases.
on:
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v6.0.3). Leave empty to use latest tag."
required: false
permissions:
contents: write # create GitHub Release & upload assets
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version
id: version
shell: pwsh
run: |
$tag = "${{ github.event.inputs.tag }}"
if (-not $tag) { $tag = "${{ github.ref_name }}" }
$ver = $tag -replace '^v', ''
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
echo "VER=$ver" >> $env:GITHUB_OUTPUT
Write-Host "Releasing $tag (version $ver)"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run tests
run: python -m pytest tests/ -q
- name: Build portable (onedir)
shell: pwsh
run: |
& packaging/build_onedir.ps1
# ── Create ZIP artifact from the onedir build ──
- name: Package ZIP
id: zip
shell: pwsh
run: |
$ver = "${{ steps.version.outputs.VER }}"
$name = "ElectroChemV6-$ver-win64"
$src = "dist/ElectroChemV6"
$zip = "dist/$name.zip"
Compress-Archive -Path "$src/*" -DestinationPath $zip -Force
echo "ZIP_PATH=$zip" >> $env:GITHUB_OUTPUT
echo "ZIP_NAME=$name.zip" >> $env:GITHUB_OUTPUT
Write-Host "Created $zip"
# ── Build Inno Setup installer (optional — skipped if ISCC not found) ──
- name: Build installer
id: installer
shell: pwsh
continue-on-error: true
run: |
# Sync version into installer.iss
$ver = "${{ steps.version.outputs.VER }}"
$iss = "packaging/installer.iss"
(Get-Content $iss) -replace '#define AppVersion ".*"', "#define AppVersion `"$ver`"" | Set-Content $iss
& packaging/build_installer.ps1
$exe = Get-ChildItem "dist_installer/ElectroChemV6-Setup-*.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($exe) {
echo "EXE_PATH=$($exe.FullName)" >> $env:GITHUB_OUTPUT
echo "EXE_NAME=$($exe.Name)" >> $env:GITHUB_OUTPUT
echo "HAS_INSTALLER=true" >> $env:GITHUB_OUTPUT
} else {
echo "HAS_INSTALLER=false" >> $env:GITHUB_OUTPUT
}
# ── Extract release notes from CHANGELOG ──
- name: Extract release notes
id: notes
shell: pwsh
run: |
$ver = "${{ steps.version.outputs.VER }}"
$content = Get-Content CHANGELOG.md -Raw
# Match the section for this version (between ## <ver> and next ## or EOF)
$pattern = '(?ms)^## ' + [regex]::Escape($ver) + '\s*$(.*?)(?=^## |\z)'
if ($content -match $pattern) {
$body = $Matches[1].Trim()
} else {
# Fallback: auto-generate notes from git commits since last tag
$prevTag = git describe --tags --abbrev=0 HEAD~ 2>$null
if ($prevTag) {
$commits = git log "$prevTag..HEAD" --pretty=format:'- %s' --no-merges 2>$null
} else {
$commits = git log -20 --pretty=format:'- %s' --no-merges 2>$null
}
$body = "## What's Changed`n`n$($commits -join "`n")"
}
# Write to file to avoid shell escaping issues
$body | Out-File -FilePath release_notes.md -Encoding utf8
Write-Host $body
# ── Create GitHub Release ──
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.TAG }}
name: "v${{ steps.version.outputs.VER }}"
body_path: release_notes.md
draft: false
prerelease: false
files: |
${{ steps.zip.outputs.ZIP_PATH }}
${{ steps.installer.outputs.HAS_INSTALLER == 'true' && steps.installer.outputs.EXE_PATH || '' }}