Skip to content

chore: Update toolchain installation in cd.yml #9

chore: Update toolchain installation in cd.yml

chore: Update toolchain installation in cd.yml #9

Workflow file for this run

# This checks out the code, and compiles and uploads the binaries.
name: CD
on:
push:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "full"
concurrency:
group: CD-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build - ${{ matrix.binary}} for ${{ matrix.platform.os_name }}
strategy:
matrix:
binary: [mecomp-tui, mecomp-cli, mecomp-daemon]
platform:
- os_name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
- os_name: Windows-aarch64
os: windows-latest
target: aarch64-pc-windows-msvc
- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.os, 'ubuntu')
- name: Install linux dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends libasound2-dev pkg-config wget libavutil-dev libavformat-dev
if: contains(matrix.platform.os, 'ubuntu')
- name: Setup cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build binary (Linux)
shell: bash
run: |
PKG_CONFIG_SYSROOT_DIR=/ cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }}
if: ${{ contains(matrix.platform.os, 'ubuntu') }}
- name: Build binary (macOS)
run: |
cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }}
if: ${{ contains(matrix.platform.os, 'macOS') }}
- name: Build binary (Windows)
# We have to use the platform's native shell. If we use bash on
# Windows then OpenSSL complains that the Perl it finds doesn't use
# the platform's native paths and refuses to build.
shell: powershell
run: |
& cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }}
if: contains(matrix.platform.os, 'windows')
- name: Package as archive
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ../../../${{ matrix.binary }}-${{ matrix.platform.os_name }}.zip ${{ matrix.binary }}.exe
else
chmod +x ${{ matrix.binary }}
tar czvf ../../../${{ matrix.binary }}-${{ matrix.platform.os_name }}.tar.gz ${{ matrix.binary }}
fi
cd -
- name: Publish build artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.binary }}-${{ matrix.platform.os_name }}
path: "${{ matrix.binary }}-${{ matrix.platform.os_name }}.*"