-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
176 additions
and
91 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
name: NPM Publish | ||
|
||
on: | ||
workflow_call: | ||
release: | ||
types: [published] | ||
secrets: | ||
NPM_TOKEN: | ||
required: true | ||
|
@@ -14,17 +15,44 @@ jobs: | |
image: ghcr.io/viamrobotics/canon:amd64 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Check if organization member | ||
id: is_organization_member | ||
if: github.event_name == 'workflow_dispatch' | ||
uses: jamessingleton/[email protected] | ||
with: | ||
persist-credentials: false | ||
organization: viamrobotics | ||
username: ${{ github.actor }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build | ||
- name: Cancelling - not an organization member | ||
uses: andymckay/[email protected] | ||
if: | | ||
github.event_name == 'workflow_dispatch' && steps.is_organization_member.outputs.result == 'false' | ||
- name: Download Release | ||
uses: dsaltares/fetch-gh-release-asset@master | ||
with: | ||
file: "viamrobotics\\-sdk\\-.*\\.tgz" | ||
regex: true | ||
target: './' | ||
version: tags/${{ github.event.release.tag_name }} | ||
|
||
- name: Check Files | ||
id: release_file | ||
run: echo "path=$(ls -1 | head -1)" >> $GITHUB_OUTPUT | ||
|
||
- name: Which Tag | ||
id: which_tag | ||
run: | | ||
sudo chown -R testbot . | ||
sudo -u testbot bash -lc 'make build' | ||
if [[ ${{ github.event.release.tag_name }} == *"rc"* ]]; then | ||
echo "tag=rc" >> $GITHUB_OUTPUT | ||
else | ||
echo "tag=latest" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Publish | ||
uses: JS-DevTools/npm-publish@v1 | ||
uses: JS-DevTools/npm-publish@v2 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
tag: ${{ steps.which_tag.outputs.tag }} | ||
package: ${{ steps.release_file.outputs.path }} |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: Publish Release Candidate to NPM | ||
|
||
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: 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: Bump Version | ||
id: bump_version | ||
run: | | ||
if [[ $(npm pkg get version) == *"rc"* ]]; 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 | ||
run: | | ||
echo "SDK_RC_VERSION=$(npm pkg get version | sed 's/\"//g')" >> $GITHUB_ENV | ||
echo "SDK_VERSION=${$(npm pkg get version | sed 's/\"//g')%-rc*}" >> $GITHUB_ENV | ||
echo "rc_version=$(npm pkg get version | sed 's/\"//g')" >> $GITHUB_OUTPUT | ||
echo "version=${$(npm pkg get version | sed 's/\"//g')%-rc*}" >> $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 + Open PR | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
commit-message: Bump version to ${{ env.RC_SDK_VERSION }} | ||
branch: rc-${{ env.SDK_VERSION }} | ||
delete-branch: false | ||
base: main | ||
title: rc-${{ env.SDK_VERSION }} | ||
body: This is an auto-generated PR to merge the rc branch back into main upon successful release. | ||
|
||
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: packed | ||
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 }} |