diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 56dea074b..6aa9293c2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 }} diff --git a/.github/workflows/publish_next.yml b/.github/workflows/publish_next.yml new file mode 100644 index 000000000..c6df50357 --- /dev/null +++ b/.github/workflows/publish_next.yml @@ -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 diff --git a/.github/workflows/release_candidate.yml b/.github/workflows/release_candidate.yml index 232dce274..578e450ef 100644 --- a/.github/workflows/release_candidate.yml +++ b/.github/workflows/release_candidate.yml @@ -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 diff --git a/Makefile b/Makefile index 6a5b73767..e62f14d28 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/package-lock.json b/package-lock.json index e09d46486..a8590920c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@viamrobotics/sdk", - "version": "0.2.2", + "version": "0.2.3-next.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@viamrobotics/sdk", - "version": "0.2.2", + "version": "0.2.3-next.0", "license": "Apache-2.0", "dependencies": { "@viamrobotics/rpc": "^0.1.37", diff --git a/package.json b/package.json index 818eb0163..324c19397 100644 --- a/package.json +++ b/package.json @@ -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",