name: Release
on:
push:
tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Release ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
os-type: linux
architecture: x86_64
target: x86_64-unknown-linux-gnu
binutils-target: ''
use-cross: false
- os: ubuntu-latest
os-type: linux
architecture: i686
target: i686-unknown-linux-gnu
binutils-target: ''
use-cross: true
- os: ubuntu-latest
os-type: linux
architecture: arm64
target: aarch64-unknown-linux-gnu
binutils-target: aarch64-linux-gnu
use-cross: true
- os: windows-latest
os-type: windows
architecture: x86_64
target: x86_64-pc-windows-msvc
binutils-target: ''
use-cross: false
- os: macos-latest
os-type: macos
architecture: x86_64
target: x86_64-apple-darwin
binutils-target: ''
use-cross: false
steps:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install strip
if: ${{ matrix.binutils-target != '' }}
shell: bash
run: |
sudo apt update
sudo apt-get install -y binutils-${{ matrix.binutils-target }}
- name: Checkout sources
uses: actions/checkout@v2
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross }}
- name: Package binaries
shell: bash
run: |
VERSION=${GITHUB_REF/refs\/tags\/v/}
REALEASE=rew-$VERSION-${{ matrix.os-type }}-${{ matrix.architecture }}
BINARIES=(rew cpb mvb)
STRIP=strip
if [[ ${{ runner.os }} == Windows ]]; then
BINARIES=(${BINARIES[@]/%/.exe})
fi
if [[ '${{ matrix.binutils-target }}' ]]; then
STRIP=${{ matrix.binutils-target }}-$STRIP
fi
cd target/${{ matrix.target }}/release
$STRIP "${BINARIES[@]}"
tar czvf $REALEASE.tar.gz "${BINARIES[@]}"
if [[ ${{ runner.os }} == Windows ]]; then
certutil -hashfile $REALEASE.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $REALEASE.sha256
else
shasum -a 256 $REALEASE.tar.gz > $REALEASE.sha256
fi
- name: Upload release
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/release/rew-*.tar.gz
target/${{ matrix.target }}/release/rew-*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Run cargo publish
uses: actions-rs/cargo@v1
with:
command: publish
args: --allow-dirty --token ${{ secrets.CARGO_API_KEY }}