Skip to content

Publish SDK

Publish SDK #19

Workflow file for this run

name: Publish SDK
on:
workflow_dispatch:
inputs:
version_type:
description: "Version increment type"
required: false
default: "patch"
type: choice
options:
- patch
- minor
- major
- custom
custom_version:
description: "Custom version (if version_type is custom)"
required: false
default: ""
type: string
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
registry-url: "https://registry.npmjs.org/"
always-auth: true
auth-token: ${{ secrets.NPM_TOKEN }}
cache: "yarn"
- name: Install dependencies
working-directory: ./sdk
run: yarn install --frozen-lockfile
- name: Build package
working-directory: ./sdk
run: |
yarn prebuild
yarn build
- name: Bump version
working-directory: ./sdk
run: |
if [ "${{ github.event.inputs.version_type }}" == "custom" ]; then
if [ -z "${{ github.event.inputs.custom_version }}" ]; then
echo "Custom version not specified"
exit 1
fi
yarn version "${{ github.event.inputs.custom_version }}"
else
yarn version ${{ github.event.inputs.version_type }}
fi
- name: Commit version bump
working-directory: ./sdk
run: |
git config user.name "GMX Release Bot"
git config user.email "release-bot@gmx.io"
git add package.json
git commit -m "Bump SDK version to $(jq -r .version package.json)"
- run: npm publish --access public
working-directory: ./sdk
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Push changes
run: |
if [ "${{ github.event.inputs.version_type }}" == "custom" ]; then
exit 0
fi
git push origin HEAD:${{ github.ref_name }}