Release #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
release: | |
types: [published] | |
jobs: | |
build: | |
name: Build ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
name: [linux, windows, macOS] | |
include: | |
- name: linux | |
target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
- name: windows | |
target: x86_64-pc-windows-msvc | |
os: windows-latest | |
- name: macOS | |
target: x86_64-apple-darwin | |
os: macOS-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Install packages (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends musl-tools | |
- name: Build | |
shell: bash | |
run: | | |
cargo build --release --target "${{ matrix.target }}" | |
if [ "${{ runner.os }}" = "Windows" ]; then | |
bin="target/${{ matrix.target }}/release/modiom.exe" | |
else | |
bin="target/${{ matrix.target }}/release/modiom" | |
fi | |
echo "BIN=$bin" >>"$GITHUB_ENV" | |
- name: Determine archive name | |
shell: bash | |
run: | | |
version="$GITHUB_REF_NAME" | |
echo "ARCHIVE=modiom-$version-${{ matrix.target }}" >>"$GITHUB_ENV" | |
- name: Creating directory for archive | |
shell: bash | |
run: | | |
mkdir -p "$ARCHIVE" | |
cp "$BIN" "$ARCHIVE"/ | |
cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$ARCHIVE/" | |
- name: Build archive (Windows) | |
shell: bash | |
if: runner.os == 'Windows' | |
run: | | |
7z a "$ARCHIVE.zip" "$ARCHIVE" | |
certutil -hashfile "$ARCHIVE.zip" SHA256 >"$ARCHIVE.zip.sha256" | |
echo "ASSET=$ARCHIVE.zip" >>"$GITHUB_ENV" | |
echo "ASSET_SUM=$ARCHIVE.zip.sha256" >>"$GITHUB_ENV" | |
- name: Build archive (Unix) | |
shell: bash | |
if: runner.os != 'Windows' | |
run: | | |
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE" | |
shasum -a 256 "$ARCHIVE.tar.gz" >"$ARCHIVE.tar.gz.sha256" | |
echo "ASSET=$ARCHIVE.tar.gz" >>"$GITHUB_ENV" | |
echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >>"$GITHUB_ENV" | |
- name: Upload release archive | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash | |
run: | |
version="$GITHUB_REF_NAME" | |
gh release upload "$version" "$ASSET" "$ASSET_SUM" |