Skip to content

Workflow file for this run

name: Tests and release
on: [push, pull_request]
env:
CRATE_NAME: smrec
GITHUB_TOKEN: ${{ github.token }}
RUST_BACKTRACE: 1
jobs:
test:
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
# Linux
- os_name: FreeBSD-x86_64
os: ubuntu-20.04
target: x86_64-unknown-freebsd
bin: smrec
name: smrec-FreeBSD-x86_64.tar.gz
skip_tests: true
- os_name: Linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-musl
bin: smrec
name: smrec-Linux-x86_64-musl.tar.gz
- os_name: Linux-i686
os: ubuntu-20.04
target: i686-unknown-linux-musl
bin: smrec
name: smrec-Linux-i686-musl.tar.gz
skip_tests: true
# Linux Arm
- os_name: Linux-aarch64
os: ubuntu-20.04
target: aarch64-unknown-linux-musl
bin: smrec
name: smrec-Linux-aarch64-musl.tar.gz
- os_name: Linux-arm
os: ubuntu-20.04
target: arm-unknown-linux-musleabi
bin: smrec
name: smrec-Linux-arm-musl.tar.gz
# Linux RiscV
- os_name: Linux-riscv64
os: ubuntu-20.04
target: riscv64gc-unknown-linux-gnu
bin: smrec
name: smrec-Linux-riscv64gc-gnu.tar.gz
# Windows
- os_name: Windows-aarch64
os: windows-latest
target: aarch64-pc-windows-msvc
bin: smrec.exe
name: smrec-Windows-aarch64.zip
skip_tests: true
- os_name: Windows-i686
os: windows-latest
target: i686-pc-windows-msvc
bin: smrec.exe
name: smrec-Windows-i686.zip
skip_tests: true
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
bin: smrec.exe
name: smrec-Windows-x86_64.zip
# macOS
- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
bin: smrec
name: smrec-Darwin-x86_64.tar.gz
- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
bin: smrec
name: smrec-Darwin-aarch64.tar.gz
skip_tests: true
toolchain:
- stable
# - beta
# - nightly
steps:
- uses: actions/checkout@v4
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: "v2"
# Why?
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Ali Somay"
#
- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.name, 'musl')
- name: Install ALSA and JACK development libraries
run: sudo apt-get update --yes && sudo apt-get install -yes libasound2-dev libjack-jackd2-dev
if: contains(matrix.platform.os, 'ubuntu')
# - name: Cache LLVM
# id: cache-llvm
# if: contains(matrix.platform.os ,'windows-latest')
# uses: actions/cache@v3
# with:
# path: |
# C:\Program Files\LLVM
# key: ${{ matrix.platform.os }}-${{ matrix.platform.arch }}-llvm-17.0.4 # Adjust version as needed
# restore-keys: |
# ${{ matrix.platform.os }}-${{ matrix.platform.arch }}-llvm-17.0.4
# - name: Download and Install LLVM
# if: steps.cache-llvm.outputs.cache-hit != 'true' && matrix.platform.os == 'windows-latest'
# run: |
# $arch = if ($env:ARCH -eq 'x86_64') { "win64" } else { "woa64" }
# $url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.4/LLVM-17.0.4-$arch.exe"
# echo "Downloading LLVM from $url" # Debugging line
# $output = ".\llvm-installer.exe"
# Invoke-WebRequest -Uri $url -OutFile $output
# $process = Start-Process $output -ArgumentList "/S" -NoNewWindow -PassThru
# $process.WaitForExit()
# shell: powershell
# env:
# ARCH: ${{ matrix.platform.arch }}
# - name: Set LIBCLANG_PATH
# if: matrix.platform.os == 'windows-latest'
# run: |
# echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
# # Debug: Print the LIBCLANG_PATH environment variable
# echo "LIBCLANG_PATH: $env:LIBCLANG_PATH"
# # Debug: Check if libclang.dll is present
# Test-Path "C:\Program Files\LLVM\bin\libclang.dll"
# shell: powershell
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--locked --release"
strip: true
- name: Run tests
uses: houseabsolute/actions-rust-cross@v0
with:
command: "test"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--locked --release"
if: ${{ !matrix.platform.skip_tests }}
- name: Package as archive
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
else
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
fi
cd -
if: |
matrix.toolchain == 'stable' &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
- name: Publish release artifacts
uses: actions/upload-artifact@v3
with:
name: smrec-${{ matrix.platform.os_name }}
path: "smrec-*"
if: matrix.toolchain == 'stable' && github.ref == 'refs/tags/test-release'
- name: Generate SHA-256
run: shasum -a 256 ${{ matrix.platform.name }}
if: |
matrix.toolchain == 'stable' &&
matrix.platform.os == 'macOS-latest' &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
files: "smrec*"
body_path: Changes.md
if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' )