Skip to content

Commit

Permalink
Add cross-release deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminSchaaf committed Nov 22, 2022
1 parent cf1c758 commit c44150b
Showing 1 changed file with 76 additions and 5 deletions.
81 changes: 76 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
name: Rust

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push]

env:
CARGO_TERM_COLOR: always

jobs:
build:
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest

steps:
Expand All @@ -28,3 +25,77 @@ jobs:
run: cargo test --verbose -p sbnf
- name: Build CLI
run: cargo build --verbose -p sbnfc

deploy-executables:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ${{ matrix.OS }}

strategy:
fail-fast: false
matrix:
include:
- TARGET: x86_64-unknown-linux-gnu
OS: ubuntu-latest
- TARGET: aarch64-unknown-linux-gnu
OS: ubuntu-latest
- TARGET: x86_64-apple-darwin
OS: macos-latest
- TARGET: x86_64-pc-windows-msvc
OS: windows-latest

env:
TARGET: ${{ matrix.TARGET }}
OS: ${{ matrix.OS }}
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install and configure dependencies
shell: bash
run: |
set -e -v -x
if [[ $ubuntu-latest ]]; then
if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then
sudo apt-get install -qq crossbuild-essential-arm64
fi
# Some additional configuration for cross-compilation on linux
cat >>~/.cargo/config <<EOF
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
fi
- name: Install rust target
shell: bash
run: rustup target add $TARGET
- name: Run build
shell: bash
run: cargo build --release --verbose --target $TARGET
- name: Compress
shell: bash
run: |
set -e -v -x
mkdir artifacts out
# windows is the only OS using a different convention for executable file name
if [[ $OS =~ ^windows.*$ ]]; then
EXEC=sbnf.exe
else
EXEC=sbnf
fi
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
TAG=$GITHUB_REF_NAME
else
TAG=$GITHUB_SHA
fi
mv ./target/$TARGET/release/$EXEC ./out/$EXEC
tar -cJf ./artifacts/sbnf-compiler-$TARGET-$TAG.tar.xz -C ./out $EXEC
- name: Archive artifact
uses: softprops/action-gh-release@v1
with:
files: './artifacts/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit c44150b

Please sign in to comment.