name: "Release"
on:
create:
tags:
- v*
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: "Release"
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
cross: false
- build: arm-v7
os: ubuntu-latest
rust: stable
target: armv7-unknown-linux-gnueabihf
linker: gcc-arm-linux-gnueabihf
cross: true
- build: aarch64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
linker: gcc-aarch64-linux-gnu
cross: true
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
- build: windows
os: ubuntu-latest
rust: stable
target: x86_64-pc-windows-gnu
linker: mingw-w64
cross: true
steps:
- name: "Check out code"
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: "Set variables"
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: "Caching cargo & rustup"
uses: actions/cache@v2.1.6
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-${{ matrix.rust }}
- name: "Install Linker"
if: matrix.cross
run: |
sudo apt update
sudo apt install ${{ matrix.linker }}
- name: "Add target build"
run: |
rustup install ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
rustup show
- name: "Build package"
run: cargo build --release --target ${{ matrix.target }}
- name: "Package artifacts"
run: |
echo "Set base path & make temp dir..."
BASE=$(pwd)
TEMP=$(mktemp -d $([[ "${RUNNER_OS}" == "macOS" ]] && echo "-t tmp"))
echo "Copy release binary & CD to temp dir..."
cp "target/${{ matrix.target }}/release/${{ github.event.repository.name }}$([[ "${{ matrix.build }}" == "windows" ]] && echo ".exe")" "${TEMP}/"
cd "${TEMP}"
echo "Set assets variable"
ASSET_NAME="${{ github.event.repository.name }}-${{ steps.vars.outputs.tag }}-${{ matrix.target }}.$([[ "${{ matrix.build }}" != "windows" ]] && echo "tar.gz" || echo "exe")"
ASSET_PATH="${BASE}/${ASSET_NAME}"
echo "Append assets variable to GitHub environment"
echo "ASSET_PATH=${ASSET_PATH}" >> $GITHUB_ENV
echo "Pack/copying asset binary..."
[[ "${{ matrix.build }}" != "windows" ]] && tar czf "${ASSET_PATH}" * || cp "${{ github.event.repository.name }}.exe" "${ASSET_PATH}"
cd "${BASE}"
- name: "Release assets"
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ASSET_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}