name: build-service on: push: branches: - main tags: - "v*" permissions: contents: write jobs: compile-binaries: runs-on: ubuntu-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 }}- # ----------------------------- # 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 run: cargo build --release --target x86_64-unknown-linux-gnu # ----------------------------- # Build ARM64 (via cross) # ----------------------------- - 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 uses: actions/upload-artifact@v4 with: name: escape-room-binaries path: dist/*.zip # ----------------------------- # Create Git release on tags # ----------------------------- - name: create-release if: startsWith(gitea.ref, 'refs/tags/v') uses: softprops/action-gh-release@v2 with: files: dist/*.zip