Skip to content

Publish JS Client

Publish JS Client #6

name: Publish JS Client
on:
workflow_dispatch:
inputs:
client:
description: Client
required: true
default: asset
type: choice
options:
- asset
- bridge
bump:
description: Version bump
required: true
default: patch
type: choice
options:
- patch
- minor
- major
- prerelease
- prepatch
- preminor
- premajor
tag:
description: NPM Tag (and preid for pre-releases)
required: true
type: string
default: latest
create_release:
description: Create a GitHub release
required: true
type: boolean
default: true
env:
CACHE: true
jobs:
build_programs:
name: Programs
uses: ./.github/workflows/build-programs.yml
secrets: inherit
test_js:
name: JS client
needs: build_programs
uses: ./.github/workflows/test-js-client.yml
secrets: inherit
with:
client_matrix: "[\"${{ inputs.client }}\"]"
publish_js:
name: JS client / Publish
runs-on: buildjet-8vcpu-ubuntu-2204
needs: test_js
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.SERVICE_TOKEN }}
- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
- name: Install Node.js
uses: nifty-oss/actions/install-node-with-pnpm@v1
with:
version: ${{ env.NODE_VERSION }}
cache: ${{ env.CACHE }}
- name: Install dependencies
uses: nifty-oss/actions/install-node-dependencies@v1
with:
folder: ./clients/js
cache: ${{ env.CACHE }}
key: clients-js
- name: Build
working-directory: ./clients/js/${{ inputs.client }}
run: pnpm build
- name: Bump
id: bump
working-directory: ./clients/js/${{ inputs.client }}
run: |
if [ "${{ startsWith(inputs.bump, 'pre') }}" == "true" ]; then
pnpm version ${{ inputs.bump }} --preid ${{ inputs.tag }} --no-git-tag-version
else
pnpm version ${{ inputs.bump }} --no-git-tag-version
fi
echo "new_version=$(pnpm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish
working-directory: ./clients/js/${{ inputs.client }}
run: pnpm publish --no-git-checks --tag ${{ inputs.tag }}
- name: Commit and tag new version
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Deploy JS client v${{ steps.bump.outputs.new_version }}
tagging_message: js@v${{ steps.bump.outputs.new_version }}
- name: Create GitHub release
if: github.event.inputs.create_release == 'true'
uses: ncipollo/release-action@v1
with:
tag: js@v${{ steps.bump.outputs.new_version }}
#deploy_js_docs:
# name: JS client / Deploy docs
# runs-on: buildjet-8vcpu-ubuntu-2204
# needs: publish_js
# environment:
# name: js-client-documentation
# url: ${{ steps.deploy.outputs.url }}
# steps:
# - name: Git checkout
# uses: actions/checkout@v4
# with:
# ref: ${{ github.ref }}
#
# - name: Load environment variables
# run: cat .github/.env >> $GITHUB_ENV
#
# - name: Deploy to Vercel
# id: deploy
# env:
# VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
# VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# working-directory: ./clients/js/${{ inputs.client }}
# run:
# echo "url=$(vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }})" | tee
# $GITHUB_OUTPUT