-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (125 loc) · 6.24 KB
/
Copy pathrelease-installer.yml
File metadata and controls
153 lines (125 loc) · 6.24 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
name: Build and Release (Deprecated)
on:
workflow_dispatch:
# DEPRECATED: This workflow has been merged into release.yml
# release.yml handles both installers and MSIX packages in a unified release process
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
shell: bash
- name: Extract latest changelog
id: changelog
run: |
$content = Get-Content CHANGELOG.md -Raw
$pattern = '(?s)(## \[.*?\].*?)(?=\n---|\Z)'
if ($content -match $pattern) {
$latest = $matches[1].Trim()
echo "CONTENT<<EOF" >> $env:GITHUB_OUTPUT
echo "$latest" >> $env:GITHUB_OUTPUT
echo "EOF" >> $env:GITHUB_OUTPUT
}
shell: pwsh
- name: Restore
run: dotnet restore DevTools.csproj
- name: Publish win-x86
run: dotnet publish DevTools.csproj -c Release -r win-x86 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=false -o publish\win-x86
- name: Publish win-x64
run: dotnet publish DevTools.csproj -c Release -r win-x64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=false -o publish\win-x64
- name: Publish win-arm64
run: dotnet publish DevTools.csproj -c Release -r win-arm64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=false -o publish\win-arm64
- name: Decode signing certificate
if: env.CERTIFICATE_BASE64 != ''
env:
CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }}
run: |
$certPath = Join-Path $env:RUNNER_TEMP "cert.pfx"
[System.IO.File]::WriteAllBytes($certPath, [System.Convert]::FromBase64String($env:CERTIFICATE_BASE64))
echo "CERT_PATH=$certPath" >> $env:GITHUB_ENV
shell: pwsh
- name: Sign executables
if: env.CERT_PATH != ''
env:
CERT_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
run: |
$signtool = Get-ChildItem -Path "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\signtool.exe" | Sort-Object { $_.VersionInfo.FileVersion } -Descending | Select-Object -First 1
$exeFiles = @(
"publish\win-x86\DevTools.exe",
"publish\win-x64\DevTools.exe",
"publish\win-arm64\DevTools.exe"
)
foreach ($exe in $exeFiles) {
Write-Host "Signing: $exe"
& $signtool.FullName sign /f $env:CERT_PATH /p $env:CERT_PASSWORD /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $exe
if ($LASTEXITCODE -ne 0) {
Write-Host "Warning: Failed to sign $exe"
}
}
shell: pwsh
- name: Install Inno Setup
run: |
choco install innosetup -y
shell: pwsh
- name: Download Chinese language file for Inno Setup
run: |
$innoPath = "${env:ProgramFiles(x86)}\Inno Setup 6"
$langPath = Join-Path $innoPath "Languages"
$chineseFile = Join-Path $langPath "ChineseSimplified.isl"
if (-not (Test-Path $chineseFile)) {
Write-Host "Downloading Chinese Simplified language file..."
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile $chineseFile
}
shell: pwsh
- name: Build Installers
run: |
New-Item -ItemType Directory -Force -Path installer
$version = "${{ steps.get_version.outputs.VERSION }}"
$rootDir = $PWD.Path
Write-Host "Building x64 installer..."
& iscc "$rootDir\scripts\installer.iss" /DAppVersion="$version" /DArchitecture="x64" /DOutputDir="$rootDir\installer" /DSourceDir="$rootDir\publish\win-x64"
Write-Host "Building x86 installer..."
& iscc "$rootDir\scripts\installer.iss" /DAppVersion="$version" /DArchitecture="x86" /DOutputDir="$rootDir\installer" /DSourceDir="$rootDir\publish\win-x86"
Write-Host "Building arm64 installer..."
& iscc "$rootDir\scripts\installer.iss" /DAppVersion="$version" /DArchitecture="arm64" /DOutputDir="$rootDir\installer" /DSourceDir="$rootDir\publish\win-arm64"
shell: pwsh
- name: Sign installers
if: env.CERT_PATH != ''
env:
CERT_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
run: |
$signtool = Get-ChildItem -Path "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\signtool.exe" | Sort-Object { $_.VersionInfo.FileVersion } -Descending | Select-Object -First 1
$installerFiles = Get-ChildItem -Path "installer\*.exe"
foreach ($installer in $installerFiles) {
Write-Host "Signing: $($installer.FullName)"
& $signtool.FullName sign /f $env:CERT_PATH /p $env:CERT_PASSWORD /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $installer.FullName
if ($LASTEXITCODE -ne 0) {
Write-Host "Warning: Failed to sign $($installer.FullName)"
}
}
shell: pwsh
- name: Rename executables
run: |
Rename-Item -Path publish\win-x86\DevTools.exe -NewName DevTools-win-x86.exe
Rename-Item -Path publish\win-x64\DevTools.exe -NewName DevTools-win-x64.exe
Rename-Item -Path publish\win-arm64\DevTools.exe -NewName DevTools-win-arm64.exe
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: DevTools v${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.changelog.outputs.CONTENT }}
files: |
publish/win-x86/DevTools-win-x86.exe
publish/win-x64/DevTools-win-x64.exe
publish/win-arm64/DevTools-win-arm64.exe
installer/*.exe
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}