-
Notifications
You must be signed in to change notification settings - Fork 3
105 lines (87 loc) · 3.69 KB
/
release.yml
File metadata and controls
105 lines (87 loc) · 3.69 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
name: Build Installer
on:
workflow_dispatch:
jobs:
build:
runs-on: windows-2022
steps:
- name: Checkout repo with LFS
uses: actions/checkout@v6
- name: Run update script
id: update
shell: pwsh
run: |
$resources = Join-Path $PWD "resources"
if (-not (Test-Path $resources)) { New-Item -ItemType Directory -Path $resources | Out-Null }
$tmpdir = Join-Path $env:TEMP ("ospanel_dl_" + (Get-Random))
if (Test-Path $tmpdir) { Remove-Item $tmpdir -Recurse -Force }
New-Item -ItemType Directory -Path $tmpdir | Out-Null
function Update-File($name, $url) {
Write-Host "=== Checking $name ==="
$target = Join-Path $resources $name
$tmpfile = Join-Path $tmpdir $name
if (Test-Path $target) {
Invoke-WebRequest -Uri $url -OutFile $tmpfile -UseBasicParsing
$oldhash = (Get-FileHash -Algorithm SHA256 $target).Hash
$newhash = (Get-FileHash -Algorithm SHA256 $tmpfile).Hash
Write-Host "Old hash: $oldhash"
Write-Host "New hash: $newhash"
if ($oldhash -ieq $newhash) {
Write-Host "Hashes match - keeping existing file."
Remove-Item $tmpfile
return $false
} else {
Write-Host "Hashes differ - replacing file."
Move-Item -Force $tmpfile $target
return $true
}
} else {
Write-Host "File not found - downloading..."
Invoke-WebRequest -Uri $url -OutFile $target -UseBasicParsing
return $true
}
}
$updated = $false
$updated = (Update-File "VC_redist.x86.exe" "https://aka.ms/vs/17/release/VC_redist.x86.exe") -or $updated
$updated = (Update-File "VC_redist.x64.exe" "https://aka.ms/vs/17/release/VC_redist.x64.exe") -or $updated
Remove-Item $tmpdir -Recurse -Force
Write-Host "=== Done! Files saved to $resources ==="
if ($updated) {
"updated=1" >> $env:GITHUB_OUTPUT
} else {
"updated=0" >> $env:GITHUB_OUTPUT
}
- name: Stop if nothing updated
if: steps.update.outputs.updated == '0'
run: |
echo "No files were updated. Release will not be created."
exit 0
- name: Remove old Inno Setup (if exists)
run: |
if (Test-Path "C:\Program Files (x86)\Inno Setup 6") {
Remove-Item "C:\Program Files (x86)\Inno Setup 6" -Recurse -Force
}
- name: Download Inno Setup
run: |
Invoke-WebRequest -Uri "https://jrsoftware.org/download.php/is.exe" -OutFile "innosetup.exe"
Start-Process innosetup.exe -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait
- name: Compile installer
run: |
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" Setup.iss
- name: Generate release tag
id: gen_tag
shell: pwsh
run: |
$now = Get-Date -Format "yy.M.d.H"
echo "tag=v$now" >> $env:GITHUB_OUTPUT
- name: Create GitHub Release
if: steps.update.outputs.updated == '1'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.gen_tag.outputs.tag }}
body: "Updated Microsoft Visual C++ Redistributable packages (x86 and x64)"
files: release/*.exe
- name: Clean up release folder
if: steps.update.outputs.updated == '1'
run: |
Remove-Item release -Recurse -Force