feat: add release workflow and static build config

This commit is contained in:
2026-01-15 23:54:47 +08:00
parent cccbd80078
commit 69f4ad5fec
7 changed files with 147 additions and 7 deletions

2
.cargo/config.toml Normal file
View File

@@ -0,0 +1,2 @@
[build]
target = "x86_64-unknown-linux-musl"

76
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,76 @@
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
build-and-release:
name: Build and Release
runs-on: ubuntu-latest
strategy:
matrix:
include:
# The target name ending in '-musl' guarantees static linking against musl libc
- target: x86_64-unknown-linux-musl
arch: amd64
- target: aarch64-unknown-linux-musl
arch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install Packaging Tools
run: |
cargo install cargo-deb
cargo install cargo-generate-rpm
- name: Build
# 'cross' handles the containerized build environment for the specified target (musl)
run: cross build --release --target ${{ matrix.target }}
- name: Prepare Packaging Assets
run: |
# Move binary to expected location for cargo-deb and cargo-generate-rpm which read Cargo.toml assets
mkdir -p target/release
cp target/${{ matrix.target }}/release/traudit target/release/traudit
- name: Package DEB
run: |
cargo deb --target ${{ matrix.target }} --no-build --output target/${{ matrix.target }}/debian/traudit_${{ matrix.arch }}.deb
- name: Package RPM
run: |
cargo generate-rpm --target ${{ matrix.target }} --output target/${{ matrix.target }}/rpm/traudit-${{ matrix.arch }}.rpm
- name: Package Tarball
run: |
# Copy extra files to release dir to bundle them
cp config_example.yaml target/${{ matrix.target }}/release/config.yaml
cp traudit.service target/${{ matrix.target }}/release/
cd target/${{ matrix.target }}/release
tar -czvf traudit-${{ matrix.target }}.tar.gz traudit config.yaml traudit.service
mv traudit-${{ matrix.target }}.tar.gz ../../../
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/${{ matrix.target }}/debian/*.deb
target/${{ matrix.target }}/rpm/*.rpm
traudit-${{ matrix.target }}.tar.gz

View File

@@ -4,6 +4,8 @@ version = "0.1.0"
edition = "2021" edition = "2021"
authors = ["awfufu"] authors = ["awfufu"]
description = "A reverse proxy with auditing capabilities." description = "A reverse proxy with auditing capabilities."
license = "MIT"
repository = "https://github.com/awfufu/traudit"
[dependencies] [dependencies]
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
@@ -31,3 +33,28 @@ lto = true
codegen-units = 1 codegen-units = 1
panic = "abort" panic = "abort"
strip = true strip = true
[package.metadata.deb]
maintainer = "awfufu"
copyright = "2026, awfufu"
license-file = ["README.md", "4"]
extended-description = """\
A reverse proxy with auditing capabilities.
"""
depends = "$auto"
section = "net"
priority = "optional"
assets = [
["target/release/traudit", "usr/bin/", "755"],
["config_example.yaml", "etc/traudit/config.yaml", "644"],
["traudit.service", "usr/lib/systemd/system/traudit.service", "644"],
]
conf-files = ["/etc/traudit/config.yaml"]
[package.metadata.generate-rpm]
assets = [
{ source = "target/release/traudit", dest = "/usr/bin/traudit", mode = "755" },
{ source = "config_example.yaml", dest = "/etc/traudit/config.yaml", mode = "644", config = true },
{ source = "traudit.service", dest = "/usr/lib/systemd/system/traudit.service", mode = "644" },
]

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 awfufu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -15,18 +15,18 @@ services:
type: "tcp" type: "tcp"
binds: binds:
# Entry 1: Public traffic from FRP # Entry 1: Public traffic from FRP
- addr: "0.0.0.0:2222" - addr: "0.0.0.0:2223"
proxy: "v2" proxy: "v2"
# Entry 2: LAN direct traffic (no Proxy Protocol) # Entry 2: LAN direct traffic (no Proxy Protocol)
- addr: "0.0.0.0:2233" - addr: "0.0.0.0:2222"
# no proxy # no proxy
forward_to: "127.0.0.1:22" forward_to: "127.0.0.1:22"
- name: "web" # - name: "web"
type: "tcp" # type: "tcp"
binds: # binds:
- addr: "0.0.0.0:8080" # - addr: "0.0.0.0:8080"
forward_to: "/run/nginx/web.sock" # forward_to: "/run/nginx/web.sock"

View File

@@ -19,6 +19,8 @@ fn print_help() {
println!(" -f <config_file> path to the yaml configuration file"); println!(" -f <config_file> path to the yaml configuration file");
println!(" -t, --test test configuration and exit"); println!(" -t, --test test configuration and exit");
println!(" -h, --help print this help message"); println!(" -h, --help print this help message");
println!();
println!("project: https://github.com/awfufu/traudit");
} }
#[tokio::main] #[tokio::main]

12
traudit.service Normal file
View File

@@ -0,0 +1,12 @@
[Unit]
Description=Traudit Reverse Proxy
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/traudit -f /etc/traudit/config.yaml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target