Release Candidate #37
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 Candidate | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'The type of version bump. Select "nobump" for no version change. `rc` version bumps will happen automatically, so select the type of version bump for the final release. See https://github.com/npm/node-semver#functions' | |
type: choice | |
required: true | |
default: nobump | |
options: | |
- premajor | |
- preminor | |
- prepatch | |
- nobump # this action is custom for this action and does not exist in npm | |
secrets: | |
NPM_TOKEN: | |
required: true | |
jobs: | |
prepare: | |
if: github.repository_owner == 'viamrobotics' | |
runs-on: [self-hosted, x64] | |
container: | |
image: ghcr.io/viamrobotics/canon:amd64 | |
outputs: | |
rc_version: ${{ steps.which_version.outputs.rc_version }} | |
version: ${{ steps.which_version.outputs.version }} | |
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 - not an organization member | |
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: Build + Lint + Test | |
run: | | |
sudo chown -R testbot . | |
sudo -u testbot bash -lc 'make build lint test' | |
- name: Current version | |
id: current_version | |
shell: bash | |
run: | | |
echo "current_version=$(npm pkg get version)" >> $GITHUB_OUTPUT | |
- name: Bump Version | |
id: bump_version | |
shell: bash | |
run: | | |
if ${{ contains(steps.current_version.outputs.current_version, 'rc') }} ; then | |
npm version prerelease --preid=rc --no-git-tag-version | |
elif ${{ contains(steps.current_version.outputs.current_version, 'next') && inputs.version == 'prepatch' }} ; then | |
npm version prerelease --preid=rc --no-git-tag-version | |
else | |
npm version ${{ inputs.version }} --preid=rc --no-git-tag-version | |
fi | |
if: inputs.version != 'nobump' | |
- name: Which Version | |
id: which_version | |
shell: bash | |
run: | | |
echo "rc_version=$(npm pkg get version | sed 's/\"//g')" >> $GITHUB_OUTPUT | |
echo "version=$(npm pkg get version | sed -e 's/\"//g' -e 's/-rc.*//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.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-${{ steps.which_version.outputs.version }} | |
message: Bump version to ${{ steps.which_version.outputs.rc_version }} | |
- name: Open PR | |
run: | | |
gh pr create -t "rc-${{ steps.which_version.outputs.version }}" -b "This is an auto-generated PR to merge the RC branch back into main upon successful release" -B "main" -H "rc-${{ steps.which_version.outputs.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 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
ref: rc-${{ needs.prepare.outputs.version }} | |
- name: Build + Pack | |
run: | | |
sudo chown -R testbot . | |
sudo -u testbot bash -lc 'make build pack' | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: viamrobotics-sdk-*.tgz | |
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 }} |