From fbb04b52592b60ce1065b5710f38db6a7732bfba Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Mon, 4 Mar 2024 16:04:32 +0100 Subject: [PATCH] ci: Create Github build action for release --- .github/workflows/release.yml | 78 +++++++++++++++++++++++++++++++++++ .github/workflows/rust.yml | 22 ---------- 2 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..923a17f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +name: Release + +on: + push: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + release-linux-binaries: + permissions: + contents: 'read' + id-token: 'write' + runs-on: ubuntu-20.04 + strategy: + matrix: + target: [x86_64-unknown-linux-musl, aarch64-unknown-linux-musl] + include: + - target: x86_64-unknown-linux-musl + docker_image: registry.gitlab.com/rust_musl_docker/image:stable-latest + docker_options: -v /home/runner/work/radicle-tui/radicle-tui:/workdir -v /home/runner/.cargo/git:/root/.cargo/git -v /home/runner/.cargo/registry:/root/.cargo/registry + - target: aarch64-unknown-linux-musl + docker_image: messense/rust-musl-cross:aarch64-musl + docker_options: -v /home/runner/work/radicle-tui/radicle-tui:/home/rust/src -v /home/runner/.cargo/git:/root/.cargo/git -v /home/runner/.cargo/registry:/root/.cargo/registry + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Configure build cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} + - name: Build release binaries + uses: addnab/docker-run-action@v3 + with: + image: ${{ matrix.docker_image }} + options: ${{ matrix.docker_options }} + run: cargo build --release --target "${{ matrix.target }}" + - name: Upload release binaries + uses: actions/upload-artifact@v4 + with: + name: rad-tui_${{ github.sha }}_${{ matrix.target }} + path: target/${{ matrix.target }}/release/rad-tui + + release-macos-binaries: + permissions: + contents: 'read' + id-token: 'write' + runs-on: macos-11 + strategy: + matrix: + target: + - aarch64-apple-darwin + - x86_64-apple-darwin + steps: + - uses: actions/checkout@v3 + - name: Configure build cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} + - uses: dtolnay/rust-toolchain@1.74 + - name: Build release binaries + run: | + rustup target add "${{ matrix.target }}" + cargo build --release --target "${{ matrix.target }}" + - name: Upload release binaries + uses: actions/upload-artifact@v4 + with: + name: rad-tui_${{ github.sha }}_${{ matrix.target }} + path: target/${{ matrix.target }}/release/rad-tui diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index de196d3..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Rust - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build - run: cargo build --release --verbose - - name: Run tests - run: cargo test --verbose