publish-bolt-crates.yml 7.2 KB

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