Skip to content

Artifacts

Artifacts #6

Workflow file for this run

on:
workflow_dispatch:
name: Artifacts
env:
RELEASE_BIN: dovi_meta
RELEASE_DIR: artifacts
WINDOWS_TARGET: x86_64-pc-windows-msvc
MACOS_X86_TARGET: x86_64-apple-darwin
MACOS_ARM_TARGET: aarch64-apple-darwin
LINUX_TARGET: x86_64-unknown-linux-musl
jobs:
build:
name: Build artifacts
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [Linux, macOS, Windows]
include:
- build: Linux
os: ubuntu-latest
- build: macOS
os: macos-latest
- build: Windows
os: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Get the version
shell: bash
run: |
echo "RELEASE_PKG_VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)" >> $GITHUB_ENV
- name: Install musl-tools (Linux)
if: matrix.build == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install musl-tools -y
- name: Build (Linux)
if: matrix.build == 'Linux'
run: |
rustup target add ${{ env.LINUX_TARGET }}
cargo build --release --target ${{ env.LINUX_TARGET }}
- name: Build (macOS)
if: matrix.build == 'macOS'
run: |
rustup target add ${{ env.MACOS_ARM_TARGET }}
cargo build --release
cargo build --release --target ${{ env.MACOS_ARM_TARGET }}
- name: Build (Windows)
if: matrix.build == 'Windows'
run: cargo build --release
- name: Install cargo-c (Windows)
if: matrix.build == 'Windows'
run: |
$LINK = "https://github.com/lu-zero/cargo-c/releases/latest/download"
$CARGO_C_FILE = "cargo-c-windows-msvc"
curl -LO "$LINK/$CARGO_C_FILE.zip"
7z e -y "$CARGO_C_FILE.zip" -o"${env:USERPROFILE}\.cargo\bin"
- name: Create artifact directory
run: |
mkdir ${{ env.RELEASE_DIR }}
- name: Create tarball (Linux)
if: matrix.build == 'Linux'
run: |
strip ./target/${{ env.LINUX_TARGET }}/release/${{ env.RELEASE_BIN }}
mv ./target/${{ env.LINUX_TARGET }}/release/${{ env.RELEASE_BIN }} ./${{ env.RELEASE_BIN }}
tar -cvzf ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ env.RELEASE_PKG_VERSION }}-${{ env.LINUX_TARGET }}.tar.gz ./${{ env.RELEASE_BIN }}
- name: Create zipfile (Windows)
if: matrix.build == 'Windows'
shell: bash
run: |
mv ./target/release/${{ env.RELEASE_BIN }}.exe ./${{ env.RELEASE_BIN }}.exe
7z a ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ env.RELEASE_PKG_VERSION }}-${{ env.WINDOWS_TARGET }}.zip ./${{ env.RELEASE_BIN }}.exe
- name: Create universal macOS binary
if: matrix.build == 'macOS'
run: |
strip ./target/release/${{ env.RELEASE_BIN }}
strip ./target/aarch64-apple-darwin/release/${{ env.RELEASE_BIN }}
lipo -create \
./target/aarch64-apple-darwin/release/${{ env.RELEASE_BIN }} \
./target/release/${{ env.RELEASE_BIN }} \
-output ./${{ env.RELEASE_BIN }}
- name: Create zipfile (macOS)
if: matrix.build == 'macOS'
run: |
zip -9 ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ env.RELEASE_PKG_VERSION }}-universal-macOS.zip ./${{ env.RELEASE_BIN }}
- name: Upload Zip
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.build }}
path: ./${{ env.RELEASE_DIR }}