Skip to content

Deploy JS Client

Deploy JS Client #11

name: Deploy JS Client
on:
workflow_dispatch:
inputs:
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
deploy_js:
name: JS client / Deploy
runs-on: ubuntu-latest
needs: test_js
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.SVC_TOKEN }}
- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
- name: Install Node.js
uses: metaplex-foundation/actions/install-node-with-pnpm@v1
with:
version: ${{ env.NODE_VERSION }}
cache: ${{ env.CACHE }}
- name: Install dependencies
uses: metaplex-foundation/actions/install-node-dependencies@v1
with:
folder: ./clients/js
cache: ${{ env.CACHE }}
key: clients-js
- name: Build
working-directory: ./clients/js
run: pnpm build
- name: Bump
id: bump
working-directory: ./clients/js
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
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: ubuntu-latest
needs: deploy_js
environment:
name: js-client-documentation
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Git checkout
uses: actions/checkout@v3
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
run: echo "url=$(vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }})" | tee $GITHUB_OUTPUT