Build and release binary #29
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: Build and release binary | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Version to build" | |
required: true | |
default: "0.0.0" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
include: | |
- os: ubuntu-latest | |
suffix: -linux | |
- os: windows-latest | |
suffix: -windows | |
- os: macos-latest | |
suffix: -macos | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Setup zip | |
if: matrix.os == 'windows-latest' | |
run: | | |
curl.exe https://www.willus.com/archive/zip64/infozip_binaries_win64.zip -o zip64.zip | |
7z x zip64.zip -oC:\tools | |
echo "C:/tools" >> $GITHUB_PATH | |
- name: Determine version | |
id: version | |
run: | | |
if [ -z "${{ inputs.version }}" ]; then | |
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\/v//') | |
else | |
VERSION=${{ inputs.version }} | |
fi | |
if [[ $VERSION == *"-"* ]]; then | |
PRERELEASE=true | |
else | |
PRERELEASE=false | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "prerelease=${PRERELEASE}" >> $GITHUB_OUTPUT | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Bazel | |
uses: bazel-contrib/[email protected] | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 8 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
cache-dependency-path: "crates/assets/frontend/pnpm-lock.yaml" | |
- name: Cache rust dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Build frontend | |
run: | | |
cd crates/assets/frontend | |
pnpm install | |
pnpm build | |
- name: Build rust | |
run: | | |
echo "Building version ${{ steps.version.outputs.version }}" | |
cargo install cargo-edit | |
cargo set-version ${{ steps.version.outputs.version }} -p cantari | |
cargo build --release -vv | |
- name: Archive | |
run: | | |
mkdir archive | |
cp -r target/release/{sample.vvm,*.html,dict} archive | |
cp target/release/{*.dylib,*.so,*.dll} archive || true | |
cp target/release/{cantari,cantari.exe} archive || true | |
cp crates/cantari/engine_manifest.json archive | |
cd archive | |
zip -r ../cantari-${{ steps.version.outputs.version }}${{ matrix.suffix }}.zip . | |
cd .. | |
mv cantari-${{ steps.version.outputs.version }}${{ matrix.suffix }}.zip cantari-${{ steps.version.outputs.version }}${{ matrix.suffix }}.vvpp | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.version.outputs.version }} | |
prerelease: ${{ steps.version.outputs.prerelease }} | |
files: | | |
cantari-${{ steps.version.outputs.version }}${{ matrix.suffix }}.vvpp |