more fixes to build #95
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: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
env: | |
BIN_NAME: trane | |
PROJECT_NAME: trane-cli | |
REPO_NAME: trane-project/trane-cli | |
jobs: | |
dist: | |
name: Dist | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false # don't fail other jobs if one fails | |
matrix: | |
build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows] | |
include: | |
- build: x86_64-linux | |
os: ubuntu-20.04 | |
rust: stable | |
target: x86_64-unknown-linux-gnu | |
cargo_cmd: cargo | |
- build: aarch64-linux | |
os: ubuntu-20.04 | |
rust: stable | |
target: aarch64-unknown-linux-gnu | |
cargo_cmd: cross | |
- build: x86_64-macos | |
os: macos-latest | |
rust: stable | |
target: x86_64-apple-darwin | |
cargo_cmd: cross | |
- build: x86_64-windows | |
os: windows-latest | |
rust: stable | |
target: x86_64-pc-windows-msvc | |
cargo_cmd: cargo | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install ${{ matrix.rust }} toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
profile: minimal | |
toolchain: 1.73.0 | |
target: ${{ matrix.target }} | |
override: true | |
- name: Install cross | |
run: cargo install --version 0.1.16 cross | |
- name: Install libssl-dev | |
run: sudo apt install -y libssl-dev | |
- name: Run cargo test | |
run: ${{ matrix.cargo_cmd }} test --release --locked --target ${{ matrix.target }} | |
- name: Build release binary | |
run: ${{ matrix.cargo_cmd }} build --release --locked --target ${{ matrix.target }} | |
- name: Strip release binary (linux and macos) | |
if: matrix.build == 'x86_64-linux' || matrix.build == 'x86_64-macos' | |
run: strip "target/${{ matrix.target }}/release/$BIN_NAME" | |
- name: Strip release binary (arm) | |
if: matrix.build == 'aarch64-linux' | |
run: | | |
docker run --rm -v \ | |
"$PWD/target:/target:Z" \ | |
rustembedded/cross:${{ matrix.target }} \ | |
aarch64-linux-gnu-strip \ | |
/target/${{ matrix.target }}/release/$BIN_NAME | |
- name: Build archive | |
shell: bash | |
run: | | |
mkdir dist | |
if [ "${{ matrix.os }}" = "windows-2019" ]; then | |
cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/" | |
else | |
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/" | |
fi | |
- uses: actions/[email protected] | |
with: | |
name: bins-${{ matrix.build }} | |
path: dist | |
publish: | |
name: Publish | |
needs: [dist] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
submodules: false | |
- uses: actions/[email protected] | |
- run: ls -al bins-* | |
- name: Calculate tag name | |
run: | | |
name=dev | |
if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
name=${GITHUB_REF:10} | |
fi | |
echo ::set-output name=val::$name | |
echo TAG=$name >> $GITHUB_ENV | |
id: tagname | |
- name: Build archive | |
shell: bash | |
run: | | |
set -ex | |
rm -rf tmp | |
mkdir tmp | |
mkdir dist | |
for dir in bins-* ; do | |
platform=${dir#"bins-"} | |
unset exe | |
if [[ $platform =~ "windows" ]]; then | |
exe=".exe" | |
fi | |
pkgname=$PROJECT_NAME-$TAG-$platform | |
mkdir tmp/$pkgname | |
# cp LICENSE README.md tmp/$pkgname | |
mv bins-$platform/$BIN_NAME$exe tmp/$pkgname | |
chmod +x tmp/$pkgname/$BIN_NAME$exe | |
if [ "$exe" = "" ]; then | |
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname | |
else | |
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname) | |
fi | |
done | |
- name: Upload binaries to release | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/* | |
file_glob: true | |
tag: ${{ steps.tagname.outputs.val }} | |
overwrite: true | |
- name: Extract version | |
id: extract-version | |
run: | | |
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}" |