RSDK-5238 - Versioned releases #73
Workflow file for this run
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: Build + draft release | |
# (erodkin) this is needed to create the release, per https://github.com/softprops/action-gh-release/issues/236 | |
permissions: | |
contents: write | |
jobs: | |
prepare: | |
if: github.repository_owner == 'viamrobotics' | |
runs-on: buildjet-8vcpu-ubuntu-2204-arm | |
container: | |
image: ghcr.io/viamrobotics/canon:arm64 | |
outputs: | |
version: ${{ steps.which_version.outputs.version }} | |
sha: ${{ steps.commit.outputs.commit_long_sha }} | |
steps: | |
- name: Check if organization member | |
id: is_organization_member | |
uses: jamessingleton/[email protected] | |
with: | |
organization: viamrobotics | |
username: ${{ github.actor }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cancelling - user not part of organization | |
uses: andymckay/[email protected] | |
if: | | |
steps.is_organization_member.outputs.result == 'false' | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Which Version | |
id: which_version | |
shell: bash | |
run: echo "version=$(grep 'set(CMAKE_PROJECT_VERSION' CMakeLists.txt | sed 's/)//' | awk '{print $2}')" >> $GITHUB_OUTPUT | |
- name: Check if release exists | |
uses: cardinalby/[email protected] | |
id: release_exists | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
releaseName: v${{ steps.which_version.outputs.version }} | |
doNotFailIfNotFound: 'true' | |
- name: Cancelling - release already exists | |
uses: andymckay/[email protected] | |
if: steps.release_exists.outputs.id != '' | |
- name: Commit + Push | |
id: commit | |
uses: EndBug/[email protected] | |
with: | |
default_author: github_actions | |
message: Bumping version to v${{ steps.which_version.outputs.version }} [skip ci] | |
build_macos: | |
if: github.repository_owner == 'viamrobotics' | |
needs: [prepare] | |
runs-on: [self-hosted, ARM64, macOS] | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: aarch64-apple-darwin | |
platform: macosx_arm64 | |
- target: x86_64-apple-darwin | |
platform: macosx_x86_64 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.prepare.outputs.sha }} | |
- name: Install dependencies | |
run: | | |
brew install abseil cmake boost grpc protobuf xtensor | |
brew install pkg-config ninja buf | |
- name: Setup build directory | |
run: mkdir builds | |
- name: Build | |
run: | | |
export BUF_CONFIG_DIR=$(mktemp -d) | |
mkdir build | |
pushd build/ | |
cmake .. -G Ninja | |
ninja all && ninja install | |
popd | |
- name: Copy | |
run: | | |
cp build/install/lib/libviam_rust_utils.a builds/libviam_rust_utils-${{ matrix.platform }}.a | |
cp build/install/lib/libviamsdk.${{ needs.prepare.outputs.version }}.dylib builds/libviamsdk-${{ matrix.platform }}.dylib | |
cp build/install/lib/libviamapi.${{ needs.prepare.outputs.version }}.dylib builds/libviamapi-${{ matrix.platform }}.dylib | |
- name: Correct install path | |
run: | | |
install_name_tool -id "@rpath/libviamsdk.dylib" builds/libviamsdk-${{ matrix.platform }}.dylib | |
install_name_tool -id "@rpath/libviamapi.dylib" builds/libviamapi-${{ matrix.platform }}.dylib | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: builds | |
path: builds | |
build_aarch_linux: | |
if: github.repository_owner == 'viamrobotics' | |
needs: [prepare] | |
runs-on: buildjet-8vcpu-ubuntu-2204-arm | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.prepare.outputs.sha }} | |
- name: Install dependencies | |
run: | | |
apt-get -y --no-install-recommends sudo | |
sudo apt-get update | |
sudo apt-get -y dist-upgrade | |
sudo apt-get -y --no-install-recommends install \ | |
build-essential \ | |
ca-certificates \ | |
curl \ | |
doxygen \ | |
g++ \ | |
gdb \ | |
git \ | |
gnupg \ | |
gpg \ | |
less \ | |
libabsl-dev \ | |
libboost-all-dev \ | |
libgrpc++-dev \ | |
libprotobuf-dev \ | |
libssl-dev \ | |
ninja-build \ | |
pkg-config \ | |
protobuf-compiler \ | |
protobuf-compiler-grpc \ | |
software-properties-common \ | |
wget | |
# Add the public key for the llvm repository to get the correct clang version | |
bash -c 'sudo wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -' | |
sudo apt-add-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main' | |
# Add public key and repository to get cmake 3.25+ | |
bash -c 'sudo wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null' | |
sudo echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null | |
sudo apt-get update | |
sudo apt-get -y --no-install-recommends install -t llvm-toolchain-jammy-15 clang-15 clang-tidy-15 | |
sudo apt-get -y install cmake | |
- name: Setup build directory | |
run: mkdir builds | |
- name: Build | |
shell: bash | |
run: | | |
mkdir build | |
pushd build/ | |
/usr/bin/cmake .. -G Ninja | |
ninja all -j 3 && ninja install | |
popd | |
- name: Copy | |
run: | | |
cp build/install/lib/libviam_rust_utils.a builds/libviam_rust_utils-linux_aarch64.a | |
cp build/install/lib/libviamapi.so.${{ needs.prepare.outputs.version }} builds/libviamapi-linux_aarch64.so | |
cp build/install/lib/libviamsdk.so.${{ needs.prepare.outputs.version }} builds/libviamsdk-linux_aarch64.so | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: builds | |
path: builds | |
build_linux: | |
if: github.repository_owner == 'viamrobotics' | |
needs: [prepare] | |
runs-on: [self-hosted, x64] | |
container: | |
image: ghcr.io/cross-rs/${{ matrix.image }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
platform: linux_x86_64 | |
image: x86_64-unknown-linux-gnu:main | |
- target: arm-unknown-linux-gnueabihf | |
platform: linux_armv6l | |
image: arm-unknown-linux-gnueabihf:main | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.prepare.outputs.sha }} | |
- name: Install dependencies | |
run: | | |
apt-get update | |
apt-get -y dist-upgrade | |
apt-get -y --no-install-recommends install \ | |
build-essential \ | |
ca-certificates \ | |
curl \ | |
doxygen \ | |
g++ \ | |
gdb \ | |
git \ | |
gnupg \ | |
gpg \ | |
less \ | |
libboost-all-dev \ | |
libc-ares-dev \ | |
libre2-dev \ | |
libssl-dev \ | |
ninja-build \ | |
pkg-config \ | |
software-properties-common \ | |
sudo \ | |
wget \ | |
zlib1g-dev | |
# Add the public key for the llvm repository to get the correct clang version | |
bash -c 'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add -' | |
apt-add-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main' | |
# Add public key and repository to get cmake 3.25+ | |
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - > /usr/share/keyrings/kitware-archive-keyring.gpg | |
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' > /etc/apt/sources.list.d/kitware.list | |
apt-get update | |
apt-get -y --no-install-recommends install -t llvm-toolchain-focal-15 clang-15 clang-tidy-15 | |
apt-get -y install cmake | |
mkdir -p ${HOME}/opt/src | |
cd ${HOME}/opt/src && \ | |
git clone --recurse-submodules -b v1.52.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc && \ | |
cd grpc && \ | |
mkdir -p build && \ | |
cd build && \ | |
cmake .. -G Ninja \ | |
-DgRPC_ZLIB_PROVIDER=package \ | |
-DgRPC_CARES_PROVIDER=package \ | |
-DgRPC_RE2_PROVIDER=package \ | |
-DgRPC_SSL_PROVIDER=package \ | |
-DgRPC_INSTALL=ON \ | |
-DgRPC_BUILD_TESTS=OFF \ | |
-DBUILD_SHARED_LIBS=ON \ | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | |
-DCMAKE_INSTALL_PREFIX=/usr/local \ | |
-DCMAKE_INSTALL_RPATH=/usr/local/lib && \ | |
ninja install && \ | |
cd .. && \ | |
rm -rf build | |
- name: Setup build directory | |
run: mkdir builds | |
- name: Build | |
shell: bash | |
run: | | |
mkdir build | |
pushd build/ | |
/usr/bin/cmake .. -G Ninja | |
ninja all && ninja install | |
popd | |
- name: Copy | |
run: | | |
cp build/install/lib/libviam_rust_utils.a builds/libviam_rust_utils-${{ matrix.platform }}.a | |
cp build/install/lib/libviamapi.so.${{ needs.prepare.outputs.version }} builds/libviamapi-${{ matrix.platform }}.so | |
cp build/install/lib/libviamsdk.so.${{ needs.prepare.outputs.version }} builds/libviamsdk-${{ matrix.platform }}.so | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: builds | |
path: builds | |
release: | |
needs: [prepare, build_macos, build_linux, build_aarch_linux] | |
if: github.repository_owner == 'viamrobotics' | |
runs-on: [self-hosted, x64] | |
container: | |
image: ghcr.io/viamrobotics/canon:amd64 | |
steps: | |
- uses: actions/download-artifact@v3 | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ needs.prepare.outputs.version }} | |
files: builds/* | |
draft: true | |
prerelease: false | |
fail_on_unmatched_files: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |