Skip to content

Commit 0aee200

Browse files
committed
chore: add static release pipeline
1 parent 0b23cee commit 0aee200

1 file changed

Lines changed: 148 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# SPDX-License-Identifier: MIT
2+
# SPDX-FileCopyrightText: 2025 Alexander Minges
3+
4+
name: Release
5+
6+
on:
7+
push:
8+
tags:
9+
- "v*"
10+
11+
permissions:
12+
contents: write
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
checks:
19+
name: Lint & Test (Linux)
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install stable toolchain
26+
uses: actions-rs/toolchain@v1
27+
with:
28+
toolchain: stable
29+
profile: minimal
30+
override: true
31+
32+
- name: Cargo fmt
33+
run: cargo fmt --all -- --check
34+
35+
- name: Cargo clippy
36+
run: cargo clippy --all-targets --all-features -- -D warnings
37+
38+
- name: Cargo test
39+
run: cargo test --all
40+
41+
build:
42+
name: Build ${{ matrix.target }}
43+
needs: checks
44+
strategy:
45+
matrix:
46+
include:
47+
- runner: ubuntu-latest
48+
target: x86_64-unknown-linux-musl
49+
archive: tar.gz
50+
- runner: windows-latest
51+
target: x86_64-pc-windows-msvc
52+
archive: zip
53+
runs-on: ${{ matrix.runner }}
54+
env:
55+
TARGET: ${{ matrix.target }}
56+
RUSTFLAGS: -C target-feature=+crt-static
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
61+
- name: Install stable toolchain
62+
uses: actions-rs/toolchain@v1
63+
with:
64+
toolchain: stable
65+
target: ${{ matrix.target }}
66+
profile: minimal
67+
override: true
68+
69+
- name: Install musl toolchain and native deps
70+
if: matrix.target == 'x86_64-unknown-linux-musl'
71+
run: |
72+
sudo apt-get update
73+
sudo apt-get install -y \
74+
musl-tools musl-dev pkg-config \
75+
libx11-dev libxcursor-dev libxrandr-dev libxi-dev \
76+
libgl1-mesa-dev libasound2-dev libudev-dev \
77+
libwayland-dev libxkbcommon-dev
78+
79+
- name: Cache cargo
80+
uses: actions/cache@v4
81+
with:
82+
path: |
83+
~/.cargo/registry
84+
~/.cargo/git
85+
target
86+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
87+
restore-keys: |
88+
${{ runner.os }}-cargo-
89+
90+
- name: Build release
91+
run: cargo build --release --target $TARGET
92+
93+
- name: Package artifact (Linux)
94+
if: matrix.archive == 'tar.gz'
95+
run: |
96+
bin_path=target/$TARGET/release/elnpack
97+
pkg_dir=package-linux
98+
mkdir -p "$pkg_dir"
99+
cp "$bin_path" "$pkg_dir/"
100+
cp README.md LICENSE "$pkg_dir/"
101+
tar -czf elnpack-${{ github.ref_name }}-$TARGET.tar.gz -C "$pkg_dir" .
102+
103+
- name: Package artifact (Windows)
104+
if: matrix.archive == 'zip'
105+
shell: pwsh
106+
run: |
107+
$binPath = "target/${env:TARGET}/release/elnpack.exe"
108+
$pkgDir = "package-windows"
109+
New-Item -ItemType Directory -Force -Path $pkgDir | Out-Null
110+
Copy-Item $binPath "$pkgDir/"
111+
Copy-Item "README.md","LICENSE" "$pkgDir/"
112+
Compress-Archive -Path "$pkgDir/*" -DestinationPath "elnpack-${{ github.ref_name }}-${env:TARGET}.zip"
113+
114+
- name: Upload artifact
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: elnpack-${{ github.ref_name }}-${{ matrix.target }}
118+
path: |
119+
elnpack-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive }}
120+
121+
publish:
122+
name: Publish Release
123+
needs: build
124+
runs-on: ubuntu-latest
125+
steps:
126+
- name: Download artifacts
127+
uses: actions/download-artifact@v4
128+
with:
129+
path: dist
130+
131+
- name: List artifacts
132+
run: ls -R dist
133+
134+
- name: Generate checksums
135+
run: |
136+
cd dist
137+
find . -maxdepth 2 -type f \( -name "*.tar.gz" -o -name "*.zip" \) | xargs sha256sum > SHA256SUMS
138+
139+
- name: Create GitHub Release
140+
uses: softprops/action-gh-release@v2
141+
with:
142+
tag_name: ${{ github.ref_name }}
143+
files: |
144+
dist/**/*
145+
draft: false
146+
generate_release_notes: true
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)