Skip to content

ci: clean up Windows-specific scripts #64

ci: clean up Windows-specific scripts

ci: clean up Windows-specific scripts #64

Workflow file for this run

name: Build
on: [push, workflow_dispatch]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
jobs:
build:
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-pc-windows-gnu
- aarch64-linux-android
- x86_64-pc-windows-msvc
env:
RUST_BACKTRACE: full
RUSTFLAGS: ${{ contains(matrix.target, 'msvc') && '-C target-feature=+crt-static' || '' }}
runs-on: ${{ contains(matrix.target, 'msvc') && 'windows-latest' || 'ubuntu-latest' }}
defaults:
run:
shell: ${{ contains(matrix.target, 'msvc') && 'msys2 {0}' || 'bash' }}
steps:
- name: Cleanup pre-installed tools
if: runner.os != 'Windows'
run: |
# This is a fix for https://github.com/actions/virtual-environments/issues/1918
shopt -s nullglob
sudo rm -rf /usr/share/{dotnet,swift,az*,gradle*,*conda} \
/opt/{ghc,az} \
/usr/local/share/boost /usr/local/graalvm /usr/local/julia* "$AGENT_TOOLSDIRECTORY"
- uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
with:
path-type: inherit
- uses: actions/checkout@v2
- name: Use GNU tar for cache
if: runner.os == 'Windows'
shell: cmd
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.target }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Install cross
run: |
cross --version || {
cargo install cross --git https://github.com/cross-rs/cross;
cross --version;
}
echo CARGO=cross >> "$GITHUB_ENV"
if: matrix.target != 'x86_64-unknown-linux-gnu' && matrix.target != 'x86_64-pc-windows-msvc'
- name: Build ${{ matrix.target }}
run: |
set -e
cargo update
target=${{ matrix.target }}
${CARGO:=cargo} build --release --target $target
if [[ $target == *windows* ]]; then
ext=.exe
fi
if [ "$CARGO" = cross ]; then
bin=target/$target/release/pvg$ext
else
bin=target/release/pvg$ext
fi
FILE=pvg-${GITHUB_SHA::7}-$target.xz
echo "FILE=$FILE" >> $GITHUB_ENV
xz -cv $bin > $FILE
- uses: actions/upload-artifact@v3
with:
name: ${{ env.FILE }}
path: ${{ env.FILE }}