Skip to content

Publish JS Client

Publish JS Client #2

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:
test_js:
name: JS client
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
steps:
- name: Git checkout
uses: actions/checkout@v3
- 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: ./
cache: ${{ env.CACHE }}
key: clients-js
- name: Build
working-directory: ./
run: pnpm build
- name: Bump
id: bump
working-directory: ./
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: ./
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 }}