-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (131 loc) · 4.95 KB
/
Copy pathrelease.yml
File metadata and controls
144 lines (131 loc) · 4.95 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
cache: maven
- name: Verify release version
shell: pwsh
run: |
[xml]$pom = Get-Content -Raw pom.xml
$version = [string]$pom.project.version
if ([string]::IsNullOrWhiteSpace($version)) {
throw "Project version is missing from pom.xml"
}
if ($version.EndsWith("-SNAPSHOT")) {
throw "Release version cannot end with -SNAPSHOT: $version"
}
if ("${{ github.event_name }}" -eq "push") {
$expectedTag = "v$version"
if ($env:GITHUB_REF_NAME -ne $expectedTag) {
throw "Tag $($env:GITHUB_REF_NAME) does not match pom.xml version $expectedTag"
}
}
"JPI_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"Validated JPI version $version" | Add-Content $env:GITHUB_STEP_SUMMARY
- name: Run unit and attach integration tests
run: mvn --batch-mode --no-transfer-progress clean verify
- name: Validate packaged application
shell: pwsh
run: |
$jar = "target/jpi.jar"
if (-not (Test-Path $jar)) {
throw "Release JAR was not produced: $jar"
}
$entries = @(& jar tf $jar)
$required = @(
"META-INF/MANIFEST.MF",
"dev/whitedev/jpi/JpiApplication.class",
"dev/whitedev/jpi/agent/InspectorAgent.class",
"dev/whitedev/jpi/agent/TraceRuntime.class",
"dev/whitedev/jpi/ui/LiveTracerPanel.class",
"org/objectweb/asm/tree/ClassNode.class",
"org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.class",
"javax/annotation/Nullable.class",
"assets/cfr-0.152.jar",
"assets/vineflower-1.12.0.jar",
"assets/procyon-compilertools-0.6.0.jar",
"assets/procyon-core-0.6.0.jar"
)
foreach ($entry in $required) {
if ($entries -notcontains $entry) {
throw "Release JAR is missing $entry"
}
}
"Validated shaded JAR contents" | Add-Content $env:GITHUB_STEP_SUMMARY
- name: Stage release artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Force dist | Out-Null
$name = "jpi-v$($env:JPI_VERSION).jar"
$artifact = Join-Path "dist" $name
Copy-Item "target/jpi.jar" $artifact
$hash = (Get-FileHash $artifact -Algorithm SHA256).Hash.ToLowerInvariant()
"$hash $name" | Set-Content -Encoding ascii "$artifact.sha256"
"Artifact: $name" | Add-Content $env:GITHUB_STEP_SUMMARY
"SHA-256: $hash" | Add-Content $env:GITHUB_STEP_SUMMARY
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: jpi-v${{ env.JPI_VERSION }}-windows
path: dist/*
if-no-files-found: error
retention-days: 30
- name: Build changelog from commits
if: github.event_name == 'push'
shell: pwsh
run: |
$currentTag = $env:GITHUB_REF_NAME
$previousTag = git tag --merged $currentTag --sort=-version:refname |
Where-Object { $_ -ne $currentTag } |
Select-Object -First 1
$range = if ($previousTag) { "$previousTag..$currentTag" } else { $currentTag }
$commits = @(git log --reverse --pretty=format:"- %s (%h)" $range)
$lines = @(
"## Changelog",
""
)
if ($previousTag) {
$lines += "Changes since ${previousTag}:"
} else {
$lines += "Changes included in the first tagged release:"
}
$lines += ""
if ($commits.Count -eq 0) {
$lines += "- No commit messages found"
} else {
$lines += $commits
}
$lines += ""
$notesPath = Join-Path $env:RUNNER_TEMP "release-notes.md"
[IO.File]::WriteAllLines($notesPath, $lines, [Text.UTF8Encoding]::new($false))
"RELEASE_NOTES_PATH=$notesPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Create GitHub release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
name: JPI ${{ github.ref_name }}
body_path: ${{ env.RELEASE_NOTES_PATH }}
files: dist/*
fail_on_unmatched_files: true
prerelease: ${{ contains(github.ref_name, '-') }}