Testing workflow
Some checks failed
Multi-Platform Release Build / detect-architecture (push) Has been cancelled
Multi-Platform Release Build / build (false, native) (push) Has been cancelled
Multi-Platform Release Build / build (true, aarch64-linux-gnu-gcc, aarch64-unknown-linux-gnu) (push) Has been cancelled
Multi-Platform Release Build / build (true, arm-linux-gnueabihf-gcc, armv7-unknown-linux-gnueabihf) (push) Has been cancelled
Multi-Platform Release Build / build (true, x86_64-linux-gnu-gcc, x86_64-unknown-linux-gnu) (push) Has been cancelled
Multi-Platform Release Build / build (true, x86_64-w64-mingw32-gcc, x86_64-pc-windows-gnu) (push) Has been cancelled
Multi-Platform Release Build / create-release (push) Has been cancelled

This commit is contained in:
Marco De Araujo 2025-12-30 07:35:50 -04:00
parent 414609b6e0
commit f6640ede13
3 changed files with 255 additions and 2 deletions

View file

@ -0,0 +1,232 @@
name: Multi-Platform Release Build
on:
push:
tags:
- "v*.*.*"
jobs:
detect-architecture:
runs-on: ubuntu-latest
outputs:
runner_arch: ${{ steps.detect.outputs.arch }}
steps:
- name: Detect runner architecture
id: detect
run: |
ARCH=$(uname -m)
case $ARCH in
aarch64) echo "arch=arm64" >> $GITHUB_OUTPUT ;;
armv7l) echo "arch=armv7" >> $GITHUB_OUTPUT ;;
x86_64) echo "arch=amd64" >> $GITHUB_OUTPUT ;;
*) echo "arch=unknown" >> $GITHUB_OUTPUT ;;
esac
echo "Detected runner architecture: $ARCH"
build:
runs-on: ubuntu-latest
needs: detect-architecture
strategy:
fail-fast: false
matrix:
include:
- target: native
cross: false
- target: x86_64-unknown-linux-gnu
cross: true
linker: x86_64-linux-gnu-gcc
- target: aarch64-unknown-linux-gnu
cross: true
linker: aarch64-linux-gnu-gcc
- target: armv7-unknown-linux-gnueabihf
cross: true
linker: arm-linux-gnueabihf-gcc
- target: x86_64-pc-windows-gnu
cross: true
linker: x86_64-w64-mingw32-gcc
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Add Rust target
if: matrix.target != 'native'
run: rustup target add ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.cross
run: |
sudo apt-get update
sudo apt-get install -y \
gcc-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu \
gcc-x86-64-linux-gnu \
g++-arm-linux-gnueabihf \
g++-aarch64-linux-gnu \
mingw-w64 \
libc6-dev-armhf-cross \
libc6-dev-arm64-cross
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.target }}-
${{ runner.os }}-cargo-
- name: Configure cross-compilation
if: matrix.cross && matrix.target != 'native'
run: |
mkdir -p .cargo
cat >> .cargo/config.toml << EOF
[target.${{ matrix.target }}]
linker = "${{ matrix.linker }}"
EOF
- name: Build release
run: |
if [ "${{ matrix.target }}" = "native" ]; then
# Build nativo para a arquitetura do runner
NATIVE_TARGET=$(rustc -vV | grep 'host:' | cut -d' ' -f2)
echo "Building for native target: $NATIVE_TARGET"
cargo build --release --features production
TARGET_BINARY="target/release/uptime-kuma-dashboard"
OUTPUT_NAME="uptime-kuma-dashboard-$NATIVE_TARGET"
else
# Build com target específico
echo "Building for target: ${{ matrix.target }}"
cargo build --release --target ${{ matrix.target }} --features production
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
TARGET_BINARY="target/${{ matrix.target }}/release/uptime-kuma-dashboard.exe"
OUTPUT_NAME="uptime-kuma-dashboard-${{ matrix.target }}.exe"
else
TARGET_BINARY="target/${{ matrix.target }}/release/uptime-kuma-dashboard"
OUTPUT_NAME="uptime-kuma-dashboard-${{ matrix.target }}"
fi
fi
# Criar diretório de artifacts
mkdir -p release-artifacts
# Verificar se o binário foi criado
if [ ! -f "$TARGET_BINARY" ]; then
echo "Error: Binary not found at $TARGET_BINARY"
exit 1
fi
# Copiar binário
cp "$TARGET_BINARY" "release-artifacts/$OUTPUT_NAME"
# Strip binário para Linux (reduz tamanho)
if [[ "${{ matrix.target }}" == *"linux"* ]] || [ "${{ matrix.target }}" = "native" ]; then
strip "release-artifacts/$OUTPUT_NAME" 2>/dev/null || echo "Strip failed, continuing..."
fi
# Tornar executável
if [[ "${{ matrix.target }}" != *"windows"* ]]; then
chmod +x "release-artifacts/$OUTPUT_NAME"
fi
# Mostrar informações do arquivo
ls -lh "release-artifacts/$OUTPUT_NAME"
file "release-artifacts/$OUTPUT_NAME" || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.target }}
path: release-artifacts/
retention-days: 1
create-release:
runs-on: ubuntu-latest
needs: [detect-architecture, build]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts/
- name: Prepare release artifacts
run: |
mkdir -p release-artifacts
find all-artifacts -type f -name "uptime-kuma-dashboard-*" -exec cp {} release-artifacts/ \;
ls -lh release-artifacts/
- name: Generate checksums
run: |
cd release-artifacts
sha256sum uptime-kuma-dashboard-* > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create Release
uses: actions/gitea-release-action@v1
with:
files: release-artifacts/*
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
## 🚀 Multi-Platform Release
Compiled on runner **${{ needs.detect-architecture.outputs.runner_arch }}**
### 📦 Available Binaries
This release includes binaries for the following platforms:
- **Linux x86_64** (Intel/AMD 64-bit)
- **Linux ARM64** (aarch64) - Raspberry Pi 4, Apple Silicon Linux, ARM servers
- **Linux ARMv7** (armhf) - Raspberry Pi 3 and earlier
- **Windows x86_64** (64-bit)
### 🚀 How to use
#### Linux/ARM:
```bash
# Download the appropriate binary
wget https://your-forgejo.com/releases/download/${{ forgejo.ref_name }}/uptime-kuma-dashboard-<your-target>
# Make executable
chmod +x uptime-kuma-dashboard-*
# Run
./uptime-kuma-dashboard-* --base-url https://your-kuma --slug your-slug
```
#### Windows:
```powershell
# Download uptime-kuma-dashboard-x86_64-pc-windows-gnu.exe
# Run in PowerShell or CMD
.\uptime-kuma-dashboard-x86_64-pc-windows-gnu.exe --base-url https://your-kuma --slug your-slug
```
### ✅ Verify Checksums
```bash
sha256sum -c SHA256SUMS.txt
```
### 🏗️ Build Information
- Runner Architecture: ${{ needs.detect-architecture.outputs.runner_arch }}
- Rust Version: stable
- Build Type: Release (optimized)

View file

@ -19,5 +19,26 @@ crossterm = "0.29.0"
chrono = "0.4.42" chrono = "0.4.42"
rayon = "1.11.0" rayon = "1.11.0"
[profile.release] [features]
default = []
production = []
[profile.dev]
opt-level = 0
debug = true debug = true
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
strip = true
panic = "abort"
debug = false
[profile.release-min]
inherits = "release"
opt-level = "z"
lto = true
codegen-units = 1
strip = true
panic = "abort"

View file

@ -10,7 +10,7 @@ use unic_langid::LanguageIdentifier;
static SYSTEM_LOCALE: OnceLock<LanguageIdentifier> = OnceLock::new(); static SYSTEM_LOCALE: OnceLock<LanguageIdentifier> = OnceLock::new();
static TRANSLATION_CACHE: OnceLock<RwLock<HashMap<String, String>>> = OnceLock::new(); static TRANSLATION_CACHE: OnceLock<RwLock<HashMap<String, String>>> = OnceLock::new();
const CACHE_INITIAL_SIZE: usize = 100; const CACHE_INITIAL_SIZE: usize = 30;
const CACHE_SIZE_LIMIT: usize = 1000; const CACHE_SIZE_LIMIT: usize = 1000;
fn get_system_locale() -> &'static LanguageIdentifier { fn get_system_locale() -> &'static LanguageIdentifier {