-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (123 loc) · 5.06 KB
/
Copy pathrelease.yml
File metadata and controls
142 lines (123 loc) · 5.06 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version tag to build and release (e.g. 1.0.1)'
required: false
default: '1.0.1'
permissions:
contents: write
id-token: write
attestations: write
jobs:
build-attest-release:
name: Build, Attest & Release
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install WiX Toolset v4
shell: pwsh
run: |
dotnet tool install --global wix --version 4.0.6
wix extension add --global WixToolset.Util.wixext/4.0.6
"$HOME/.dotnet/tools" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
wix --version
- name: Resolve Release Version and Tag
id: resolve-version
shell: pwsh
run: |
$ver = "${{ inputs.version }}"
$refName = "${{ github.ref_name }}"
$refType = "${{ github.ref_type }}"
# Only parse the ref_name if this action was triggered explicitly by a genuine git Tag push
if ($refType -eq "tag" -and $refName -match '^v?([0-9]+\.[0-9]+\.[0-9]+.*)') {
$ver = $matches[1]
$tag = "v$ver"
} elseif ($ver) {
$tag = if ($ver.StartsWith('v')) { $ver } else { "v$ver" }
$ver = $tag.TrimStart('v')
} else {
$ver = "1.0.1"
$tag = "v1.0.1"
}
Write-Host "Resolved Version: $ver"
Write-Host "Resolved Tag: $tag"
"version=$ver" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
"tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
- name: Build Standalone MSIs (x64 & arm64)
shell: pwsh
run: |
$ver = "${{ steps.resolve-version.outputs.version }}"
.\packages\msi\build-msi.ps1 -Version $ver -Arch all
- name: Run Integration Test Suite (x64)
shell: pwsh
run: |
$ver = "${{ steps.resolve-version.outputs.version }}"
.\packages\msi\test-msi.ps1 -MsiPath "packages/msi/jvm-windows-$ver-x64.msi"
- name: Build Chocolatey Package (.nupkg)
shell: pwsh
run: |
$ver = "${{ steps.resolve-version.outputs.version }}"
.\packages\choco\build-choco.ps1 -Version $ver
- name: Create Portable Zip Distribution
shell: pwsh
run: |
$ver = "${{ steps.resolve-version.outputs.version }}"
$zipName = "packages/msi/jvm-windows-$ver-portable.zip"
$itemsToCompress = @("jvm.bat", "assets", "LICENSE", "README.md", "uninstall.ps1", "install.ps1") | Where-Object { Test-Path $_ }
Compress-Archive -Path $itemsToCompress -DestinationPath $zipName -Force
Write-Host "Created portable archive: $zipName"
- name: Stage Release Artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Path "dist" -Force | Out-Null
Copy-Item "packages\msi\jvm-windows-*.msi" -Destination "dist\" -Force
Copy-Item "packages\msi\jvm-windows-*.zip" -Destination "dist\" -Force
Copy-Item "packages\choco\jvm-windows.*.nupkg" -Destination "dist\" -Force
# Safely copy only the files that actually exist to prevent step crashes
@("jvm.bat", "install.ps1", "uninstall.ps1", "README.md", "LICENSE") | Where-Object { Test-Path $_ } | ForEach-Object {
Copy-Item $_ -Destination "dist\" -Force
}
Write-Host "Staged release artifacts in dist/:"
Get-ChildItem dist | ForEach-Object { Write-Host " $($_.Name) ($([math]::Round($_.Length / 1KB, 1)) KB)" -ForegroundColor Cyan }
- name: Generate Checksums (SHA256SUMS.txt)
shell: pwsh
run: |
$distFiles = Get-ChildItem -Path "dist" -File | Where-Object { $_.Name -ne "SHA256SUMS.txt" }
$checksumLines = foreach ($item in $distFiles) {
$hash = (Get-FileHash -Path $item.FullName -Algorithm SHA256).Hash.ToLower()
Write-Host "$hash $($item.Name)"
"$hash $($item.Name)"
}
$checksumLines | Out-File -FilePath "dist\SHA256SUMS.txt" -Encoding utf8
- name: Attest Build Provenance
uses: actions/attest-build-provenance@v2
with:
subject-path: "dist/*"
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.resolve-version.outputs.tag }}
target_commitish: ${{ github.sha }}
name: ${{ steps.resolve-version.outputs.tag }}
files: dist/*
generate_release_notes: true
draft: false
prerelease: false
- name: Upload Release Artifacts
uses: actions/upload-artifact@v4
with:
name: jvm-release-artifacts
path: dist/*
if-no-files-found: error