publish-bolt-crates.yml 7.8 KB

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