Release statically linked binaries #11
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: Release statically linked binaries | |
on: | |
workflow_dispatch: # manual trigger release | |
inputs: | |
create_release: | |
description: 'Create new release' | |
required: true | |
type: boolean | |
release_version: | |
description: "Version (e.g. 1.0.0)" | |
required: true | |
type: string | |
# jobs: | |
# build-and-release: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Clone project | |
# id: checkout | |
# uses: actions/checkout@v3 | |
# - name: Setup rustup | |
# id: rustup | |
# uses: actions-rust-lang/setup-rust-toolchain@v1 | |
# with: | |
# target: wasm32-wasi | |
# - name: Build x86_64-unknown-linux-gnu | |
# id: build_simple | |
# run: | | |
# cd simple | |
# cargo build --target wasm32-wasi --release | |
# cp ./target/wasm32-wasi/release/llama-simple.wasm ../llama-simple.wasm | |
# - name: Build chat | |
# id: build_chat | |
# run: | | |
# cd chat | |
# cargo build --target wasm32-wasi --release | |
# cp ./target/wasm32-wasi/release/llama-chat.wasm ../llama-chat.wasm | |
# - name: Build api-server | |
# id: build_api_server | |
# run: | | |
# cd api-server | |
# cargo build --target wasm32-wasi --release | |
# cp ./target/wasm32-wasi/release/llama-api-server.wasm ../llama-api-server.wasm | |
# - name: Calculate checksum | |
# id: checksum | |
# run: | | |
# sha256sum *.wasm > SHA256SUM | |
# echo "Debug info(SHA256SUM):" | |
# cat SHA256SUM | |
# - name: Tag and release names | |
# id: tag_and_release_names | |
# run: | | |
# echo "tag_name=${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT | |
# echo "release_name=LlamaEdge ${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT | |
# - name: Create Release and Upload Release Asset | |
# if: ${{ github.event.inputs.create_release == 'true' && github.ref == 'refs/heads/main'}} | |
# uses: softprops/action-gh-release@v1 | |
# with: | |
# name: ${{ steps.tag_and_release_names.outputs.release_name }} | |
# tag_name: ${{ steps.tag_and_release_names.outputs.tag_name }} | |
# body: TODO New Release. | |
# draft: true | |
# prerelease: true | |
# files: | | |
# llama-api-server.wasm | |
# llama-chat.wasm | |
# llama-simple.wasm | |
# SHA256SUM | |
jobs: | |
release: | |
name: Release - ${{ matrix.platform.os_name }} | |
# if: startsWith( github.ref, 'refs/tags/v' ) || github.ref == 'refs/tags/test-release' | |
strategy: | |
matrix: | |
platform: | |
# - os_name: FreeBSD-x86_64 | |
# os: ubuntu-20.04 | |
# target: x86_64-unknown-freebsd | |
# bin: ubi | |
# name: ubi-FreeBSD-x86_64.tar.gz | |
# cross: true | |
# cargo_command: ./cross | |
# - os_name: Linux-x86_64-musl | |
# os: ubuntu-20.04 | |
# target: x86_64-unknown-linux-musl | |
# bin: ubi | |
# name: ubi-Linux-x86_64-musl.tar.gz | |
# cross: false | |
# cargo_command: cargo | |
- os_name: Linux-x86_64-gnu | |
os: ubuntu-20.04 | |
target: x86_64-unknown-linux-gnu | |
bin: ubi | |
name: ubi-Linux-x86_64-gnu.tar.gz | |
cross: false | |
cargo_command: cargo | |
# - os_name: Windows-aarch64 | |
# os: windows-latest | |
# target: aarch64-pc-windows-msvc | |
# bin: ubi.exe | |
# name: ubi-Windows-aarch64.zip | |
# cross: false | |
# cargo_command: cargo | |
# - os_name: macOS-x86_64 | |
# os: macOS-latest | |
# target: x86_64-apple-darwin | |
# bin: ubi | |
# name: ubi-Darwin-x86_64.tar.gz | |
# cross: false | |
# cargo_command: cargo | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install toolchain if not cross-compiling | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.platform.target }} | |
if: ${{ !matrix.platform.cross }} | |
- name: Install musl-tools on Linux | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y musl-dev musl-tools build-essential libclang-dev | |
if: contains(matrix.platform.os, 'ubuntu') && !matrix.platform.cross | |
- name: Setup protoc | |
run: | | |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip | |
unzip protoc-3.15.8-linux-x86_64.zip -d $HOME/.local | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
if: contains(matrix.platform.os, 'ubuntu') | |
- name: Install cross if cross-compiling (*nix) | |
id: cross-nix | |
shell: bash | |
run: | | |
set -e | |
export TARGET="$HOME/bin" | |
mkdir -p "$TARGET" | |
./bootstrap/bootstrap-ubi.sh | |
"$HOME/bin/ubi" --project cross-rs/cross --matching musl --in . | |
if: matrix.platform.cross && !contains(matrix.platform.os, 'windows') | |
- name: Install cross if cross-compiling (Windows) | |
id: cross-windows | |
shell: powershell | |
run: | | |
.\bootstrap\bootstrap-ubi.ps1 | |
.\ubi --project cross-rs/cross --in . | |
if: matrix.platform.cross && contains(matrix.platform.os, 'windows') | |
# - name: Build binary (*nix) | |
# shell: bash | |
# run: | | |
# ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} | |
# if: ${{ !contains(matrix.platform.os, 'windows') }} | |
- name: Build binary (Linux) | |
shell: bash | |
run: | | |
# curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip | |
# unzip protoc-3.15.8-linux-x86_64.zip -d $HOME/.local | |
# echo "$HOME/.local/bin" >> $GITHUB_PATH | |
# protoc --version | |
${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} | |
if: ${{ contains(matrix.platform.os, 'ubuntu') }} | |
- name: Build binary (Windows) | |
# We have to use the platform's native shell. If we use bash on | |
# Windows then OpenSSL complains that the Perl it finds doesn't use | |
# the platform's native paths and refuses to build. | |
shell: powershell | |
run: | | |
& ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} | |
if: contains(matrix.platform.os, 'windows') | |
# - name: Strip binary | |
# shell: bash | |
# run: | | |
# # strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | |
# strip target/${{ matrix.platform.target }}/release | |
# # strip doesn't work with cross-arch binaries on Linux or Windows. | |
# if: ${{ !(matrix.platform.cross || matrix.platform.target == 'aarch64-pc-windows-msvc') }} | |
- name: Package as archive | |
shell: bash | |
run: | | |
cd target/${{ matrix.platform.target }}/release | |
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | |
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | |
else | |
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | |
fi | |
cd - | |
- name: Publish release artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ubi-${{ matrix.platform.os_name }} | |
path: "ubi*" | |
if: github.ref == 'refs/tags/test-release' | |
- name: Publish GitHub release | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: true | |
files: "ubi*" | |
body_path: Changes.md | |
if: startsWith( github.ref, 'refs/tags/v' ) |