mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-06 03:15:48 -06:00
138 lines
3.7 KiB
YAML
138 lines
3.7 KiB
YAML
name: Build
|
|
|
|
on: ["push", "pull_request"]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
RUST_TOOLCHAIN: 1.86.0
|
|
|
|
jobs:
|
|
build:
|
|
name: Build (${{ matrix.target }})
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
artifact_name: pacman
|
|
- os: macos-13
|
|
target: x86_64-apple-darwin
|
|
artifact_name: pacman
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
artifact_name: pacman
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-gnu
|
|
artifact_name: pacman.exe
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust Toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
target: ${{ matrix.target }}
|
|
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
|
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Cache vcpkg
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: target/vcpkg
|
|
key: A-vcpkg-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
|
|
restore-keys: |
|
|
A-vcpkg-${{ runner.os }}-${{ matrix.target }}-
|
|
|
|
- name: Vcpkg Linux Dependencies
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libltdl-dev
|
|
|
|
- name: Vcpkg
|
|
run: |
|
|
cargo install cargo-vcpkg
|
|
cargo vcpkg -v build
|
|
|
|
- name: Build
|
|
run: cargo build --release
|
|
|
|
- name: Acquire Package Version
|
|
shell: bash
|
|
run: |
|
|
PACKAGE_VERSION=$(cargo metadata --format-version 1 --no-deps | jq '.packages[0].version' -r)
|
|
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: "pacman-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}"
|
|
path: ./target/release/${{ matrix.artifact_name }}
|
|
retention-days: 7
|
|
if-no-files-found: error
|
|
|
|
wasm:
|
|
name: Build (wasm32-unknown-emscripten)
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
pages: write
|
|
id-token: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Emscripten SDK
|
|
uses: pyodide/setup-emsdk@v15
|
|
with:
|
|
version: 3.1.43
|
|
actions-cache-folder: "emsdk-cache"
|
|
|
|
- name: Setup Rust (WASM32 Emscripten)
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
target: wasm32-unknown-emscripten
|
|
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
|
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v3
|
|
with:
|
|
version: 8
|
|
run_install: true
|
|
|
|
- name: Build with Emscripten
|
|
run: |
|
|
cargo build --target=wasm32-unknown-emscripten --release
|
|
|
|
- name: Assemble
|
|
run: |
|
|
echo "Generating CSS"
|
|
pnpx postcss-cli ./assets/site/styles.scss -o ./assets/site/build.css
|
|
|
|
echo "Copying WASM files"
|
|
|
|
mkdir -p dist
|
|
cp assets/site/{build.css,favicon.ico,index.html} dist
|
|
output_folder="target/wasm32-unknown-emscripten/release"
|
|
cp $output_folder/pacman.{wasm,js} $output_folder/deps/pacman.data dist
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
with:
|
|
path: "./dist/"
|
|
retention-days: 7
|
|
|
|
- name: Deploy
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
uses: actions/deploy-pages@v4
|