Files
vibetorrent/.gitea/workflows/build-mips.yml
spinline bf54d2699e
Some checks failed
Build MIPS Binary / build (push) Failing after 10m7s
ci: force static linking with crt-static and -static flags
2026-02-06 18:39:40 +03:00

104 lines
3.3 KiB
YAML

name: Build MIPS Binary
on:
push:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
run: |
rustup toolchain install nightly --profile minimal
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup component add rust-src --toolchain nightly
rustc +nightly --version
- name: Install Trunk
run: |
if ! command -v trunk &> /dev/null; then
cargo install trunk --locked
fi
- name: Build Frontend
run: |
cd frontend
npm install
trunk build --release
- name: Install Cross
run: |
if ! command -v cross &> /dev/null; then
cargo install cross --locked
fi
- name: Build Backend (MIPS)
run: |
docker run --rm --platform linux/amd64 \
-v "$PWD":/project \
-v cargo-cache:/usr/local/cargo/registry \
-w /project \
rust:latest \
bash -c '
rustup toolchain install nightly --component rust-src &&
apt-get update -qq && apt-get install -y -qq musl-tools wget >/dev/null 2>&1 &&
wget -qO- https://musl.cc/mips-linux-musl-cross.tgz | tar xz -C /opt/ &&
export PATH="/opt/mips-linux-musl-cross/bin:$PATH" &&
export CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-linux-musl-gcc &&
export RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-static" &&
cd backend &&
cargo +nightly build --target mips-unknown-linux-musl --release -Z build-std=std,panic_abort &&
file /project/target/mips-unknown-linux-musl/release/backend
'
- name: Rename Binary
run: mv target/mips-unknown-linux-musl/release/backend target/mips-unknown-linux-musl/release/vibetorrent-mips
- name: Generate Release Tag
id: tag
run: echo "release_tag=release-$(date +'%Y%m%d-%H%M')" >> "$GITHUB_OUTPUT"
- name: Create Release
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
TAG="${{ steps.tag.outputs.release_tag }}"
REPO="admin/vibetorrent"
API_URL="${{ gitea.server_url }}/api/v1"
# Create release
RELEASE_RESPONSE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases" \
-H "Authorization: token ${RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${TAG}\",
\"name\": \"Release ${TAG}\",
\"body\": \"Automated build from commit ${{ gitea.sha }}\",
\"draft\": false,
\"prerelease\": false
}")
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
echo "Release ID: $RELEASE_ID"
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
echo "Failed to create release:"
echo "$RELEASE_RESPONSE"
exit 1
fi
# Upload binary as release asset
curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=vibetorrent-mips" \
-H "Authorization: token ${RELEASE_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @target/mips-unknown-linux-musl/release/vibetorrent-mips
echo "Release ${TAG} created with binary attached."