Merge pull request #133 from pipeless-ai/buffersize #60
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 Build & Release | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'pipeless/Cargo.toml' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest] | |
arch: [x64] | |
# Provide an output that can be used by other jobs | |
outputs: | |
new_version: ${{ steps.check_version.outputs.new_version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get before and after versions | |
id: check_version | |
run: | | |
before_version=$(git describe --abbrev=0 --tags | grep -o '\([0-9]\+\.\)\+[0-9]\+') | |
after_version=$(cargo metadata --manifest-path pipeless/Cargo.toml --format-version 1 | jq -r '.packages[] | select(.name == "pipeless-ai").version') | |
if [ "$before_version" != "$after_version" ]; then | |
echo "Cargo.toml version has been updated" | |
echo "new_version=${after_version}" >> $GITHUB_OUTPUT | |
else | |
echo "Cargo.toml version was not updated" | |
exit 1 | |
fi | |
- name: Set OS and Arch | |
id: set-os-arch | |
run: | | |
ARCH=$(uname -m) | |
case $ARCH in | |
armv5*) ARCH="armv5";; | |
armv6*) ARCH="armv6";; | |
armv7*) ARCH="arm";; | |
aarch64) ARCH="arm64";; | |
x86) ARCH="386";; | |
x86_64) ARCH="amd64";; | |
i686) ARCH="386";; | |
i386) ARCH="386";; | |
esac | |
echo "ARCH=$ARCH" >> $GITHUB_ENV | |
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') | |
case "$OS" in | |
# Minimalist GNU for Windows | |
mingw*|cygwin*) OS='windows';; | |
esac | |
echo "OS=$OS" >> $GITHUB_ENV | |
- name: Install latest rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: beta | |
default: true | |
override: true | |
- name: Set up Homebrew | |
if: matrix.os == 'macos-latest' | |
run: | | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
- name: Install dependencies with Homebrew | |
if: matrix.os == 'macos-latest' | |
run: | | |
# Avoid to upgrade dependents like azure-cli, because we don't need them | |
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 | |
# Avoid error when installing Python as gstreamer dependency | |
brew link --overwrite python@3.12 | |
brew install gstreamer | |
brew install coreutils # For sha256sum | |
- name: Install system dependencies | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -y \ | |
libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ | |
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \ | |
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \ | |
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \ | |
gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 \ | |
gstreamer1.0-qt5 gstreamer1.0-pulseaudio gstreamer1.0-rtsp | |
- name: Build | |
run: | | |
cargo build --all --release --manifest-path pipeless/Cargo.toml | |
mv pipeless/target/release/pipeless-ai pipeless/target/release/pipeless | |
strip pipeless/target/release/pipeless | |
mkdir pipeless-${{ steps.check_version.outputs.new_version }} | |
cp pipeless/target/release/{pipeless,libonnxruntime*} pipeless-${{ steps.check_version.outputs.new_version }}/ | |
tar -czf pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz pipeless-${{ steps.check_version.outputs.new_version }} | |
- name: Create SHA256 file | |
run: sha256sum pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz > pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256 | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.check_version.outputs.new_version }} | |
path: | | |
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz | |
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256 | |
# Build for Jetson in our self hosted runner. Note it must be setup and have dependencies installed | |
build-jetson: | |
runs-on: self-hosted | |
# Provide an output that can be used by other jobs | |
outputs: | |
new_version: ${{ steps.check_version.outputs.new_version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get before and after versions | |
id: check_version | |
run: | | |
before_version=$(git describe --abbrev=0 --tags | grep -o '\([0-9]\+\.\)\+[0-9]\+') | |
after_version=$(cargo metadata --manifest-path pipeless/Cargo.toml --format-version 1 | jq -r '.packages[] | select(.name == "pipeless-ai").version') | |
if [ "$before_version" != "$after_version" ]; then | |
echo "Cargo.toml version has been updated" | |
echo "new_version=${after_version}" >> $GITHUB_OUTPUT | |
else | |
echo "Cargo.toml version was not updated" | |
exit 1 | |
fi | |
- name: Set OS and Arch | |
id: set-os-arch | |
run: | | |
ARCH=$(uname -m) | |
case $ARCH in | |
armv5*) ARCH="armv5";; | |
armv6*) ARCH="armv6";; | |
armv7*) ARCH="arm";; | |
aarch64) ARCH="arm64";; | |
x86) ARCH="386";; | |
x86_64) ARCH="amd64";; | |
i686) ARCH="386";; | |
i386) ARCH="386";; | |
esac | |
echo "ARCH=$ARCH" >> $GITHUB_ENV | |
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') | |
case "$OS" in | |
# Minimalist GNU for Windows | |
mingw*|cygwin*) OS='windows';; | |
esac | |
echo "OS=$OS" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
# We have already placed the onnx runtime library at ~/.pipeless so it can be linked and copied | |
ORT_STRATEGY=system ORT_LIB_LOCATION=/home/miguelaeh/.pipeless/ cargo build --all --release --manifest-path pipeless/Cargo.toml && | |
mv pipeless/target/release/pipeless-ai pipeless/target/release/pipeless && | |
strip pipeless/target/release/pipeless && | |
mkdir pipeless-${{ steps.check_version.outputs.new_version }} | |
cp pipeless/target/release/{pipeless,libonnxruntime*} pipeless-${{ steps.check_version.outputs.new_version }} | |
# HACK: Copy the file that we renamed adding the version after building onnx runtime | |
cp /home/miguelaeh/.pipeless/libonnxruntime* pipeless-${{ steps.check_version.outputs.new_version }}/ | |
tar -czf pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz pipeless-${{ steps.check_version.outputs.new_version }} | |
- name: Create SHA256 file | |
run: sha256sum pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz > pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256 | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.check_version.outputs.new_version }} | |
path: | | |
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz | |
pipeless-${{ steps.check_version.outputs.new_version }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz.sha256 | |
# Create GitHub releases | |
release: | |
needs: | |
- build | |
- build-jetson | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.build.outputs.new_version }} | |
path: artifact | |
- name: Create and push tag | |
run: | | |
git config --global user.email "actions@github.com" | |
git config --global user.name "GitHub Build Action" | |
git tag -a v${{ needs.build.outputs.new_version }} -m "Version ${{ needs.build.outputs.new_version }}" | |
git push origin v${{ needs.build.outputs.new_version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: true | |
tag_name: v${{ needs.build.outputs.new_version }} | |
files: | | |
artifact/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Publish to crates.io | |
publish: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# The publish needs to build it again | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -y \ | |
libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ | |
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \ | |
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \ | |
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \ | |
gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 \ | |
gstreamer1.0-qt5 gstreamer1.0-pulseaudio gstreamer1.0-rtsp | |
- name: Crates.io | |
run: cargo publish --manifest-path pipeless/Cargo.toml --token ${CRATES_IO_TOKEN} | |
env: | |
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} |