Skip to content

Commit

Permalink
ci: Update build to use cross
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed May 24, 2024
1 parent 6eaa704 commit fec1cd8
Showing 1 changed file with 27 additions and 79 deletions.
106 changes: 27 additions & 79 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,104 +27,52 @@ jobs:
- name: Build
run: cargo build --verbose

build-x86_64:
needs: check
runs-on: ubuntu-20.04 # allow usage with older libc
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
TARGET: aarch64-unknown-linux-gnu

- os: ubuntu-latest
TARGET: armv7-unknown-linux-gnueabihf

- os: ubuntu-latest
TARGET: x86_64-unknown-linux-musl
steps:
- name: Building ${{ matrix.TARGET }}
run: echo "${{ matrix.TARGET }}"

- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1.0.1
with:
toolchain: stable
target: ${{ matrix.TARGET }}
override: true

- name: Install linux libraries
run: |
uname -a
sudo apt update
sudo apt install -y libudev-dev
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --verbose --release
args: --verbose --release --target=${{ matrix.TARGET }}

- name: Rename
run: cp target/release/linux2rest linux2rest-x86_64

- uses: actions/upload-artifact@master
with:
name: linux2rest-x86_64
path: linux2rest-x86_64

- uses: svenstaro/upload-release-action@v2
name: Upload binaries to release
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')}}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: linux2rest-x86_64
asset_name: linux2rest-x86_64
tag: ${{ github.ref }}
overwrite: true
run: cp target/${{ matrix.TARGET }}/release/linux2rest${{ matrix.EXTENSION }} linux2rest-${{ matrix.TARGET }}${{ matrix.EXTENSION }}

build-armv7:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Restore cache
uses: actions/cache@v2
id: cache
with:
path: /tmp/.cache
key: ${{ runner.os }}-cargo-armv7-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-armv7-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}
${{ runner.os }}-cargo-armv7-${{ hashFiles('Cargo.toml') }}
${{ runner.os }}-cargo-armv7
- uses: uraimo/run-on-arch-action@v2.7.1
id: runcmd
with:
arch: armv7
distro: ubuntu18.04
githubToken: ${{ github.token }}
setup: |
mkdir -p /tmp/.cache
install: |
uname -a
apt update
apt install -y libudev-dev curl gcc
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
cargo install sccache --no-default-features
dockerRunArgs: |
--volume "/tmp/.cache:/tmp/.cache"
run: |
export SCCACHE_DIR=/tmp/.cache
export PATH="$HOME/.cargo/bin:$PATH"
apt install -y pkg-config libudev-dev libssl-dev openssl git
sccache --show-stats
# Fix issues related to git unable to use current directory since its not from current user
git config --global --add safe.directory '*'
RUSTC_WRAPPER=sccache cargo build --verbose --release --features raspberry
sccache --show-stats
- name: Rename
run: |
cp target/release/linux2rest linux2rest-armv7
- name: Fix cache owner
run: |
sudo chown $(whoami) -R /tmp/.cache
- uses: actions/upload-artifact@master
with:
name: linux2rest-armv7
path: linux2rest-armv7
name: linux2rest-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
path: linux2rest-${{ matrix.TARGET }}${{ matrix.EXTENSION }}

- uses: svenstaro/upload-release-action@v2
name: Upload binaries to release
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')}}
if: ${{ github.event_name == 'push' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: linux2rest-armv7
asset_name: linux2rest-armv7
file: linux2rest-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
asset_name: linux2rest-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
tag: ${{ github.ref }}
prerelease: true
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
overwrite: true

0 comments on commit fec1cd8

Please sign in to comment.