This commit is contained in:
@@ -2,99 +2,68 @@ name: build-service
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
|
||||
jobs:
|
||||
compile-binaries:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# 🔥 EVERYTHING runs inside Rust container (no host Rust used)
|
||||
container:
|
||||
image: rust:latest
|
||||
|
||||
steps:
|
||||
# -----------------------------
|
||||
# Checkout
|
||||
# -----------------------------
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# -----------------------------
|
||||
# Cargo cache (BIG SPEED BOOST)
|
||||
# -----------------------------
|
||||
- name: cache cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
# 🔥 install cross INSIDE container
|
||||
- name: install cross
|
||||
run: cargo install cross --locked
|
||||
|
||||
# -----------------------------
|
||||
# Rust toolchain
|
||||
# -----------------------------
|
||||
- name: install-rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
|
||||
|
||||
# -----------------------------
|
||||
# Install cross (ARM builds)
|
||||
# -----------------------------
|
||||
- name: install-cross
|
||||
run: cargo install cross --git https://github.com/cross-rs/cross
|
||||
|
||||
# -----------------------------
|
||||
# Build x86_64 (native)
|
||||
# -----------------------------
|
||||
- name: build-x86
|
||||
# =========================
|
||||
# 🧱 X86_64 BUILD
|
||||
# =========================
|
||||
- name: build x86_64
|
||||
run: cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
# -----------------------------
|
||||
# Build ARM64 (via cross)
|
||||
# -----------------------------
|
||||
- name: build-arm64
|
||||
# =========================
|
||||
# 🧱 ARM64 BUILD (FIXED)
|
||||
# =========================
|
||||
- name: build arm64
|
||||
run: cross build --release --target aarch64-unknown-linux-gnu
|
||||
|
||||
# -----------------------------
|
||||
# Package outputs
|
||||
# -----------------------------
|
||||
- name: prepare-release-files
|
||||
run: |
|
||||
mkdir -p dist
|
||||
|
||||
cp target/x86_64-unknown-linux-gnu/release/escape_room_server \
|
||||
dist/escape_room_server-linux-x86_64
|
||||
|
||||
cp target/aarch64-unknown-linux-gnu/release/escape_room_server \
|
||||
dist/escape_room_server-linux-arm64
|
||||
|
||||
chmod +x dist/*
|
||||
|
||||
cd dist
|
||||
|
||||
zip escape_room_server-linux-x86_64.zip escape_room_server-linux-x86_64
|
||||
zip escape_room_server-linux-arm64.zip escape_room_server-linux-arm64
|
||||
|
||||
# -----------------------------
|
||||
# Upload artifacts (CI downloads)
|
||||
# -----------------------------
|
||||
- name: upload-artifacts
|
||||
# =========================
|
||||
# 📦 ARTIFACT UPLOAD
|
||||
# =========================
|
||||
- name: upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: escape-room-binaries
|
||||
path: dist/*.zip
|
||||
path: |
|
||||
target/x86_64-unknown-linux-gnu/release/escape_room_server
|
||||
target/aarch64-unknown-linux-gnu/release/escape_room_server
|
||||
|
||||
# -----------------------------
|
||||
# Create Git release on tags
|
||||
# -----------------------------
|
||||
- name: create-release
|
||||
if: startsWith(gitea.ref, 'refs/tags/v')
|
||||
uses: softprops/action-gh-release@v2
|
||||
# =========================
|
||||
# 🚀 CREATE GITEA RELEASE (only on tags)
|
||||
# =========================
|
||||
- name: create release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/create-release@v1
|
||||
with:
|
||||
files: dist/*.zip
|
||||
tag_name: ${{ github.ref_name }}
|
||||
release_name: Release ${{ github.ref_name }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# =========================
|
||||
# 📎 UPLOAD RELEASE ASSETS
|
||||
# =========================
|
||||
- name: upload release assets
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: target/x86_64-unknown-linux-gnu/release/escape_room_server
|
||||
asset_name: escape_room_server-x86_64
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
Reference in New Issue
Block a user