Skip to content

Commit

Permalink
RSDK-3923 Add workflow to publish off-cycle versions (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpertsov authored Jul 10, 2023
1 parent 2c86432 commit 60a3ddb
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ on:
jobs:
test:
uses: viamrobotics/viam-typescript-sdk/.github/workflows/test.yml@main

publish_next:
needs: test
uses: viamrobotics/viam-typescript-sdk/.github/workflows/publish_next.yml@main
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/publish_next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: NPM Publish Next

on:
workflow_call:
secrets:
NPM_TOKEN:
required: true

jobs:
publish_next:
if: github.repository_owner == 'viamrobotics'
runs-on: [self-hosted, x64]
container:
image: ghcr.io/viamrobotics/canon:amd64

steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Build
run: |
sudo chown -R testbot .
sudo -u testbot bash -lc 'make build'
- name: Publish (dry run)
id: check_new_version
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
tag: next
dry-run: true

- name: Validate version name
if: ${{ steps.check_new_version.outputs.type }}
shell: bash
run: |
if [[ ! "$(npm pkg get version)" =~ ^\"[0-9]+\.[0-9]+\.[0-9]\-next\.[0-9]+\"$ ]]; then
echo "::error::Cannot publish an off-cycle version named: $(npm pkg get version). Please run 'make bump-next-version' to generate a valid version name."
exit 1
fi
- name: Publish
if: ${{ steps.check_new_version.outputs.type }}
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
tag: next
2 changes: 2 additions & 0 deletions .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ jobs:
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
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ build-js: $(node_modules) clean-js build-buf
pack: build
npm pack

# bump to the next pre-release version on the `next` distribution tag -
# run this command if you need to publish an off-cycle release of the sdk
.PHONY: bump-next-version
bump-next-version:
npm version --no-git-tag-version prerelease --preid=next

# docs targets

.PHONY: clean-docs
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/sdk",
"version": "0.2.2",
"version": "0.2.3-next.0",
"description": "",
"main": "./dist/main.umd.js",
"module": "./dist/main.es.js",
Expand Down

0 comments on commit 60a3ddb

Please sign in to comment.