From 51a8a379371dd39ec0647daef2757182764702f0 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 13 May 2024 12:10:01 +0200 Subject: [PATCH] Add Release CI Signed-off-by: Oliver Tale-Yazdi --- .github/workflows/release_binaries.yml | 64 +++++++++++++++++--------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release_binaries.yml b/.github/workflows/release_binaries.yml index ace19c1..f4f7d80 100644 --- a/.github/workflows/release_binaries.yml +++ b/.github/workflows/release_binaries.yml @@ -1,29 +1,51 @@ -name: Build and Upload Release Binaries +name: Release on: release: - types: [published] + types: + - created + workflow_dispatch: jobs: - release: - name: release ${{ matrix.target }} - runs-on: self-hosted + build_and_upload: strategy: - fail-fast: false matrix: - include: - - target: x86_64-pc-windows-gnu - archive: zip - - target: x86_64-unknown-linux-musl - archive: tar.gz tar.xz tar.zst - - target: x86_64-apple-darwin - archive: zip + platform: + - { os: ubuntu-latest, target: x86_64-unknown-linux-musl } + - { os: macos-latest, target: x86_64-apple-darwin } + + runs-on: ${{ matrix.platform.os }} + steps: - - uses: actions/checkout@master - - name: Compile and release - uses: rust-build/rust-build.action@v1.4.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - RUSTTARGET: ${{ matrix.target }} - ARCHIVE_TYPES: ${{ matrix.archive }} + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Add target + run: rustup target add ${{ matrix.platform.target }} + + - name: Install deps for musl build + if: matrix.platform.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y musl-tools clang build-essential curl llvm-dev libclang-dev linux-headers-generic libsnappy-dev liblz4-dev libzstd-dev libgflags-dev zlib1g-dev libbz2-dev + sudo ln -s /usr/bin/g++ /usr/bin/musl-g++ + + - name: Build + run: cargo build --release --target ${{ matrix.platform.target }} + + - name: Upload Binary to Release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./target/${{ matrix.platform.target }}/release/zepter + asset_name: zepter-${{ matrix.platform.target }} + asset_content_type: application/octet-stream + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}