-
Notifications
You must be signed in to change notification settings - Fork 0
269 lines (239 loc) · 7.98 KB
/
Copy pathrelease.yml
File metadata and controls
269 lines (239 loc) · 7.98 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2025 elnPack Contributors
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
# Simplified manual tag release flow using git-cliff for notes.
# Changelog is generated at publish time from git history.
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
checks:
name: Lint & Test (Linux)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-stable-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install toolchain
uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e
with:
toolchain: stable
components: rustfmt, clippy
- name: Cargo fmt
run: cargo fmt --all -- --check
- name: Cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Cargo test
run: cargo test --all
build:
name: Build ${{ matrix.target }}
needs: checks
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
rustflags: ""
linux: true
pkg_config_libdir: ""
multilib: false
toolchain: stable
build_std_flag: ""
install_target: true
- runner: ubuntu-latest
target: i686-unknown-linux-gnu
archive: tar.gz
rustflags: ""
linux: true
pkg_config_libdir: "/usr/lib/i386-linux-gnu/pkgconfig"
multilib: true
toolchain: stable
build_std_flag: ""
install_target: true
- runner: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
rustflags: ""
linux: false
pkg_config_libdir: ""
multilib: false
toolchain: stable
build_std_flag: ""
install_target: true
- runner: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
rustflags: ""
linux: false
pkg_config_libdir: ""
multilib: false
toolchain: stable
build_std_flag: ""
install_target: true
- runner: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
rustflags: ""
linux: false
pkg_config_libdir: ""
multilib: false
toolchain: stable
build_std_flag: ""
install_target: true
- runner: windows-latest
target: i686-pc-windows-msvc
archive: zip
rustflags: ""
linux: false
pkg_config_libdir: ""
multilib: false
toolchain: stable
build_std_flag: ""
install_target: true
runs-on: ${{ matrix.runner }}
env:
TARGET: ${{ matrix.target }}
RUSTFLAGS: ${{ matrix.rustflags }}
PKG_CONFIG_LIBDIR: ${{ matrix.pkg_config_libdir }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set safe ref name (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$safe = $env:GITHUB_REF_NAME -replace '/', '-'
Add-Content -Path $env:GITHUB_ENV -Value "SAFE_REF=$safe"
- name: Set safe ref name (Unix)
if: runner.os != 'Windows'
shell: bash
run: echo "SAFE_REF=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_ENV"
- name: Install toolchain
uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e
with:
toolchain: ${{ matrix.toolchain }}
- name: Add target
if: matrix.install_target
run: rustup target add ${{ matrix.target }} --toolchain ${{ matrix.toolchain }}
- name: Add rust-src component
if: matrix.build_std_flag != ''
run: rustup component add rust-src --toolchain ${{ matrix.toolchain }}
- name: Install Linux build deps
if: matrix.linux
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libx11-dev libxcursor-dev libxrandr-dev libxi-dev \
libgl1-mesa-dev libasound2-dev libudev-dev \
libwayland-dev libxkbcommon-dev
- name: Install 32-bit Linux deps
if: matrix.target == 'i686-unknown-linux-gnu'
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y \
gcc-multilib g++-multilib pkg-config \
libx11-dev:i386 libxcursor-dev:i386 libxrandr-dev:i386 libxi-dev:i386 \
libgl1-mesa-dev:i386 libasound2-dev:i386 libudev-dev:i386 \
libwayland-dev:i386 libxkbcommon-dev:i386
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build release
run: cargo +${{ matrix.toolchain }} build ${{ matrix.build_std_flag }} --release --target ${{ matrix.target }}
- name: Package artifact (Linux)
if: matrix.archive == 'tar.gz'
run: |
bin_path=target/$TARGET/release/elnpack
pkg_dir=package-${{ runner.os }}
mkdir -p "$pkg_dir"
cp "$bin_path" "$pkg_dir/"
cp README.md LICENSE "$pkg_dir/"
tar -czf "elnpack-$SAFE_REF-$TARGET.tar.gz" -C "$pkg_dir" .
- name: Package artifact (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$binPath = "target/${env:TARGET}/release/elnpack.exe"
$pkgDir = "package-${env:RUNNER_OS}"
New-Item -ItemType Directory -Force -Path $pkgDir | Out-Null
Copy-Item $binPath "$pkgDir/"
Copy-Item "README.md","LICENSE" "$pkgDir/"
$safeRef = $env:SAFE_REF
Compress-Archive -Path "$pkgDir/*" -DestinationPath "elnpack-$safeRef-${env:TARGET}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: elnpack-${{ env.SAFE_REF }}-${{ matrix.target }}
path: |
elnpack-${{ env.SAFE_REF }}-${{ matrix.target }}.${{ matrix.archive }}
publish:
name: Publish Release
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout (full history for git-cliff)
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: List artifacts
run: ls -R dist
- name: Generate checksums
run: |
cd dist
: > SHA256SUMS
find . -maxdepth 2 -type f \( -name "*.tar.gz" -o -name "*.zip" \) -print0 \
| sort -z \
| xargs -0 -r sha256sum >> SHA256SUMS
- name: Generate changelog with git-cliff
uses: orhun/git-cliff-action@v2
with:
config: cliff.toml
args: --tag ${{ github.ref_name }} --output release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
files: |
dist/**/*
draft: false
generate_release_notes: false
body_path: release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}