publish-js-client.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. name: Publish JS Client
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. level:
  6. description: Version level
  7. required: true
  8. default: patch
  9. type: choice
  10. options:
  11. - patch
  12. - minor
  13. - major
  14. - prerelease
  15. - prepatch
  16. - preminor
  17. - premajor
  18. tag:
  19. description: NPM Tag (and preid for pre-releases)
  20. required: true
  21. type: string
  22. default: latest
  23. create_release:
  24. description: Create a GitHub release
  25. required: true
  26. type: boolean
  27. default: true
  28. jobs:
  29. test_js:
  30. name: Test JS client
  31. runs-on: ubuntu-latest
  32. steps:
  33. - name: Git Checkout
  34. uses: actions/checkout@v4
  35. - name: Setup Environment
  36. uses: ./.github/actions/setup
  37. with:
  38. solana: true
  39. - name: Format JS Client
  40. run: pnpm clients:js:format
  41. - name: Lint JS Client
  42. run: pnpm clients:js:lint
  43. - name: Test JS Client
  44. run: pnpm clients:js:test
  45. publish_js:
  46. name: Publish JS client
  47. runs-on: ubuntu-latest
  48. needs: test_js
  49. permissions:
  50. contents: write
  51. steps:
  52. - name: Git Checkout
  53. uses: actions/checkout@v4
  54. - name: Setup Environment
  55. uses: ./.github/actions/setup
  56. - name: Ensure NPM_TOKEN variable is set
  57. env:
  58. token: ${{ secrets.NPM_TOKEN }}
  59. if: ${{ env.token == '' }}
  60. run: |
  61. echo "The NPM_TOKEN secret variable is not set"
  62. echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
  63. exit 1
  64. - name: NPM Authentication
  65. run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
  66. env:
  67. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  68. - name: Set Git Author
  69. run: |
  70. git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  71. git config --global user.name "github-actions[bot]"
  72. - name: Publish JS Client
  73. id: publish
  74. run: pnpm clients:js:publish ${{ inputs.level }} ${{ inputs.tag }}
  75. - name: Push Commit and Tag
  76. run: git push origin --follow-tags
  77. - name: Create GitHub release
  78. if: github.event.inputs.create_release == 'true'
  79. uses: ncipollo/release-action@v1
  80. with:
  81. tag: js@v${{ steps.publish.outputs.new_version }}