test-build #6
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: test-build | |
on: | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: "-D warnings" | |
jobs: | |
build-test: | |
name: build-test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-musl | |
- aarch64-unknown-linux-musl | |
- x86_64-apple-darwin | |
- aarch64-apple-darwin | |
- x86_64-pc-windows-msvc | |
toolchain: [stable] | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
use-cross: true | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
use-cross: true | |
# macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 | |
- os: macos-13 | |
target: x86_64-apple-darwin | |
use-cross: false | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
use-cross: false | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
use-cross: false | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
target: ${{ matrix.target }} | |
- name: Handle Rust dependencies caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: v1-${{ matrix.target }} | |
- name: Build release binary | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: build | |
args: --release --target ${{ matrix.target }} | |
use-cross: ${{ matrix.use-cross }} | |
- name: Build archive | |
shell: bash | |
run: | | |
# Get latest version | |
# https://stackoverflow.com/a/69708418 | |
VERSION="$(git describe --tags "$(git rev-list --tags --max-count=1)")" | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
ARCHIVE="glistix-$VERSION-${{ matrix.target }}.zip" | |
cp "target/${{ matrix.target }}/release/glistix.exe" "glistix.exe" | |
7z a "$ARCHIVE" "glistix.exe" | |
rm glistix.exe | |
else | |
ARCHIVE="glistix-$VERSION-${{ matrix.target }}.tar.gz" | |
cp "target/${{ matrix.target }}/release/glistix" "glistix" | |
tar -czvf "$ARCHIVE" "glistix" | |
rm glistix | |
fi | |
openssl dgst -r -sha256 -out "$ARCHIVE".sha256 "$ARCHIVE" | |
openssl dgst -r -sha512 -out "$ARCHIVE".sha512 "$ARCHIVE" | |
echo "ASSET=$ARCHIVE" >> $GITHUB_ENV | |
- name: Ensure binary successfully boots | |
shell: bash | |
run: | | |
case "${{ matrix.target }}" in | |
x86_64-pc-windows-msvc) | |
7z x "$ASSET" | |
./glistix.exe --version ;; | |
aarch64*) | |
echo "We cannot test an ARM binary on a AMD64 runner" ;; | |
*) | |
tar -xvzf "$ASSET" | |
./glistix --version ;; | |
esac | |
- name: Upload built binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-binary-${{ matrix.os }} | |
path: | | |
${{ env.ASSET }} | |
${{ env.ASSET }}.sha256 | |
${{ env.ASSET }}.sha512 | |
retention-days: 3 | |
build-test-wasm: | |
name: build-test-wasm | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Install wasm-pack | |
run: curl -sSL https://rustwasm.github.io/wasm-pack/installer/init.sh | sh | |
- name: Build wasm | |
run: wasm-pack build --release --target web compiler-wasm | |
- name: Build wasm archive | |
run: | | |
# Get latest version | |
# https://stackoverflow.com/a/69708418 | |
VERSION="$(git describe --tags "$(git rev-list --tags --max-count=1)")" | |
ARCHIVE="glistix-$VERSION-browser.tar.gz" | |
tar -C compiler-wasm/pkg/ -czvf $ARCHIVE . | |
openssl dgst -r -sha256 -out "$ARCHIVE".sha256 "$ARCHIVE" | |
openssl dgst -r -sha512 -out "$ARCHIVE".sha512 "$ARCHIVE" | |
echo "ASSET=$ARCHIVE" >> $GITHUB_ENV | |
- name: Upload built archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-archive-wasm | |
path: | | |
${{ env.ASSET }} | |
${{ env.ASSET }}.sha256 | |
${{ env.ASSET }}.sha512 | |
retention-days: 3 |