publish-js-client.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. pnpm: true
  39. solana: true
  40. - name: Format
  41. run: make format-js
  42. - name: Lint
  43. run: make lint-js
  44. - name: Test
  45. run: make test-js
  46. publish_js:
  47. name: Publish JS client
  48. runs-on: ubuntu-latest
  49. needs: test_js
  50. permissions:
  51. contents: write
  52. steps:
  53. - name: Git Checkout
  54. uses: actions/checkout@v4
  55. with:
  56. token: ${{ secrets.ANZA_TEAM_PAT }}
  57. - name: Setup Environment
  58. uses: ./.github/actions/setup
  59. with:
  60. pnpm: true
  61. - name: Ensure NPM_TOKEN variable is set
  62. env:
  63. token: ${{ secrets.NPM_TOKEN }}
  64. if: ${{ env.token == '' }}
  65. run: |
  66. echo "The NPM_TOKEN secret variable is not set"
  67. echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
  68. exit 1
  69. - name: NPM Authentication
  70. run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
  71. env:
  72. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  73. - name: Set Git Author
  74. run: |
  75. git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  76. git config --global user.name "github-actions[bot]"
  77. - name: Publish JS Client
  78. id: publish
  79. run: ./scripts/publish-js.sh clients/js ${{ inputs.level }} ${{ inputs.tag }}
  80. - name: Push Commit and Tag
  81. run: git push origin --follow-tags
  82. - name: Create GitHub release
  83. if: github.event.inputs.create_release == 'true'
  84. uses: ncipollo/release-action@v1
  85. with:
  86. tag: js@v${{ steps.publish.outputs.new_version }}