publish-bolt-crates.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. name: Publish Bolt crates
  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: stable
  45. - name: Install Rust nightly
  46. uses: dtolnay/rust-toolchain@nightly
  47. with:
  48. toolchain: nightly
  49. - name: Cache rust
  50. uses: Swatinem/rust-cache@v2
  51. - name: install solana
  52. if: steps.cache-solana.outputs.cache-hit != 'true'
  53. run: |
  54. sh -c "$(curl -sSfL https://release.solana.com/${{ env.solana_version }}/install)"
  55. export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
  56. solana --version
  57. clippy-lint:
  58. needs: install
  59. runs-on: ubuntu-latest
  60. steps:
  61. - uses: actions/checkout@v4
  62. - name: Cache rust
  63. uses: Swatinem/rust-cache@v2
  64. - name: Run fmt
  65. run: cargo fmt -- --check --verbose
  66. - name: Run clippy
  67. run: cargo clippy -- --deny=warnings --allow=unexpected_cfgs
  68. test-and-publish:
  69. needs: [clippy-lint]
  70. runs-on: ubuntu-latest
  71. steps:
  72. - name: install rust
  73. uses: dtolnay/rust-toolchain@stable
  74. with:
  75. toolchain: stable
  76. - name: Cache rust
  77. uses: Swatinem/rust-cache@v2
  78. - uses: actions/checkout@v4
  79. - name: Set DRY_RUN based on trigger
  80. run: echo "DRY_RUN=true" >> $GITHUB_ENV
  81. if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')
  82. - name: Use Node ${{ matrix.node }}
  83. uses: actions/setup-node@v4
  84. with:
  85. node-version: 21
  86. - name: Cache node dependencies
  87. uses: actions/cache@v3
  88. with:
  89. path: '**/node_modules'
  90. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  91. - name: install node_modules
  92. run: |
  93. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  94. yarn --frozen-lockfile
  95. - uses: actions/cache@v4
  96. name: cache solana cli
  97. id: cache-solana
  98. with:
  99. path: |
  100. ~/.cache/solana/
  101. ~/.local/share/solana/
  102. key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
  103. - name: setup solana
  104. run: |
  105. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  106. solana --version
  107. solana-keygen new --silent --no-bip39-passphrase
  108. - name: Set deployments keys
  109. run: |
  110. mkdir -p target/deploy
  111. echo ${{ secrets.WORLD }} > target/deploy/world-keypair.json
  112. echo ${{ secrets.BOLT_COMPONENT }} > target/deploy/bolt_component-keypair.json
  113. echo ${{ secrets.BOLT_SYSTEM }} > target/deploy/bolt_system-keypair.json
  114. echo ${{ secrets.COMPONENT_POSITION }} > target/deploy/component_position-keypair.json
  115. echo ${{ secrets.COMPONENT_VELOCITY }} > target/deploy/component_velocity-keypair.json
  116. echo ${{ secrets.SYSTEM_APPLY_VELOCITY }} > target/deploy/system_apply_velocity-keypair.json
  117. echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json
  118. echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json
  119. - name: Check versions are aligned
  120. run: |
  121. # Fails if versions are not aligned
  122. cargo install git-cliff@2.6.1 --locked
  123. ./scripts/version-align.sh --check
  124. - name: run build
  125. run: |
  126. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  127. cargo install --path crates/bolt-cli --force --locked
  128. bolt build
  129. - name: Generate lib
  130. run: |
  131. cd clients/typescript
  132. yarn install && yarn build
  133. cd ../..
  134. - name: run tests
  135. run: |
  136. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  137. cargo install --path crates/bolt-cli --force --locked
  138. bolt test
  139. - name: cargo publish
  140. run: |
  141. DRY_RUN_FLAG=""
  142. if [ "${DRY_RUN}" = "true" ]; then
  143. DRY_RUN_FLAG="--dry-run"
  144. fi
  145. if [ "${DRY_RUN}" = "true" ]; then
  146. NO_VERIFY_FLAG="--no-verify"
  147. fi
  148. cargo +nightly publish -Zpackage-workspace $DRY_RUN_FLAG $NO_VERIFY_FLAG --token $CRATES_TOKEN \
  149. -p world \
  150. -p bolt-cli \
  151. -p bolt-lang \
  152. -p bolt-utils \
  153. -p bolt-system \
  154. -p bolt-component \
  155. -p bolt-attribute-bolt-arguments \
  156. -p bolt-attribute-bolt-component \
  157. -p bolt-attribute-bolt-component-deserialize \
  158. -p bolt-attribute-bolt-component-id \
  159. -p bolt-attribute-bolt-delegate \
  160. -p bolt-attribute-bolt-extra-accounts \
  161. -p bolt-attribute-bolt-program \
  162. -p bolt-attribute-bolt-system \
  163. -p bolt-attribute-bolt-system-input
  164. env:
  165. CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
  166. DRY_RUN: ${{ env.DRY_RUN }}