Files
rlogg/.gitea/workflows/build.yml
Stanislav Pastushenko 42d0c0c02a
All checks were successful
Build / Build - linux (push) Successful in 3m57s
fix build?
2025-12-11 20:13:55 +01:00

134 lines
4.9 KiB
YAML

name: Build
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Build - ${{ matrix.platform }}
runs-on: gitea-runner
container:
image: ${{ matrix.docker_image }}
strategy:
matrix:
include:
- platform: linux
docker_image: gitea.staspast.click/stas/rust-node-builder:custom
target: x86_64-unknown-linux-gnu
artifact_name: rlogg-linux-x86_64
binary_extension: ""
setup_cmd: ""
# - platform: macos
# docker_image: messense/cargo-zigbuild:latest
# target: x86_64-apple-darwin
# artifact_name: rlogg-macos-x86_64
# binary_extension: ""
# setup_cmd: ""
# - platform: windows
# docker_image: rust:latest
# target: x86_64-pc-windows-gnu
# artifact_name: rlogg-windows-x86_64
# binary_extension: ".exe"
# setup_cmd: "apt-get update && apt-get install -y mingw-w64"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Debug - Check tar and environment
run: |
echo "=== Container Image Info ==="
cat /etc/os-release || true
echo ""
echo "=== PATH ==="
echo $PATH
echo ""
echo "=== All tar binaries on system ==="
which -a tar || true
find /bin /usr/bin /usr/local/bin -name "tar" 2>/dev/null || true
echo ""
echo "=== /bin/tar info ==="
ls -la /bin/tar || echo "/bin/tar not found"
/bin/tar --version 2>&1 || echo "/bin/tar --version failed"
echo ""
echo "=== /usr/bin/tar info ==="
ls -la /usr/bin/tar || echo "/usr/bin/tar not found"
/usr/bin/tar --version 2>&1 || echo "/usr/bin/tar --version failed"
echo ""
echo "=== Testing --posix flag ==="
/bin/tar --posix --version 2>&1 || echo "/bin/tar doesn't support --posix"
/usr/bin/tar --posix --version 2>&1 || echo "/usr/bin/tar doesn't support --posix"
echo ""
echo "=== Environment variables ==="
env | grep -i tar || echo "No tar-related env vars"
- name: Generate dependency hash
id: deps_hash
run: |
# Create a hash of dependencies only (excludes package version)
# This prevents cache invalidation on version bumps
{
# Get all dependencies from Cargo.toml (skip package.version)
grep -A 9999 '^\[dependencies' Cargo.toml 2>/dev/null || true
grep -A 9999 '^\[dev-dependencies' Cargo.toml 2>/dev/null || true
grep -A 9999 '^\[build-dependencies' Cargo.toml 2>/dev/null || true
# Include Cargo.lock for exact dependency versions
cat Cargo.lock 2>/dev/null || true
} | sha256sum | cut -d' ' -f1 > /tmp/deps_hash.txt
echo "hash=$(cat /tmp/deps_hash.txt)" >> $GITHUB_OUTPUT
- name: Cache Cargo Dependencies
uses: https://gitea.com/actions/cache@v3
with:
# Path to cache: The 'target' directory contains all compiled libraries
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
# Key: Changes only when dependencies change, not when version changes
key: ${{ runner.os }}-cargo-${{ steps.deps_hash.outputs.hash }}-${{ matrix.target }}
# Restore Keys: Fallback to any cache for this target
restore-keys: |
${{ runner.os }}-cargo-${{ steps.deps_hash.outputs.hash }}-
${{ runner.os }}-cargo-
env:
# Force use of GNU tar instead of BusyBox tar
INPUT_TAR_PATH: /usr/bin/tar
- name: Setup cross-compilation tools
if: matrix.setup_cmd != ''
run: ${{ matrix.setup_cmd }}
- name: Add Rust target
run: rustup target add ${{ matrix.target }}
- name: Build release binary
run: |
if [ "${{ matrix.platform }}" = "macos" ]; then
cargo zigbuild --release --target ${{ matrix.target }}
else
# Define RUSTFLAGS to use the system linker (cc) and disable debug compression
cargo build --release
fi
- name: Prepare artifact
shell: sh
run: |
mkdir -p dist
if [ "${{ matrix.platform }}" = "linux" ]; then
cp target/release/rlogg${{ matrix.binary_extension }} dist/${{ matrix.artifact_name }}${{ matrix.binary_extension }}
else
cp target/${{ matrix.target }}/release/rlogg${{ matrix.binary_extension }} dist/${{ matrix.artifact_name }}${{ matrix.binary_extension }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.artifact_name }}${{ matrix.binary_extension }}
retention-days: 14