.github/workflows/release.yml #97
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'The type of version bump. Use "nobump" for no change.' | |
type: choice | |
required: true | |
default: nobump | |
options: | |
- major | |
- minor | |
- patch | |
- nobump | |
jobs: | |
prepare: | |
if: github.repository_owner == 'viamrobotics' | |
runs-on: [buildjet-2vcpu-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: Setup rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Bump Version | |
shell: bash | |
if: inputs.version != 'nobump' | |
run: | | |
cargo install cargo-release | |
cargo release version ${{ inputs.version }} --execute --no-confirm | |
- name: Which Version | |
id: which_version | |
shell: bash | |
run: | | |
cargo update | |
echo "version=$(cargo pkgid | sed 's/.*@//g')" >> $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: Setup rust toolchain | |
# uses: dtolnay/rust-toolchain@stable | |
# with: | |
# toolchain: stable | |
# targets: ${{ matrix.target }} | |
# - name: Setup build directory | |
# run: mkdir builds | |
# - name: Build | |
# run: | | |
# cargo build --release --target=${{ matrix.target }} | |
# - name: Copy | |
# run: | | |
# cp target/${{ matrix.target }}/release/libviam_rust_utils.dylib builds/libviam_rust_utils-${{ matrix.platform }}.dylib | |
# cp target/${{ matrix.target }}/release/libviam_rust_utils.a builds/libviam_rust_utils-${{ matrix.platform }}.a | |
# - name: Correct install path | |
# run: | | |
# install_name_tool -id "@rpath/libviam_rust_utils.dylib" builds/libviam_rust_utils-${{ matrix.platform }}.dylib | |
# - name: Upload artifacts | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: builds | |
# path: builds | |
# build_linux builds all but aarch64. | |
build_linux: | |
if: github.repository_owner == 'viamrobotics' | |
needs: [prepare] | |
runs-on: ${{ matrix.runs-on }} | |
container: | |
image: ${{ matrix.image }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: aarch64-unknown-linux-gnu | |
platform: linux_aarch64 | |
image: rust | |
runs-on: buildjet-2vcpu-ubuntu-2204-arm | |
- target: x86_64-unknown-linux-gnu | |
platform: linux_x86_64 | |
image: ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main-centos | |
runs-on: buildjet-2vcpu-ubuntu-2204 | |
- target: arm-unknown-linux-gnueabihf | |
platform: linux_armv6l | |
image: ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:main | |
runs-on: buildjet-2vcpu-ubuntu-2204 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.prepare.outputs.sha }} | |
- name: Setup rust toolchain | |
shell: bash | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source "$HOME/.cargo/env" | |
rustup target add ${{ matrix.target }} | |
- name: Setup build directory | |
run: mkdir builds | |
- name: Build | |
shell: bash | |
run: | | |
source "$HOME/.cargo/env" | |
cargo build --release --target=${{ matrix.target }} | |
- name: Copy | |
run: | | |
cp target/${{ matrix.target }}/release/libviam_rust_utils.so builds/libviam_rust_utils-${{ matrix.platform }}.so | |
cp target/${{ matrix.target }}/release/libviam_rust_utils.a builds/libviam_rust_utils-${{ matrix.platform }}.a | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: builds | |
path: builds | |
# build_aarch64_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 }} | |
# # Variables for rust toolchain setup copied from the micro-rdk release | |
# # process. | |
# - name: Setup rust toolchain | |
# uses: actions-rs/toolchain@v1 | |
# with: | |
# profile: minimal | |
# toolchain: 1.70.0 | |
# override: true | |
# target: aarch64-unknown-linux-gnu | |
# default: true | |
# - name: Setup build directory | |
# run: mkdir builds | |
# - name: Build | |
# run: | | |
# cargo build --release --locked --target aarch64-unknown-linux-gnu | |
# cp target/aarch64-unknown-linux-gnu/release/libviam_rust_utils.so builds/libviam_rust_utils-linux_aarch64.so | |
# cp target/aarch64-unknown-linux-gnu/release/libviam_rust_utils.a builds/libviam_rust_utils-linux_aarch64.a | |
# - name: Upload artifacts | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: builds | |
# path: builds | |
release: | |
needs: [prepare, build_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 |