-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (121 loc) · 5.34 KB
/
Copy pathrelease-package.yml
File metadata and controls
137 lines (121 loc) · 5.34 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
name: Build Windows WPF single EXE
on:
workflow_dispatch:
inputs:
version:
description: "Release version without leading v"
required: true
default: "0.1.0"
app:
description: "WPF app to package"
type: choice
required: true
default: "SvPublisher"
options:
- SvPublisher
- IedDiscovery
- IedSimulator
- EngineeringWorkbench
publish_release:
description: "Create or update GitHub Release"
type: boolean
required: true
default: true
prerelease:
description: "Mark GitHub Release as pre-release"
type: boolean
required: true
default: true
draft:
description: "Create GitHub Release as draft"
type: boolean
required: true
default: false
push:
tags:
- "v*"
permissions:
contents: write
jobs:
package:
name: Publish WPF single-file package
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Resolve release inputs
id: release
shell: pwsh
run: |
if ('${{ github.event_name }}' -eq 'workflow_dispatch') {
$version = '${{ github.event.inputs.version }}'.Trim()
if ($version.StartsWith('v')) { $version = $version.Substring(1) }
$publishRelease = '${{ github.event.inputs.publish_release }}'
$preRelease = '${{ github.event.inputs.prerelease }}'
$draft = '${{ github.event.inputs.draft }}'
$app = '${{ github.event.inputs.app }}'
} else {
$version = '${{ github.ref_name }}'.TrimStart('v')
$publishRelease = 'true'
$preRelease = 'true'
$draft = 'false'
$app = 'SvPublisher'
}
if ([string]::IsNullOrWhiteSpace($version)) {
throw 'Release version cannot be empty.'
}
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"tag=v$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"publish_release=$publishRelease" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"prerelease=$preRelease" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"draft=$draft" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"app=$app" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Verify source tree is clean
shell: pwsh
run: ./scripts/verify-source-clean.ps1
- name: Build single-file WPF package
shell: pwsh
run: ./scripts/publish-windows-singlefile.ps1 -Version '${{ steps.release.outputs.version }}' -App '${{ steps.release.outputs.app }}'
- name: Verify release package
shell: pwsh
run: |
$app = '${{ steps.release.outputs.app }}'
$packageName = if ($app -eq 'SvPublisher') { 'ARIEC61850-SvPublisher' } elseif ($app -eq 'IedDiscovery') { 'ARIEC61850-IedDiscovery' } elseif ($app -eq 'IedSimulator') { 'ARIEC61850-IedSimulator' } else { 'ARIEC61850-EngineeringWorkbench' }
./scripts/verify-release-package.ps1 -PackagePath ".artifacts/release/$packageName-v${{ steps.release.outputs.version }}-win-x64-single-exe.zip" -Version '${{ steps.release.outputs.version }}' -App $app
- name: Upload workflow artifacts
uses: actions/upload-artifact@v4
with:
name: ARIEC61850-${{ steps.release.outputs.app }}-v${{ steps.release.outputs.version }}-win-x64-single-exe
path: |
.artifacts/release/*.exe
.artifacts/release/*.zip
.artifacts/release/SHA256SUMS.txt
- name: Create or update GitHub Release
if: steps.release.outputs.publish_release == 'true'
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$tag = '${{ steps.release.outputs.tag }}'
$version = '${{ steps.release.outputs.version }}'
$app = '${{ steps.release.outputs.app }}'
$exe = (Get-ChildItem ".artifacts/release/*.exe" | Select-Object -First 1).FullName
$zip = (Get-ChildItem ".artifacts/release/*.zip" | Select-Object -First 1).FullName
$sha = ".artifacts/release/SHA256SUMS.txt"
$target = '${{ github.sha }}'
$notes = "# ARIEC61850 $app v$version`n`nWindows x64 self-contained single-file WPF package.`n`n## Assets`n`n- $(Split-Path $exe -Leaf)`n- $(Split-Path $zip -Leaf)`n- SHA256SUMS.txt`n`nNpcap is required only for workflows that use live raw Ethernet traffic. Use active publishing only on isolated lab networks."
$notesFile = ".artifacts/release/RELEASE_NOTES_GENERATED.md"
$notes | Set-Content -Path $notesFile -Encoding UTF8
$releaseFlags = @()
if ('${{ steps.release.outputs.prerelease }}' -eq 'true') { $releaseFlags += '--prerelease' }
if ('${{ steps.release.outputs.draft }}' -eq 'true') { $releaseFlags += '--draft' }
gh release view $tag *> $null
if ($LASTEXITCODE -ne 0) {
gh release create $tag $exe $zip $sha --title "ARIEC61850 $app $tag" --notes-file $notesFile --target $target @releaseFlags
} else {
gh release upload $tag $exe $zip $sha --clobber
}