-
Notifications
You must be signed in to change notification settings - Fork 17
192 lines (161 loc) · 7.1 KB
/
pre-release.yml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Pre-Release
on:
workflow_dispatch:
jobs:
# Reuse the build job from build.yml
Compile:
name: Compile
uses: ./.github/workflows/build.yml
with:
output_dependencies: true
create_package: true
use_preview_version: true
channel: "Preview"
secrets:
pfx_base64_encoded: ${{ secrets.PFX_BASE64_ENCODED }}
Pack:
name: Pack .msixbundle
needs: Compile
runs-on: windows-latest
env:
SigningKey_Path: SigningKey.pfx
Artifacts_Path: .artifacts
steps:
- name: Download .msix from artifacts
uses: actions/download-artifact@v4
with:
pattern: msix-*
merge-multiple: true
path: ${{ env.Artifacts_Path }}
- name: Get Package Information
id: get_package_info
run: |
# Get the name of the .msix file
$file = Get-Item -Path "${{ env.Artifacts_Path }}\*.msix"
if ($file -is [array]) {
$file = $file[0]
}
# Extract the package name with version number
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.FullName)
$bundleFileName = $fileName -replace '^(.*?Natsurainko\.FluentLauncher)_(\d+\.\d+\.\d+\.\d+)(_x64|_arm64)$', '$1_$2.msixbundle'
$version = $fileName -replace '^(.*?Natsurainko\.FluentLauncher)_(\d+\.\d+\.\d+\.\d+)(_x64|_arm64)$', '$2'
echo "::set-output name=bundleFileName::$bundleFileName"
echo "::set-output name=version::$version"
- name: Create .msixbundle
run: |
# Get makeappx.exe
$makeappx = Get-Item -Path "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\makeappx.exe"
if ($makeappx -is [array]) {
$makeappx = $makeappx[0]
}
# Create the .msixbundle using makeappx.exe
& $makeappx.FullName bundle /d "${{ env.Artifacts_Path }}" /p "${{ steps.get_package_info.outputs.bundleFileName }}" /bv "${{ steps.get_package_info.outputs.version }}"
# Decode the base 64 encoded pfx and sign the package
- name: Sign .msixbundle
run: |
# Get signtool.exe
$signtool = Get-Item -Path "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe"
if ($signtool -is [array]) {
$signtool = $signtool[0]
}
# Sign .msixbundle
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.PFX_BASE64_ENCODED }}")
[IO.File]::WriteAllBytes("${{ env.SigningKey_Path }}", $pfx_cert_byte)
& $signtool sign /f "${{ env.SigningKey_Path }}" /fd SHA256 /td SHA256 "${{ steps.get_package_info.outputs.bundleFileName }}"
rm "${{ env.SigningKey_Path }}"
- name: Upload .msixbundle to artifacts
uses: actions/upload-artifact@v4
with:
name: .msixbundle
path: ${{ steps.get_package_info.outputs.bundleFileName }}
Release:
runs-on: windows-latest
name: Release
needs: [Compile, Pack]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Config User
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub-actions[bot]"
- name: Download x64 msixbundle
uses: actions/download-artifact@v4
with:
name: msix-x64
path: "${{ github.workspace }}\\updatePackage-x64"
- name: Download x64 dependencies
uses: actions/download-artifact@v4
with:
name: dependencies-x64
path: "${{ github.workspace }}\\updatePackage-x64\\dependencies"
- name: Create x64 update package
run: |
cd "${{ github.workspace }}\\updatePackage-x64\\dependencies"
tar -xf dependencies-x64.zip -C ./
Remove-Item dependencies-x64.zip
cd "${{ github.workspace }}\\updatePackage-x64"
Rename-Item *.msix msix-x64.msix
Compress-Archive -Path .\\* -DestinationPath ..\\updatePackage-x64.zip
- name: Download arm64 msixbundle
uses: actions/download-artifact@v4
with:
name: msix-arm64
path: "${{ github.workspace }}\\updatePackage-arm64"
- name: Download arm64 dependencies
uses: actions/download-artifact@v4
with:
name: dependencies-arm64
path: "${{ github.workspace }}\\updatePackage-arm64\\dependencies"
- name: Create arm64 update package
run: |
cd "${{ github.workspace }}\\updatePackage-arm64\\dependencies"
tar -xf dependencies-arm64.zip -C ./
Remove-Item dependencies-arm64.zip
cd "${{ github.workspace }}\\updatePackage-arm64"
Rename-Item *.msix msix-arm64.msix
Compress-Archive -Path .\\* -DestinationPath ..\\updatePackage-arm64.zip
- name: Download msixbundle
uses: actions/download-artifact@v4
with:
name: .msixbundle
path: "${{ github.workspace }}\\${{env.Artifacts_Path}}"
- name: Rename msixbundle
run: |
cd "${{ github.workspace }}"
Rename-Item *.msixbundle package.msixbundle
- name: Download Artifacts (dependencies)
uses: actions/download-artifact@v4
with:
pattern: dependencies-*
path: "${{ github.workspace }}\\${{env.Artifacts_Path}}"
- name: Create Release Information
run: |
[xml]$xmlContent = Get-Content -Path "Natsurainko.FluentLauncher\Package-Preview.appxmanifest"
$version = $xmlContent.Package.Identity.Version
$commit = $env:GITHUB_SHA.Substring(0, 7)
$url = "https://github.com/Xcube-Studio/FluentLauncher.PreviewChannel.PackageInstaller/releases/download/v0.0.1/PackageInstaller-x64.exe"
$installerPath = "PackageInstaller-x64.exe"
$ErrorActionPreference = "Stop"
$ErrorVariable = "DownloadError"
try {
Invoke-WebRequest -Uri $url -OutFile $installerPath -ErrorAction Stop -ErrorVariable DownloadError
Write-Output "File downloaded successfully to $installerPath"
} catch {
Write-Error "Download failed: $($DownloadError[0])"
exit 1
}
$json = & .\$installerPath generateReleaseMarkdown --markdownPath "${{ github.workspace }}\body.md" --updatePackageFiles "${{ github.workspace }}\updatePackage-x64.zip" "${{ github.workspace }}\updatePackage-arm64.zip" --stableVersion $version --commit $commit
$jsonObject = $json | ConvertFrom-Json
$currentPreviewVersion = $jsonObject.currentPreviewVersion
echo "currentPreviewVersion=$currentPreviewVersion" >> $env:GITHUB_ENV
echo "commit=$commit" >> $env:GITHUB_ENV
- name: Create Release
uses: ncipollo/[email protected]
with:
artifacts: "${{ github.workspace }}\\updatePackage-*.zip,${{ github.workspace }}\\package.msixbundle"
allowUpdates: true
generateReleaseNotes: true
prerelease: true
tag: "pre-release-v${{ env.currentPreviewVersion }}-${{ env.commit }}"
bodyFile: "${{ github.workspace }}\\body.md"