0.1.10 #49
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: | |
branches: [ "master" ] | |
tags: [ "**" ] | |
pull_request: | |
branches: [ "master" ] | |
env: | |
CARGO_TERM_COLOR: always | |
BUILD_ARGS: "--bin altc --release --features bin" | |
jobs: | |
build: | |
name: Build - ${{ matrix.platform.name }} | |
# By default, runs on Ubuntu, otherwise, override with the desired os | |
runs-on: ${{ matrix.platform.os || 'ubuntu-latest' }} | |
strategy: | |
matrix: | |
platform: | |
# Linux | |
- name: Linux x86_64 | |
target: x86_64-unknown-linux-gnu | |
- name: Linux aarch64 | |
target: aarch64-unknown-linux-gnu | |
use-cross: true | |
# Mac OS | |
- name: MacOS x86_64 | |
os: macos-latest | |
target: x86_64-apple-darwin | |
- name: MacOS aarch64 | |
os: macos-latest | |
target: aarch64-apple-darwin | |
# Windows | |
- name: Windows x86_64 | |
# Use another GitHub action OS | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.platform.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ matrix.platform.target }}-cargo- | |
- name: Install ${{ matrix.platform.target }} Toolchain | |
run: rustup target add ${{ matrix.platform.target }} | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
- name: Build ${{ matrix.platform.name }} binary | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
use-cross: ${{ matrix.platform.use-cross }} | |
args: ${{ env.BUILD_ARGS }} --target ${{ matrix.platform.target }} | |
- name: Rename binary | |
run: | | |
mv target/${{ matrix.platform.target }}/release/altc${{ contains(matrix.platform.target, 'windows') && '.exe' || '' }} \ | |
altc.${{ matrix.platform.target }}${{ contains(matrix.platform.target, 'windows') && '.exe' || '' }} | |
shell: bash | |
- name: Upload ${{ matrix.platform.name }} binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.platform.target }} | |
path: altc.${{ matrix.platform.target }}${{ contains(matrix.platform.target, 'windows') && '.exe' || '' }} | |
build-web: | |
name: Build - Web | |
# By default, runs on Ubuntu, otherwise, override with the desired os | |
runs-on: 'ubuntu-latest' | |
env: | |
CARGO_INSTALLS: | | |
wasm-pack | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: web-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: web-cargo- | |
- name: Set up cargo install cache | |
uses: actions/cache@v4 | |
with: | |
path: installs | |
key: | | |
web-installs | |
${{ env.CARGO_INSTALLS }} | |
restore-keys: web-installs | |
- name: Install cargo dependencies | |
run: | | |
while IFS= read -r package; do | |
if [ "$package" != "" ]; then | |
cargo install "$package" --target-dir "installs/$package" || true | |
fi; | |
done <<< "$CARGO_INSTALLS" | |
- name: Install wasm32-unknown-unknown Toolchain | |
run: rustup target add wasm32-unknown-unknown | |
- name: Build wasm bundle | |
run: wasm-pack build --target web | |
- name: Pack wasm bundle | |
run: | | |
cd pkg | |
npm pack | |
cd - | |
- name: Rename binary | |
run: | | |
mv pkg/altc-*.tgz \ | |
altc.wasm32-unknown-unknown.tgz | |
- name: Upload web bundle | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wasm32-unknown-unknown | |
path: altc.wasm32-unknown-unknown.tgz | |
release: | |
name: Release | |
runs-on: 'ubuntu-latest' | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
needs: [ 'build', 'build-web' ] | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
merge-multiple: true | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
files: artifacts/** | |