Skip to content

Publish JS Client

Publish JS Client #9

name: Publish 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
publish_js:
name: JS client / Publish
runs-on: ubuntu-latest
needs: test_js
permissions:
contents: write
id-token: write
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 8.9.0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Install npm 11.x (min 11.5.1)
run: npm install -g "npm@^11.5.1"
- 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: Publish
working-directory: ./clients/js
run: npm publish --access public --tag ${{ inputs.tag }} --provenance
- name: Create release pull request
if: ${{ github.event.inputs.create_release == 'true' }}
uses: peter-evans/create-pull-request@v6
with:
commit-message: 'chore: release JS client v${{ steps.bump.outputs.new_version }}'
branch: release/js-client-v${{ steps.bump.outputs.new_version }}
title: 'chore: release JS client v${{ steps.bump.outputs.new_version }}'
body: |
## Summary
- publish-js-client workflow bumped the package to `${{ steps.bump.outputs.new_version }}`
labels: release
- 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: publish_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