Files
moeka-project/.github/workflows/release-tamagotchi.yml
T

251 lines
11 KiB
YAML

name: Release Tamagotchi
permissions:
contents: write
env:
PRODUCT_NAME: 'AIRI'
BUNDLE_NAME: ''
on:
release:
types:
- prereleased
workflow_dispatch:
inputs:
build_only:
description: Build only
required: false
default: false
type: boolean
artifacts_only:
description: Build and upload artifacts only
required: false
default: false
type: boolean
tag:
description: Specific tag/commit for the release (leave empty to auto-detect latest tag)
required: false
type: string
schedule:
- cron: '0 0 * * *'
jobs:
build-tamagotchi:
name: Build Tamagotchi
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
# - os: ubuntu-latest
# target: x86_64-unknown-linux-gnu
# - os: ubuntu-24.04-arm
# target: aarch64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm
# registry-url required. Learn more at
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
registry-url: https://registry.npmjs.org
# Why?
#
# failed to build archive at `/home/runner/work/airi/airi/target/x86_64-unknown-linux-gnu/release/deps/libapp_lib.rlib`:
# No space left on device (os error 28)
- name: Free Disk Space
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm'
uses: jlumbroso/free-disk-space@main
- name: Get Product Name (Windows Only)
if: matrix.os == 'windows-latest'
run: |
$productName = node -p 'require("./apps/stage-tamagotchi/src-tauri/tauri.conf.json").productName'
echo "PRODUCT_NAME=$productName" >> $env:GITHUB_ENV
- name: Get Product Name
if: matrix.os != 'windows-latest'
run: |
echo "PRODUCT_NAME=$(node -p 'require("./apps/stage-tamagotchi/src-tauri/tauri.conf.json").productName')" >> $GITHUB_ENV
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install system dependencies (Ubuntu Only)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libssl-dev \
libgtk-3-dev \
librsvg2-dev \
libsoup-3.0-dev \
libgdk-pixbuf2.0-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Setup MSVC (Windows Only)
if: matrix.os == 'windows-latest'
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Install CUDA Toolkit (Linux and Windows Only)
uses: Jimver/cuda-toolkit@v0.2.24
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'windows-latest'
with:
cuda: '12.5.0'
log-file-suffix: ${{matrix.os}}.txt
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Dependencies
run: pnpm run build:packages
- name: Build Application (macOS Only)
if: matrix.os == 'macos-latest'
run: pnpm run build:tamagotchi --target ${{ matrix.target }}
- name: Build Application (Linux and Windows Only)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'windows-latest'
run: pnpm run build:tamagotchi --target ${{ matrix.target }} --features cuda --verbose
env:
RUST_BACKTRACE: '1'
# Call to `nvcc` (which part of the CUDA Toolkit) doesn't require a physical GPU, yet bindgen_cuda requires `nvidia-smi`
# to be available in order to determine the compute capability of the GPU.[^1]
#
# And bindgen_cuda is what candle depends on, to bypass the Compute compatibility here,
# we need to explicitly setting CUDA_COMPUTE_CAP as one of the environment varaible in order to
# build without any actual physical GPUs inside of the GitHub Actions runner.[^2]
#
# About how bindgen_cuda depends on nvidia-smi, check the actual source code here:
# https://github.com/Narsil/bindgen_cuda/blob/a6b0c891be8ebefb55600d46d8a77a358adc3913/src/lib.rs#L477-L500
#
# Similar information were seen from TEI (text-embedding-inference) documentations
# https://huggingface.co/docs/text-embeddings-inference/en/custom_container
#
# To understand what compute capability is required, visit [CUDA GPU Compute Capability](https://developer.nvidia.com/cuda-gpus)
#
# In short:
# | Compute Capability | GeForce / RTX |
# |---------------------|----------------|
# | 7.5 | GeForce GTX 1650 Ti, NVIDIA TITAN RTX, GeForce RTX 2000 series... |
# | 8.6 | RTX A series, GeForce RTX 3000 series |
# | 8.9 | GeForce RTX 4000 series, RTX A Ada series |
# | 9.0 | GeForce RTX 5000 series, RTX Pro Blackwell series |
#
# Also, the meaning of how the different ranges of numeric values will impact on which compilers, dependencies, to be used,
# TEI (text-embedding-inference) got a Dockerfile specified that well
# https://github.com/huggingface/text-embeddings-inference/blob/6e900afba71821fdf250e380d7da1f5a6e5e7e27/Dockerfile-cuda#L50-L63
#
# Thanks
# - https://github.com/Narsil/bindgen_cuda/issues/4
# - https://github.com/Narsil/bindgen_cuda/issues/8
# - https://github.com/huggingface/candle/issues/1516#issuecomment-1875440701
#
# [^1]: compilation - Can I compile a cuda program without having a cuda device - Stack Overflow https://stackoverflow.com/a/20196425
# [^2]: https://huggingface.github.io/candle/guide/installation.html
CUDA_COMPUTE_CAP: '75'
# ---------
# Nightly (schedule) builds only
# ---------
- name: Get Name of Artifacts (Nightly + Windows Only)
if: ${{ github.event_name == 'schedule' && matrix.os == 'windows-latest' }}
run: |
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
- name: Get Name of Artifacts (Nightly)
if: ${{ github.event_name == 'schedule' && matrix.os != 'windows-latest' }}
run: |
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
- name: Rename Artifacts (Nightly)
if: ${{ github.event_name == 'schedule' }}
run:
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }}
- name: Upload Artifacts (Nightly)
if: ${{ github.event_name == 'schedule' }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUNDLE_NAME }}
path: bundle/${{ env.BUNDLE_NAME }}
# ---------
# Workflow Dispatch only
# ---------
- name: Get Name of Artifacts (Manual + Windows Only)
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os == 'windows-latest' }}
run: |
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
- name: Get Name of Artifacts (Manual)
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os != 'windows-latest' }}
run: |
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
- name: Rename Artifacts (Manual)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }} --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
- name: Upload Artifacts (Manual + Non-Release)
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUNDLE_NAME }}
path: bundle/${{ env.BUNDLE_NAME }}
- name: Upload To GitHub Releases (Manual + Overwrite Release)
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && !inputs.artifacts_only }}
uses: softprops/action-gh-release@v2
with:
files: bundle/${{ env.PRODUCT_NAME }}_*
append_body: true
tag_name: ${{ inputs.tag }}
# ---------
# Version push
# ---------
- name: Rename Artifacts (Automatic)
if: ${{ github.event_name == 'release' }}
run: |
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }} --release --auto-tag
- name: Upload To GitHub Releases (Automatic)
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v2
with:
files: bundle/${{ env.PRODUCT_NAME }}_*
append_body: true