-
-
Notifications
You must be signed in to change notification settings - Fork 7
132 lines (111 loc) · 5.01 KB
/
build.yml
File metadata and controls
132 lines (111 loc) · 5.01 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
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
arch: x64
- os: windows-latest
rid: win-x86
arch: x86
- os: windows-11-arm
rid: win-arm64
arch: arm64
runs-on: ${{ matrix.os }}
name: Windows ${{ matrix.arch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore src/OddSnap/OddSnap.csproj -r ${{ matrix.rid }}
- name: Test
if: matrix.rid == 'win-x64'
run: dotnet test tests/OddSnap.Tests/OddSnap.Tests.csproj -c Release
- name: Install Velopack CLI
shell: pwsh
run: dotnet tool install -g vpk --version 0.0.1298
- name: Prepare code signing
if: ${{ secrets.WINDOWS_SIGN_PFX_BASE64 != '' && secrets.WINDOWS_SIGN_PFX_PASSWORD != '' }}
id: signing
shell: pwsh
env:
WINDOWS_SIGN_PFX_BASE64: ${{ secrets.WINDOWS_SIGN_PFX_BASE64 }}
WINDOWS_SIGN_PFX_PASSWORD: ${{ secrets.WINDOWS_SIGN_PFX_PASSWORD }}
run: |
$pfxPath = Join-Path $env:RUNNER_TEMP "oddsnap-signing-cert.pfx"
[System.IO.File]::WriteAllBytes($pfxPath, [Convert]::FromBase64String($env:WINDOWS_SIGN_PFX_BASE64))
Add-Content -Path $env:GITHUB_OUTPUT -Value "pfx_path=$pfxPath" -Encoding utf8
Add-Content -Path $env:GITHUB_OUTPUT -Value "sign_params=/fd SHA256 /f `"$pfxPath`" /p `"$env:WINDOWS_SIGN_PFX_PASSWORD`" /tr `"http://timestamp.digicert.com`" /td SHA256" -Encoding utf8
- name: Publish
run: >
dotnet publish src/OddSnap/OddSnap.csproj
-c Release
-r ${{ matrix.rid }}
--self-contained true
-p:PublishSingleFile=true
-o publish
- name: Read version
id: version
shell: pwsh
run: |
[xml]$csproj = Get-Content src/OddSnap/OddSnap.csproj -Raw
$version = ($csproj.Project.PropertyGroup.Version | Select-Object -First 1).Trim()
Add-Content -Path $env:GITHUB_OUTPUT -Value "version=$version" -Encoding utf8
- name: Build Velopack package
shell: pwsh
run: |
$env:PATH += ";$env:USERPROFILE\.dotnet\tools"
$outDir = Join-Path $PWD "vpk-${{ matrix.rid }}"
New-Item -ItemType Directory -Path $outDir -Force | Out-Null
vpk pack `
--packId JasperDevs.OddSnap `
--packVersion "${{ steps.version.outputs.version }}" `
--packDir publish `
--mainExe OddSnap.exe `
--packTitle OddSnap `
--packAuthors jasperdevs `
--icon src/OddSnap/oddsnap.ico `
--channel "${{ matrix.rid }}" `
--runtime "${{ matrix.rid }}" `
--releaseNotes "docs/CHANGELOG.md" `
${{ steps.signing.outputs.sign_params != '' && format('--signParams "{0}"', steps.signing.outputs.sign_params) || '' }} `
--outputDir $outDir
$rid = "${{ matrix.rid }}"
$version = "${{ steps.version.outputs.version }}"
$setupName = "OddSnap-Setup-$rid.exe"
$portableName = "OddSnap-Portable-$rid.zip"
$fullName = "OddSnap-Update-$version-$rid-full.nupkg"
$releasesName = "OddSnap-RELEASES-$rid"
$releaseJsonName = "OddSnap-releases-$rid.json"
$assetsJsonName = "OddSnap-assets-$rid.json"
$setup = Get-ChildItem $outDir -Filter '*-Setup.exe' | Select-Object -First 1
if ($null -ne $setup) { Rename-Item -LiteralPath $setup.FullName -NewName $setupName }
$portable = Get-ChildItem $outDir -Filter '*-Portable.zip' | Select-Object -First 1
if ($null -ne $portable) { Rename-Item -LiteralPath $portable.FullName -NewName $portableName }
$full = Get-ChildItem $outDir -Filter '*-full.nupkg' | Select-Object -First 1
if ($null -ne $full) { Rename-Item -LiteralPath $full.FullName -NewName $fullName }
$releases = Get-ChildItem $outDir -Filter 'RELEASES-*' | Select-Object -First 1
if ($null -ne $releases) { Rename-Item -LiteralPath $releases.FullName -NewName $releasesName }
$releaseJson = Get-ChildItem $outDir -Filter 'releases.*.json' | Select-Object -First 1
if ($null -ne $releaseJson) { Rename-Item -LiteralPath $releaseJson.FullName -NewName $releaseJsonName }
$assetsJson = Get-ChildItem $outDir -Filter 'assets.*.json' | Select-Object -First 1
if ($null -ne $assetsJson) { Rename-Item -LiteralPath $assetsJson.FullName -NewName $assetsJsonName }
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Velopack-${{ matrix.rid }}
path: vpk-${{ matrix.rid }}/
if-no-files-found: error