Publish SDK #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
scope: "@gmx-io" | |
auth-token: ${{ secrets.NPM_TOKEN }} | |
- name: Install dependencies | |
working-directory: ./sdk | |
run: yarn install --immutable | |
- 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 }} |