92 lines
3.4 KiB
YAML
92 lines
3.4 KiB
YAML
name: Build MIPS Binary
|
||
|
||
on:
|
||
push:
|
||
branches: [ "main" ]
|
||
|
||
env:
|
||
CARGO_TERM_COLOR: always
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: mips-builder
|
||
|
||
steps:
|
||
- name: Checkout
|
||
env:
|
||
GIT_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||
run: |
|
||
rm -rf .git
|
||
git init .
|
||
git remote add origin https://admin:$\{GIT_TOKEN\}@git.karatatar.com/admin/vibetorrent.git
|
||
git fetch --depth=1 origin ${{ gitea.sha }}
|
||
git checkout FETCH_HEAD
|
||
|
||
- name: Build Frontend
|
||
run: |
|
||
cd frontend
|
||
npm install
|
||
# Run Tailwind manually first
|
||
npx @tailwindcss/cli -i input.css -o public/tailwind.css
|
||
trunk build --release
|
||
|
||
# Manuel WASM Optimizasyonu
|
||
WASM_FILE=$(ls dist/*.wasm | head -n 1)
|
||
BEFORE=$(du -h "$WASM_FILE" | cut -f1)
|
||
echo "Before optimization: $BEFORE"
|
||
|
||
wasm-opt --all-features -Oz "$WASM_FILE" -o "$WASM_FILE"
|
||
|
||
AFTER=$(du -h "$WASM_FILE" | cut -f1)
|
||
echo "After optimization: $AFTER"
|
||
echo "Optimization complete!"
|
||
|
||
- name: Build Backend (MIPS)
|
||
env:
|
||
# -s: Sembolleri siler, -w: DWARF debug bilgilerini siler (Binary boyutunu devasa düşürür)
|
||
RUSTFLAGS: "-C target-feature=+crt-static -C link-self-contained=no -C link-arg=-msoft-float -C link-arg=-s -C link-arg=-w"
|
||
CFLAGS_mips_unknown_linux_musl: "-msoft-float"
|
||
run: |
|
||
# Kök dizinden derleyerek workspace profil ayarlarının (LTO, z, strip) uygulanmasını sağlıyoruz
|
||
# Sadece push-notifications özelliğini aktif ediyoruz (swagger UI kapanır, boyut düşer)
|
||
cargo zigbuild -p backend --target mips-unknown-linux-musl --release -Z build-std=std,panic_abort --no-default-features --features push-notifications
|
||
file 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."
|