Skip to content

Release Candidate

Release Candidate #27

name: Release Candidate
on:
workflow_dispatch:
inputs:
version:
description: 'The type of version bump. All versions will have `rc*` appended. `rc` version bumps will happen automatically, so select the type of version bump for the final release. Use `-s` for no change.'
type: choice
required: true
default: '-s'
options:
- major
- minor
- patch
- '-s'
jobs:
prepare:
if: github.repository_owner == 'viamrobotics'
runs-on: [self-hosted, x64]
container:
image: ghcr.io/viamrobotics/canon:amd64
outputs:
rc_version: ${{ steps.bump_version.outputs.rc_version }}
version: ${{ steps.bump_version.outputs.version }}
steps:
- name: Output Event
run: echo "${{ toJSON(github.event) }}"
- 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: Install GH CLI
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install Package
run: poetry install
- name: Clean Format Test
run: make clean better_imports format test
- name: Current version
id: current_version
shell: bash
run: |
echo "current_version=$(poetry version)" >> $GITHUB_OUTPUT
- name: Bump Version
id: bump_version
shell: bash
run: |
if ${{ contains(steps.current_version.outputs.current_version, 'rc') }} ; then
poetry version prerelease
else
poetry version "$(poetry version ${{ inputs.version }} -s --dry-run)"rc1
fi
echo "SDK_RC_VERSION=$(poetry version -s)" >> $GITHUB_ENV
echo "SDK_VERSION=$(poetry version ${{ inputs.version }} -s --dry-run)" >> $GITHUB_ENV
echo "rc_version=$(poetry version -s)" >> $GITHUB_OUTPUT
echo "version=$(poetry version ${{ inputs.version }} -s --dry-run)" >> $GITHUB_OUTPUT
- name: Check if release exists
uses: cardinalby/[email protected]
id: release_exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseName: v${{ env.SDK_RC_VERSION }}
doNotFailIfNotFound: 'true'
- name: Cancelling - release already exists
uses: andymckay/[email protected]
if: |
steps.release_exists.outputs.id != ''
- name: Add + Commit
uses: EndBug/add-and-commit@v9
with:
new_branch: rc-${{ env.SDK_VERSION }}
message: Bump version to ${{ env.SDK_RC_VERSION }}
- name: Open PR
run: |
gh pr create -t "rc-${{ env.SDK_VERSION }}" -b "This is an auto-generated PR to merge the RC branch back into main upon successful release" -B "main" -H "rc-${{ env.SDK_VERSION }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: prepare
if: github.repository_owner == 'viamrobotics'
runs-on: [self-hosted, x64]
container:
image: ghcr.io/viamrobotics/canon:amd64
strategy:
matrix:
include:
- arch: macosx_x86_64
ext: dylib
whl: macosx_10_16_x86_64
- arch: macosx_arm64
ext: dylib
whl: macosx_11_0_arm64
- arch: linux_aarch64
ext: so
whl: manylinux2014_aarch64
- arch: linux_x86_64
ext: so
whl: manylinux2014_x86_64
- arch: linux_armv6l
ext: so
whl: linux_armv6l
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: rc-${{ needs.prepare.outputs.version }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install package
run: poetry install
- name: Download binary
run: curl -sL -o src/viam/rpc/libviam_rust_utils.${{ matrix.ext }} https://github.com/viamrobotics/rust-utils/releases/latest/download/libviam_rust_utils-${{ matrix.arch }}.${{ matrix.ext }}
- name: Build
run: poetry build -f wheel
- name: Rename
run: mv dist/viam_sdk-$(poetry run python -c "import viam; print(viam.__version__)")-py3-none-any.whl dist/viam_sdk-$(poetry run python -c "import viam; print(viam.__version__)")-py3-none-${{ matrix.whl }}.whl
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
release:
needs: [prepare, build]
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.rc_version }}
files: dist/*
draft: true
prerelease: true
fail_on_unmatched_files: true
target_commitish: rc-${{ needs.prepare.outputs.version }}