-
-
Notifications
You must be signed in to change notification settings - Fork 0
226 lines (187 loc) · 6.58 KB
/
Copy pathrelease.yml
File metadata and controls
226 lines (187 loc) · 6.58 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: Release
on:
push:
tags:
- "v*.*.*"
- "v*.*.*-*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
build:
name: Build (${{ matrix.target }})
environment: release
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar
- runs-on: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
archive: tar
- runs-on: windows-2025
target: x86_64-pc-windows-msvc
archive: zip
- runs-on: windows-11-arm
target: aarch64-pc-windows-msvc
archive: zip
- runs-on: macos-15-intel
target: x86_64-apple-darwin
archive: tar
- runs-on: macos-15
target: aarch64-apple-darwin
archive: tar
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.JOLTERBOT_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Build release
run: make build-release ARGS="--target ${{ matrix.target }}"
- name: Package Unix artifact
if: matrix.archive == 'tar'
shell: bash
run: |
set -euo pipefail
name="jolter-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir -p "dist/$name"
cp "target/${{ matrix.target }}/release/jolter" \
"target/${{ matrix.target }}/release/jolter-shim" \
README.md LICENSE "dist/$name/"
test -x "dist/$name/jolter"
test -x "dist/$name/jolter-shim"
tar -C dist -czf "dist/$name.tar.gz" "$name"
sha256sum "dist/$name.tar.gz" > "dist/$name.tar.gz.sha256"
- name: Code Sign Windows Binaries
if: matrix.archive == 'zip' && env.WINDOWS_CODESIGN_CERTIFICATE_BASE64 != ''
env:
WINDOWS_CODESIGN_CERTIFICATE_BASE64: ${{ secrets.WINDOWS_CODESIGN_CERTIFICATE_BASE64 }}
WINDOWS_CODESIGN_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CODESIGN_CERTIFICATE_PASSWORD }}
shell: pwsh
run: |
$certBytes = [System.Convert]::FromBase64String($env:WINDOWS_CODESIGN_CERTIFICATE_BASE64)
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import(
$certBytes,
$env:WINDOWS_CODESIGN_CERTIFICATE_PASSWORD,
[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable
)
Set-AuthenticodeSignature `
-FilePath "target/${{ matrix.target }}/release/jolter.exe" `
-Certificate $cert `
-TimestampServer "http://timestamp.digicert.com"
Set-AuthenticodeSignature `
-FilePath "target/${{ matrix.target }}/release/jolter-shim.exe" `
-Certificate $cert `
-TimestampServer "http://timestamp.digicert.com"
- name: Package Windows artifact
if: matrix.archive == 'zip'
shell: pwsh
run: |
$name = "jolter-$env:GITHUB_REF_NAME-${{ matrix.target }}"
$dir = "dist/$name"
New-Item -ItemType Directory -Force $dir | Out-Null
Copy-Item `
"target/${{ matrix.target }}/release/jolter.exe", `
"target/${{ matrix.target }}/release/jolter-shim.exe", `
"README.md", `
"LICENSE" `
$dir
if (-not (Test-Path (Join-Path $dir "jolter.exe"))) {
throw "missing jolter.exe"
}
if (-not (Test-Path (Join-Path $dir "jolter-shim.exe"))) {
throw "missing jolter-shim.exe"
}
$zip = "dist/$name.zip"
Compress-Archive "$dir/*" $zip
$hash = (Get-FileHash -Algorithm SHA256 $zip).Hash.ToLower()
"$hash $name.zip" | Set-Content "$zip.sha256"
- uses: actions/upload-artifact@v4
with:
name: jolter-${{ matrix.target }}
path: |
dist/*.tar.gz
dist/*.tar.gz.sha256
dist/*.zip
dist/*.zip.sha256
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.JOLTERBOT_TOKEN }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
pattern: jolter-*
merge-multiple: true
- name: Extract release notes from CHANGELOG.md
shell: bash
run: |
set -euo pipefail
VER="${GITHUB_REF_NAME#v}"
export VER
node -e '
const fs = require("fs");
const changelog = fs.readFileSync("CHANGELOG.md", "utf8");
const version = process.env.VER;
const lines = changelog.split("\n");
let active = false;
const notes = [];
for (const line of lines) {
if (/^##\s+/.test(line)) {
if (line.includes(" " + version + " ") || line.startsWith("## " + version + " ") || line.startsWith("## " + version + "-")) {
active = true;
continue;
} else if (active) {
break;
}
}
if (active) {
notes.push(line);
}
}
const content = notes.join("\n").trim();
if (!content) {
if (version.includes("nightly")) {
fs.writeFileSync("RELEASE_NOTES.md", "Nightly release " + process.env.GITHUB_REF_NAME + "\n");
} else {
console.error("No changelog entry found for version " + version);
process.exit(1);
}
} else {
fs.writeFileSync("RELEASE_NOTES.md", content + "\n");
}
'
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.JOLTERBOT_TOKEN }}
run: |
set -euo pipefail
FLAGS=()
if [[ "${GITHUB_REF_NAME}" == *"-nightly."* ]] || [[ "${GITHUB_REF_NAME}" == *"nightly"* ]]; then
FLAGS+=("--prerelease")
fi
gh release create "${GITHUB_REF_NAME}" \
dist/* \
--title "${GITHUB_REF_NAME}" \
--notes-file RELEASE_NOTES.md \
"${FLAGS[@]}"