Compare commits
9 Commits
5f8facbd46
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8affad428e | |||
| ef132c35f3 | |||
| e6c30dc403 | |||
| f9f81e6dcf | |||
| e1102b8590 | |||
| 7d3f95ae82 | |||
| 42d0c0c02a | |||
| 22af721701 | |||
| bd56cd31e4 |
@@ -12,62 +12,34 @@ jobs:
|
|||||||
runs-on: gitea-runner
|
runs-on: gitea-runner
|
||||||
container:
|
container:
|
||||||
image: ${{ matrix.docker_image }}
|
image: ${{ matrix.docker_image }}
|
||||||
|
volumes:
|
||||||
|
- /tmp/gitea-sccache:/tmp/sccache
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- platform: linux
|
- platform: linux
|
||||||
docker_image: gitea.staspast.click/stas/rust-node-builder:latest
|
docker_image: gitea.staspast.click/stas/rust-node-builder:v5
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
artifact_name: rlogg-linux-x86_64
|
artifact_name: rlogg-linux-x86_64
|
||||||
binary_extension: ""
|
binary_extension: ""
|
||||||
setup_cmd: ""
|
setup_cmd: ""
|
||||||
# - platform: macos
|
- platform: windows
|
||||||
# docker_image: messense/cargo-zigbuild:latest
|
docker_image: gitea.staspast.click/stas/rust-node-builder:v5
|
||||||
# target: x86_64-apple-darwin
|
target: x86_64-pc-windows-gnu
|
||||||
# artifact_name: rlogg-macos-x86_64
|
artifact_name: rlogg-windows-x86_64
|
||||||
# binary_extension: ""
|
binary_extension: ".exe"
|
||||||
# setup_cmd: ""
|
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:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Generate dependency hash
|
- name: Configure sccache
|
||||||
id: deps_hash
|
|
||||||
run: |
|
run: |
|
||||||
# Create a hash of dependencies only (excludes package version)
|
# Configure sccache cache directory (persists on runner between builds)
|
||||||
# This prevents cache invalidation on version bumps
|
mkdir -p /tmp/sccache
|
||||||
{
|
echo "SCCACHE_DIR=/tmp/sccache" >> $GITHUB_ENV
|
||||||
# Get all dependencies from Cargo.toml (skip package.version)
|
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
|
||||||
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-
|
|
||||||
|
|
||||||
- name: Setup cross-compilation tools
|
- name: Setup cross-compilation tools
|
||||||
if: matrix.setup_cmd != ''
|
if: matrix.setup_cmd != ''
|
||||||
@@ -80,11 +52,17 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if [ "${{ matrix.platform }}" = "macos" ]; then
|
if [ "${{ matrix.platform }}" = "macos" ]; then
|
||||||
cargo zigbuild --release --target ${{ matrix.target }}
|
cargo zigbuild --release --target ${{ matrix.target }}
|
||||||
else
|
elif [ "${{ matrix.platform }}" = "linux" ]; then
|
||||||
# Define RUSTFLAGS to use the system linker (cc) and disable debug compression
|
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
else
|
||||||
|
# Cross-compile for other targets (e.g., Windows)
|
||||||
|
cargo build --release --target ${{ matrix.target }}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Show sccache statistics
|
||||||
|
echo "=== sccache stats ==="
|
||||||
|
sccache --show-stats
|
||||||
|
|
||||||
- name: Prepare artifact
|
- name: Prepare artifact
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
docker build -t gitea.staspast.click/stas/rust-node-builder:latest -f linux-build.Dockerfile . && docker push gitea.staspast.click/stas/rust-node-builder:latest
|
docker build -t gitea.staspast.click/stas/rust-node-builder:v5 -f linux-build.Dockerfile . && docker push gitea.staspast.click/stas/rust-node-builder:v5
|
||||||
@@ -1,8 +1,26 @@
|
|||||||
FROM rust:latest
|
FROM rust:latest
|
||||||
|
|
||||||
|
# Install system dependencies and tools
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
nodejs \
|
nodejs \
|
||||||
npm \
|
npm \
|
||||||
tar \
|
tar \
|
||||||
gzip \
|
gzip \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
curl \
|
||||||
|
mingw-w64 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* && \
|
||||||
|
# Check if /bin/tar is BusyBox and replace it with GNU tar
|
||||||
|
if /bin/tar --version 2>&1 | grep -q "BusyBox"; then \
|
||||||
|
cp /usr/bin/tar /bin/tar.gnu && \
|
||||||
|
rm -f /bin/tar && \
|
||||||
|
mv /bin/tar.gnu /bin/tar; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install sccache for Rust compilation caching
|
||||||
|
RUN SCCACHE_VERSION=0.7.4 && \
|
||||||
|
SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" && \
|
||||||
|
curl -L "$SCCACHE_URL" | tar xz && \
|
||||||
|
chmod +x sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache && \
|
||||||
|
mv sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache /usr/local/bin/ && \
|
||||||
|
rm -rf sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl
|
||||||
Reference in New Issue
Block a user