fix: remove un-needed clones #14
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: Rust | |
on: | |
push: | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
./target | |
key: test-cargo-registry | |
- name: Run tests | |
run: cargo test --verbose | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- TARGET: x86_64-unknown-linux-gnu | |
OS: ubuntu-latest | |
- TARGET: aarch64-unknown-linux-gnu | |
OS: ubuntu-latest | |
- TARGET: armv7-unknown-linux-gnueabihf | |
OS: ubuntu-latest | |
needs: test | |
runs-on: ${{ matrix.OS }} | |
env: | |
NAME: bright | |
TARGET: ${{ matrix.TARGET }} | |
OS: ${{ matrix.OS }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
./target | |
key: build-cargo-registry-${{matrix.TARGET}} | |
- name: List | |
run: find ./ | |
- name: Install and configure dependencies | |
run: | | |
# dependencies are only needed on ubuntu as that's the only place where | |
# we make cross-compilation | |
if [[ $OS =~ ^ubuntu.*$ ]]; then | |
sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf musl-tools libssl-dev | |
fi | |
# some additional configuration for cross-compilation on linux | |
cat >>~/.cargo/config <<EOF | |
[target.aarch64-unknown-linux-gnu] | |
linker = "aarch64-linux-gnu-gcc" | |
[target.aarch64-unknown-linux-musl] | |
linker = "aarch64-linux-gnu-gcc" | |
[target.armv7-unknown-linux-gnueabihf] | |
linker = "arm-linux-gnueabihf-gcc" | |
[target.armv7-unknown-linux-musleabihf] | |
linker = "arm-linux-gnueabihf-gcc" | |
[target.arm-unknown-linux-gnueabihf] | |
linker = "arm-linux-gnueabihf-gcc" | |
[target.arm-unknown-linux-musleabihf] | |
linker = "arm-linux-gnueabihf-gcc" | |
EOF | |
- name: Install rust target | |
run: rustup target add $TARGET | |
- name: Run build | |
run: cargo build --release --verbose --target $TARGET | |
- name: Compress | |
run: | | |
mkdir -p ./artifacts | |
EXEC=$NAME | |
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then | |
TAG=$GITHUB_REF_NAME | |
else | |
TAG=$GITHUB_SHA | |
fi | |
mv ./target/$TARGET/release/$EXEC ./$EXEC | |
tar -czf ./artifacts/$NAME-$TARGET-$TAG.tar.gz $EXEC | |
- name: Archive artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.TARGET }} | |
path: | | |
./artifacts | |
# deploys to github releases on tag | |
deploy: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
merge-multiple: 'true' | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./artifacts/*.tar.gz |