Skip to content

Commit

Permalink
ci: clean up Windows-specific scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
karin0 committed Oct 27, 2023
1 parent f5f2358 commit 7b93c58
Showing 1 changed file with 20 additions and 38 deletions.
58 changes: 20 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
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'
Expand All @@ -28,6 +31,11 @@ jobs:
/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
Expand Down Expand Up @@ -55,54 +63,28 @@ jobs:
profile: minimal
default: true

- run: cargo install cross --git https://github.com/cross-rs/cross
continue-on-error: true
if: matrix.target != 'x86_64-unknown-linux-gnu' && runner.os != 'Windows'
- name: Install cross
run: |
cargo install cross --git https://github.com/cross-rs/cross || true
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 }}
if: runner.os != 'Windows'
shell: bash
run: |
set -e
cargo update
target=${{ matrix.target }}
flags=--release
if [[ $target != *linux-gnu ]]; then
flags+=' --no-default-features'
fi
if [ $target = x86_64-unknown-linux-gnu ]; then
cargo=cargo
else
cargo=cross
flags+=" --target $target"
fi
$cargo build $flags
bin=target/$target/release/pvg
if ! [ -f $bin ]; then
bin+=.exe
if ! [ -f $bin ]; then
bin=target/release/pvg
fi
${CARGO:=cargo} build --release --target $target
if [[ $target == *windows* ]]; then
ext=.exe
fi
bin=target/$target/release/pvg$ext
FILE=pvg-${GITHUB_SHA::7}-$target.xz
echo "FILE=$FILE" >> $GITHUB_ENV
xz -cv $bin > $FILE
- uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
with:
path-type: inherit

- name: Build ${{ matrix.target }} in MSYS2
shell: msys2 {0}
if: runner.os == 'Windows'
run: |
set -e
cargo update
cargo build --release --no-default-features
FILE=pvg-${GITHUB_SHA::7}-${{ matrix.target }}.xz
echo "FILE=$FILE" >> $GITHUB_ENV
xz -cv target/release/pvg.exe > $FILE
- uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit 7b93c58

Please sign in to comment.