diff --git a/.gitea/workflows/compile.yaml b/.gitea/workflows/compile.yaml new file mode 100644 index 0000000..39b7ca1 --- /dev/null +++ b/.gitea/workflows/compile.yaml @@ -0,0 +1,89 @@ +name: Compile to Binary +on: + push: + branches: [ main, master, dev ] + pull_request: + branches: [ main, master ] + workflow_dispatch: + +jobs: + build-linux: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + uses: https://github.com/dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: x86_64-unknown-linux-gnu + + - name: Cache Cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Build for Linux + run: cargo build --release --target x86_64-unknown-linux-gnu + + - name: Copy Linux executable + run: | + mkdir -p artifacts + cp target/x86_64-unknown-linux-gnu/release/http-rs artifacts/http-rs-linux-x86_64 + + - name: Upload Linux artifact + uses: actions/upload-artifact@v3 + with: + name: http-rs-linux-x86_64 + path: artifacts/http-rs-linux-x86_64 + if-no-files-found: error + + build-windows: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + uses: https://github.com/dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: x86_64-pc-windows-gnu + + - name: Install MinGW cross-compiler + run: | + sudo apt-get update + sudo apt-get install -y gcc-mingw-w64-x86-64 + + - name: Cache Cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-windows-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-windows- + + - name: Build for Windows + run: cargo build --release --target x86_64-pc-windows-gnu + + - name: Copy Windows executable + run: | + mkdir -p artifacts + cp target/x86_64-pc-windows-gnu/release/http-rs.exe artifacts/http-rs-windows-x86_64.exe + + - name: Upload Windows artifact + uses: actions/upload-artifact@v3 + with: + name: http-rs-windows-x86_64 + path: artifacts/http-rs-windows-x86_64.exe + if-no-files-found: error