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
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
jobs:
build:
name: Build ${{ matrix.os_arch }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os_arch: linux-amd64
runner: ubuntu-latest
- os_arch: linux-arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: "release-${{ matrix.os_arch }}"
- name: Build
run: cargo build --release
- name: Strip binary
run: strip target/release/fail2ban-rs
- name: Package
run: |
ARTIFACT="fail2ban-rs-${VERSION}-${{ matrix.os_arch }}"
mkdir -p dist/${ARTIFACT}
cp target/release/fail2ban-rs dist/${ARTIFACT}/
cp dist/fail2ban-rs.service dist/${ARTIFACT}/
cp config/default.toml dist/${ARTIFACT}/config.toml
cp LICENSE dist/${ARTIFACT}/ 2>/dev/null || true
cp README.md dist/${ARTIFACT}/ 2>/dev/null || true
cd dist
tar -czf ${ARTIFACT}.tar.gz ${ARTIFACT}
sha256sum ${ARTIFACT}.tar.gz > ${ARTIFACT}.tar.gz.sha256
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os_arch }}
path: dist/fail2ban-rs-${{ env.VERSION }}-${{ matrix.os_arch }}.tar.gz*
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
generate_release_notes: true