Skip to content

Commit ff9b2df

Browse files
committed
ci: keep windows plugin release asset names stable
1 parent 8820f06 commit ff9b2df

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

.github/workflows/plugin-release.yml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ jobs:
3030
- name: windows-x64
3131
os: windows-latest
3232
target: x86_64-pc-windows-msvc
33-
asset_suffix: windows-x64
33+
asset_suffix: ""
34+
artifact_suffix: windows-x64
3435
- name: macos-arm64
3536
os: macos-26
3637
target: aarch64-apple-darwin
3738
asset_suffix: macos-arm64
39+
artifact_suffix: macos-arm64
3840
runs-on: ${{ matrix.platform.os }}
3941

4042
env:
@@ -97,15 +99,20 @@ jobs:
9799
npx --yes @haloforge/plugin-pack@0.2.13 pack . --release --target $target --out dist/plugin-release
98100
$pkg = Get-ChildItem dist/plugin-release -Filter *.hfpkg | Select-Object -First 1
99101
if (-not $pkg) { throw "No .hfpkg artifact was created." }
100-
$renamedName = "$([System.IO.Path]::GetFileNameWithoutExtension($pkg.Name))-$suffix.hfpkg"
101-
$renamedPath = Join-Path $pkg.DirectoryName $renamedName
102-
Move-Item -Path $pkg.FullName -Destination $renamedPath -Force
102+
if ([string]::IsNullOrWhiteSpace($suffix)) {
103+
$packageName = $pkg.Name
104+
$packagePath = $pkg.FullName
105+
} else {
106+
$packageName = "$([System.IO.Path]::GetFileNameWithoutExtension($pkg.Name))-$suffix.hfpkg"
107+
$packagePath = Join-Path $pkg.DirectoryName $packageName
108+
Move-Item -Path $pkg.FullName -Destination $packagePath -Force
109+
}
103110
Get-ChildItem dist/plugin-release -Filter *.hfpkg.sha256 | Remove-Item -Force
104-
$digest = (Get-FileHash -Algorithm SHA256 -Path $renamedPath).Hash.ToLowerInvariant()
105-
$shaPath = "$renamedPath.sha256"
106-
"$digest $renamedName" | Set-Content -Path $shaPath
107-
"PKG_PATH=$renamedPath" | Out-File -FilePath $env:GITHUB_ENV -Append
108-
"PKG_NAME=$renamedName" | Out-File -FilePath $env:GITHUB_ENV -Append
111+
$digest = (Get-FileHash -Algorithm SHA256 -Path $packagePath).Hash.ToLowerInvariant()
112+
$shaPath = "$packagePath.sha256"
113+
"$digest $packageName" | Set-Content -Path $shaPath
114+
"PKG_PATH=$packagePath" | Out-File -FilePath $env:GITHUB_ENV -Append
115+
"PKG_NAME=$packageName" | Out-File -FilePath $env:GITHUB_ENV -Append
109116
"SHA_PATH=$shaPath" | Out-File -FilePath $env:GITHUB_ENV -Append
110117
"PLUGIN_PLATFORM_SUFFIX=$suffix" | Out-File -FilePath $env:GITHUB_ENV -Append
111118
@@ -160,7 +167,11 @@ jobs:
160167
shell: pwsh
161168
run: |
162169
$artifactUrl = "https://github.com/${{ github.repository }}/releases/download/$env:RELEASE_TAG/$env:PKG_NAME"
163-
$draftPath = "dist/plugin-release/catalog-draft-$env:PLUGIN_PLATFORM_SUFFIX.json"
170+
if ([string]::IsNullOrWhiteSpace($env:PLUGIN_PLATFORM_SUFFIX)) {
171+
$draftPath = "dist/plugin-release/catalog-draft.json"
172+
} else {
173+
$draftPath = "dist/plugin-release/catalog-draft-$env:PLUGIN_PLATFORM_SUFFIX.json"
174+
}
164175
$args = @(
165176
"--yes", "@haloforge/plugin-pack@0.2.13",
166177
"metadata", "$env:PKG_PATH",
@@ -185,10 +196,6 @@ jobs:
185196
throw "Generated catalog draft artifact_url does not match the release tag."
186197
}
187198
"CATALOG_DRAFT_PATH=$draftPath" | Out-File -FilePath $env:GITHUB_ENV -Append
188-
if ($env:PLUGIN_PLATFORM_SUFFIX -eq "windows-x64") {
189-
Copy-Item $draftPath "dist/plugin-release/catalog-draft.json" -Force
190-
"LEGACY_CATALOG_DRAFT_PATH=dist/plugin-release/catalog-draft.json" | Out-File -FilePath $env:GITHUB_ENV -Append
191-
}
192199
193200
- name: Upload metadata to release
194201
shell: pwsh
@@ -219,14 +226,14 @@ jobs:
219226
}
220227
221228
- name: Submit catalog draft
222-
if: env.HF_ADMIN_TOKEN != '' && matrix.platform.asset_suffix == 'windows-x64'
229+
if: env.HF_ADMIN_TOKEN != '' && matrix.platform.name == 'windows-x64'
223230
shell: pwsh
224231
run: npx --yes @haloforge/plugin-pack@0.2.13 submit dist/plugin-release/catalog-draft.json --api-base-url https://admin.haloforge.dev --token-env HF_ADMIN_TOKEN
225232

226233
- name: Upload workflow artifacts
227234
uses: actions/upload-artifact@v4
228235
with:
229-
name: plugin-release-${{ matrix.platform.asset_suffix }}-${{ github.run_id }}
236+
name: plugin-release-${{ matrix.platform.artifact_suffix }}-${{ github.run_id }}
230237
path: |
231238
dist/plugin-release/*.hfpkg
232239
dist/plugin-release/*.hfpkg.sha256

0 commit comments

Comments
 (0)