-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (134 loc) · 5.75 KB
/
Copy pathrelease.yml
File metadata and controls
154 lines (134 loc) · 5.75 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Release
# Triggered when a version tag is pushed:
# git tag v1.2.0 && git push origin v1.2.0
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-*"
permissions:
contents: write
jobs:
release:
name: Build & Publish Release
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse version from tag
id: version
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$ver = $tag -replace '^v', ''
Write-Host "Tag: $tag Version: $ver"
"tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"version=$ver" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build PowerMeter.exe (Release x64)
run: |
msbuild PowerMeter.vcxproj `
/p:Configuration=Release `
/p:Platform=x64 `
/p:PlatformToolset=v143 `
/v:minimal `
/nologo
# SC headers are bundled in ACSIL/sc_stub/ACS_Source/ — no download needed.
- name: Build PowerMeterFeed_64.dll (Release x64)
run: |
msbuild PowerMeterFeed.vcxproj `
/p:Configuration=Release `
/p:Platform=x64 `
/p:PlatformToolset=v143 `
/p:SierraChartRoot="${{ github.workspace }}\ACSIL\sc_stub" `
/v:minimal `
/nologo
working-directory: ACSIL
- name: Build PowerMeterFeedJS_64.dll (Release x64)
run: |
msbuild PowerMeterFeedJS.vcxproj `
/p:Configuration=Release `
/p:Platform=x64 `
/p:PlatformToolset=v143 `
/p:SierraChartRoot="${{ github.workspace }}\ACSIL\sc_stub" `
/v:minimal `
/nologo
working-directory: ACSIL
- name: Smoke test - all binaries valid AMD64 PE
id: smoketest
shell: pwsh
run: |
$exeCandidates = @("x64\Release\PowerMeter.exe","PowerMeter\x64\Release\PowerMeter.exe")
$exe = $exeCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $exe) { Write-Error "PowerMeter.exe not found"; exit 1 }
$stub = "${{ github.workspace }}\ACSIL\sc_stub"
$binaries = @(
$exe,
"$stub\Data\PowerMeterFeed_64.dll",
"$stub\Data\PowerMeterFeedJS_64.dll"
)
foreach ($bin in $binaries) {
if (-not (Test-Path $bin)) { Write-Error "Not found: $bin"; exit 1 }
$bytes = [System.IO.File]::ReadAllBytes($bin)
if ($bytes[0] -ne 0x4D -or $bytes[1] -ne 0x5A) { Write-Error "Bad MZ: $bin"; exit 1 }
$peOffset = [BitConverter]::ToInt32($bytes, 0x3C)
$machine = [BitConverter]::ToUInt16($bytes, $peOffset + 4)
if ($machine -ne 0x8664) { Write-Error ("Not AMD64: $bin"); exit 1 }
Write-Host ("PASS: $(Split-Path $bin -Leaf) ({0:N0} bytes)" -f (Get-Item $bin).Length)
}
"exe_path=$exe" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Assemble distribution ZIP
id: package
shell: pwsh
run: |
$ver = "${{ steps.version.outputs.version }}"
$stub = "${{ github.workspace }}\ACSIL\sc_stub"
$exe = "${{ steps.smoketest.outputs.exe_path }}"
$distDir = "dist\PowerMeter_v$ver"
$zipPath = "dist\PowerMeter_v$ver.zip"
foreach ($d in @($distDir,"$distDir\ACSIL","$distDir\ACSIL\src","$distDir\docs")) {
New-Item -ItemType Directory -Force $d | Out-Null
}
Copy-Item $exe "$distDir\PowerMeter.exe"
Copy-Item "$stub\Data\PowerMeterFeed_64.dll" "$distDir\ACSIL\"
Copy-Item "$stub\Data\PowerMeterFeedJS_64.dll" "$distDir\ACSIL\"
Copy-Item "PowerMeterFeed.cpp" "$distDir\ACSIL\src\"
Copy-Item "PowerMeterFeedJS.cpp" "$distDir\ACSIL\src\"
Copy-Item "build_acsil.ps1" "$distDir\ACSIL\"
Copy-Item "docs\README.md" "$distDir\README.md"
Copy-Item "docs\ALGORITHM_NOTES.md" "$distDir\docs\"
Compress-Archive -Path "$distDir\*" -DestinationPath $zipPath -Force
Write-Host "Package: $zipPath"
"zip_path=$zipPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Generate release notes
shell: pwsh
run: |
$tag = "${{ steps.version.outputs.tag }}"
$prevTag = git describe --tags --abbrev=0 "$tag^" 2>$null
if ($prevTag) {
$log = git log "$prevTag..$tag" --pretty=format:"- %s" --no-merges
} else {
$log = git log $tag --pretty=format:"- %s" --no-merges | Select-Object -First 20
}
@"
## What's changed
$($log -join "`n")
## Installation
1. Extract the ZIP.
2. Copy ``ACSIL\PowerMeterFeed_64.dll`` (or ``PowerMeterFeedJS_64.dll``) to ``C:\SierraChart\Data\``.
3. Run ``PowerMeter.exe``.
4. Load the study: **Analysis -> Add Custom Study -> PowerMeter Feed**.
See ``README.md`` inside the ZIP for full instructions.
"@ | Out-File -FilePath release_notes.md -Encoding utf8
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: PowerMeter ${{ steps.version.outputs.tag }}
body_path: release_notes.md
draft: false
prerelease: ${{ contains(steps.version.outputs.tag, '-') }}
files: ${{ steps.package.outputs.zip_path }}