-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (141 loc) · 6.25 KB
/
release.yml
File metadata and controls
166 lines (141 loc) · 6.25 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
154
155
156
157
158
159
160
161
162
163
164
165
name: Release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
windows-x64:
name: Windows x64 release artifact
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --check
- name: Test
run: cargo test
- name: Check
run: cargo check
- name: Build release
run: cargo build --release
- name: Install Inno Setup
shell: pwsh
run: choco install innosetup --no-progress -y
- name: Compute package metadata
id: meta
shell: pwsh
run: |
$versionLine = Select-String -Path Cargo.toml -Pattern '^version\s*=\s*"([^"]+)"' | Select-Object -First 1
if (-not $versionLine) { throw "Could not find package version in Cargo.toml" }
$version = $versionLine.Matches[0].Groups[1].Value
$packageName = "rmenu-v$version-windows-x64"
"version=$version" >> $env:GITHUB_OUTPUT
"package_name=$packageName" >> $env:GITHUB_OUTPUT
- name: Stage release package
shell: pwsh
run: |
$packageName = "${{ steps.meta.outputs.package_name }}"
$stage = Join-Path "dist" $packageName
New-Item -ItemType Directory -Force $stage | Out-Null
New-Item -ItemType Directory -Force (Join-Path $stage "module-examples") | Out-Null
Copy-Item "target\release\rmenu.exe" $stage
Copy-Item "target\release\rmenu-daemon.exe" $stage
Copy-Item "target\release\rmenu-module-host.exe" $stage
Copy-Item "target\release\rmenu-updater.exe" $stage
Copy-Item "config_example.ini" $stage
$docs = @(
"README.md",
"INSTALL.md",
"CHANGELOG.md",
"CORE_FREEZE_V1.md",
"MODULES_QUICKSTART.md",
"MODULES_AUTHORING_GUIDE.md",
"MODULES_OPERATIONS_GUIDE.md",
"MODULES_API_SPEC_V1.md",
"RMOD_SPEC_V1.md",
"MANIFEST_SPEC_V1.md",
"CTX_ACTIONS_SPEC_V1.md",
"PROVIDER_EXECUTION_POLICY.md",
"ERROR_ISOLATION_POLICY.md",
"MODULES_CAPABILITIES_MATRIX.md"
)
foreach ($doc in $docs) {
if (Test-Path $doc) {
Copy-Item $doc $stage
}
}
New-Item -ItemType Directory -Force (Join-Path $stage "docs") | Out-Null
if (Test-Path "docs\companion-and-rmods-workflow.md") {
Copy-Item "docs\companion-and-rmods-workflow.md" (Join-Path $stage "docs\companion-and-rmods-workflow.md")
}
if (Test-Path "docs\rmods-registry.md") {
Copy-Item "docs\rmods-registry.md" (Join-Path $stage "docs\rmods-registry.md")
}
if (Test-Path "docs\update-workflow.md") {
Copy-Item "docs\update-workflow.md" (Join-Path $stage "docs\update-workflow.md")
}
if (Test-Path "modules\calculator.rmod") {
Copy-Item "modules\calculator.rmod" (Join-Path $stage "module-examples\calculator.rmod")
}
if (Test-Path "modules\local-scripts.rmod") {
Copy-Item "modules\local-scripts.rmod" (Join-Path $stage "module-examples\local-scripts.rmod")
}
if (Test-Path "modules\examples\shortcuts.example.rmod") {
Copy-Item "modules\examples\shortcuts.example.rmod" (Join-Path $stage "module-examples\shortcuts.example.rmod")
}
if (Test-Path "modules\timer") {
Copy-Item "modules\timer" (Join-Path $stage "module-examples\timer") -Recurse -Force
}
# Do not copy modules/shortcuts.rmod as an active default module; it may contain local user paths.
# Module examples are packaged under module-examples/ and must be copied into modules/ by the user.
- name: Generate package checksums
shell: pwsh
run: |
$packageName = "${{ steps.meta.outputs.package_name }}"
$stage = Join-Path "dist" $packageName
$checksumPath = Join-Path $stage "checksums.txt"
Get-ChildItem $stage -File -Recurse |
Where-Object { $_.Name -ne "checksums.txt" } |
Sort-Object FullName |
ForEach-Object {
$hash = Get-FileHash $_.FullName -Algorithm SHA256
$relative = Resolve-Path -Relative $_.FullName
"$($hash.Hash) $relative"
} | Set-Content -Path $checksumPath -Encoding utf8
- name: Create zip artifact
shell: pwsh
run: |
$packageName = "${{ steps.meta.outputs.package_name }}"
$zipPath = Join-Path "dist" "$packageName.zip"
if (Test-Path $zipPath) { Remove-Item $zipPath }
Compress-Archive -Path (Join-Path "dist" $packageName) -DestinationPath $zipPath
- name: Build installer artifact
shell: pwsh
run: |
powershell -NoProfile -ExecutionPolicy Bypass -File installer\build-installer.ps1 -Version "${{ steps.meta.outputs.version }}" -SkipBuild -Force
- name: Generate release checksums
shell: pwsh
run: |
$packageName = "${{ steps.meta.outputs.package_name }}"
$version = "${{ steps.meta.outputs.version }}"
$zipPath = Join-Path "dist" "$packageName.zip"
$installerPath = Join-Path "dist" "installers\rmenu-setup-v$version.exe"
$lines = New-Object System.Collections.Generic.List[string]
$zipHash = Get-FileHash $zipPath -Algorithm SHA256
$lines.Add("$($zipHash.Hash) $packageName.zip")
$installerHash = Get-FileHash $installerPath -Algorithm SHA256
$lines.Add("$($installerHash.Hash) installers/rmenu-setup-v$version.exe")
$lines | Set-Content -Path (Join-Path "dist" "SHA256SUMS.txt") -Encoding utf8
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.package_name }}
path: |
dist/${{ steps.meta.outputs.package_name }}.zip
dist/installers/rmenu-setup-v${{ steps.meta.outputs.version }}.exe
dist/SHA256SUMS.txt
if-no-files-found: error