publish-bolt-sdk.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. name: Publish Bolt SDKs
  2. on:
  3. release:
  4. types: [ published ]
  5. push:
  6. branches:
  7. - 'release/v*'
  8. workflow_dispatch:
  9. env:
  10. solana_version: v1.18.15
  11. jobs:
  12. install:
  13. runs-on: ubuntu-latest
  14. steps:
  15. - uses: actions/checkout@v4
  16. - uses: actions/cache@v4
  17. name: cache solana cli
  18. id: cache-solana
  19. with:
  20. path: |
  21. ~/.cache/solana/
  22. ~/.local/share/solana/
  23. key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
  24. - uses: actions/setup-node@v4
  25. with:
  26. node-version: 21
  27. - name: install essentials
  28. run: |
  29. sudo apt-get update
  30. sudo apt-get install -y pkg-config build-essential libudev-dev
  31. npm install --global yarn
  32. - name: Cache node dependencies
  33. uses: actions/cache@v3
  34. with:
  35. path: '**/node_modules'
  36. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  37. - name: install node_modules
  38. run: |
  39. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  40. yarn --frozen-lockfile --network-concurrency 2
  41. - name: install rust
  42. uses: dtolnay/rust-toolchain@stable
  43. with:
  44. toolchain: 1.81.0
  45. - name: Cache rust
  46. uses: Swatinem/rust-cache@v2
  47. - name: install solana
  48. if: steps.cache-solana.outputs.cache-hit != 'true'
  49. run: |
  50. sh -c "$(curl -sSfL https://release.solana.com/${{ env.solana_version }}/install)"
  51. export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
  52. solana --version
  53. yarn-lint:
  54. needs: install
  55. runs-on: ubuntu-latest
  56. steps:
  57. - uses: actions/checkout@v4
  58. - name: Use Node ${{ matrix.node }}
  59. uses: actions/setup-node@v4
  60. with:
  61. node-version: 21
  62. # FIXME: This is not working
  63. # - name: Cache node dependencies
  64. # uses: actions/cache@v4
  65. # with:
  66. # path: '**/node_modules'
  67. # key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  68. - name: install node_modules
  69. run: yarn install
  70. - name: Run lint
  71. run: yarn lint
  72. test:
  73. needs: [yarn-lint]
  74. runs-on: ubuntu-latest
  75. steps:
  76. - name: install rust
  77. uses: dtolnay/rust-toolchain@stable
  78. with:
  79. toolchain: 1.81.0
  80. - name: Cache rust
  81. uses: Swatinem/rust-cache@v2
  82. - uses: actions/checkout@v4
  83. - name: Set DRY_RUN based on trigger
  84. run: echo "DRY_RUN=true" >> $GITHUB_ENV
  85. if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')
  86. - name: Use Node ${{ matrix.node }}
  87. uses: actions/setup-node@v4
  88. with:
  89. node-version: 21
  90. - name: Cache node dependencies
  91. uses: actions/cache@v3
  92. with:
  93. path: '**/node_modules'
  94. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  95. - name: install node_modules
  96. run: |
  97. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  98. yarn --frozen-lockfile
  99. - uses: actions/cache@v4
  100. name: cache solana cli
  101. id: cache-solana
  102. with:
  103. path: |
  104. ~/.cache/solana/
  105. ~/.local/share/solana/
  106. key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
  107. - name: setup solana
  108. run: |
  109. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  110. solana --version
  111. solana-keygen new --silent --no-bip39-passphrase
  112. - name: Set deployments keys
  113. run: |
  114. mkdir -p target/deploy
  115. echo ${{ secrets.WORLD }} > target/deploy/world-keypair.json
  116. echo ${{ secrets.BOLT_COMPONENT }} > target/deploy/bolt_component-keypair.json
  117. echo ${{ secrets.BOLT_SYSTEM }} > target/deploy/bolt_system-keypair.json
  118. echo ${{ secrets.COMPONENT_POSITION }} > target/deploy/component_position-keypair.json
  119. echo ${{ secrets.COMPONENT_VELOCITY }} > target/deploy/component_velocity-keypair.json
  120. echo ${{ secrets.SYSTEM_APPLY_VELOCITY }} > target/deploy/system_apply_velocity-keypair.json
  121. echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json
  122. echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json
  123. - name: Check versions are aligned
  124. run: |
  125. # Fails if versions are not aligned
  126. cargo install git-cliff@2.6.1 --locked
  127. ./scripts/version-align.sh --check
  128. - name: run build
  129. run: |
  130. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  131. cargo install --path crates/bolt-cli --force --locked
  132. bolt build
  133. - name: Generate lib
  134. run: |
  135. cd clients/typescript
  136. yarn install && yarn build
  137. cd ../..
  138. - name: run tests
  139. run: |
  140. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  141. cargo install --path crates/bolt-cli --force --locked
  142. bolt test
  143. - name: npm publish
  144. run: |
  145. npm install
  146. echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
  147. npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
  148. cd clients/typescript && npm run build && npm run lint:fix && cd ../.. && npm run lint:fix
  149. cd clients/typescript
  150. if [ "${DRY_RUN}" = "true" ]; then
  151. echo "Running npm publish in dry-run mode"
  152. npm publish --access public --dry-run
  153. else
  154. npm publish --access public
  155. fi
  156. env:
  157. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}