publish-bolt-crates.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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.1
  11. anchor_version: 0.29.0
  12. jobs:
  13. install:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - uses: actions/checkout@v4
  17. - uses: actions/cache@v4
  18. name: cache solana cli
  19. id: cache-solana
  20. with:
  21. path: |
  22. ~/.cache/solana/
  23. ~/.local/share/solana/
  24. key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
  25. - uses: actions/setup-node@v4
  26. with:
  27. node-version: 20
  28. - name: install essentials
  29. run: |
  30. sudo apt-get update
  31. sudo apt-get install -y pkg-config build-essential libudev-dev
  32. npm install --global yarn
  33. - name: Cache node dependencies
  34. uses: actions/cache@v3
  35. with:
  36. path: '**/node_modules'
  37. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  38. - name: install node_modules
  39. run: |
  40. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  41. yarn --frozen-lockfile --network-concurrency 2
  42. - name: install rust
  43. uses: dtolnay/rust-toolchain@stable
  44. with:
  45. toolchain: stable
  46. - name: Cache rust
  47. uses: Swatinem/rust-cache@v2
  48. - name: install solana
  49. if: steps.cache-solana.outputs.cache-hit != 'true'
  50. run: |
  51. sh -c "$(curl -sSfL https://release.solana.com/${{ env.solana_version }}/install)"
  52. export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
  53. solana --version
  54. clippy-lint:
  55. needs: install
  56. runs-on: ubuntu-latest
  57. steps:
  58. - uses: actions/checkout@v4
  59. - name: Cache rust
  60. uses: Swatinem/rust-cache@v2
  61. - name: Run fmt
  62. run: cargo fmt -- --check
  63. - name: Run clippy
  64. run: cargo clippy -- --deny=warnings
  65. yarn-lint:
  66. needs: install
  67. runs-on: ubuntu-latest
  68. steps:
  69. - uses: actions/checkout@v4
  70. - name: Use Node ${{ matrix.node }}
  71. uses: actions/setup-node@v4
  72. with:
  73. node-version: 20
  74. - name: Cache node dependencies
  75. uses: actions/cache@v4
  76. with:
  77. path: '**/node_modules'
  78. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  79. - name: Run lint
  80. run: yarn lint
  81. test-and-publish:
  82. needs: [clippy-lint, yarn-lint]
  83. runs-on: ubuntu-latest
  84. steps:
  85. - name: install rust
  86. uses: dtolnay/rust-toolchain@stable
  87. with:
  88. toolchain: stable
  89. - name: Cache rust
  90. uses: Swatinem/rust-cache@v2
  91. - uses: actions/checkout@v4
  92. - name: Set DRY_RUN based on trigger
  93. run: echo "DRY_RUN=true" >> $GITHUB_ENV
  94. if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v')
  95. - name: Use Node ${{ matrix.node }}
  96. uses: actions/setup-node@v4
  97. with:
  98. node-version: 20
  99. - name: Cache node dependencies
  100. uses: actions/cache@v3
  101. with:
  102. path: '**/node_modules'
  103. key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
  104. - name: install node_modules
  105. run: |
  106. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  107. yarn --frozen-lockfile
  108. - uses: actions/cache@v4
  109. name: cache solana cli
  110. id: cache-solana
  111. with:
  112. path: |
  113. ~/.cache/solana/
  114. ~/.local/share/solana/
  115. key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
  116. - name: setup solana
  117. run: |
  118. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  119. solana --version
  120. solana-keygen new --silent --no-bip39-passphrase
  121. - name: Set deployments keys
  122. run: |
  123. mkdir -p target/deploy
  124. echo ${{ secrets.WORLD }} > target/deploy/world-keypair.json
  125. echo ${{ secrets.BOLT_COMPONENT }} > target/deploy/bolt_component-keypair.json
  126. echo ${{ secrets.BOLT_SYSTEM }} > target/deploy/bolt_system-keypair.json
  127. echo ${{ secrets.COMPONENT_POSITION }} > target/deploy/component_position-keypair.json
  128. echo ${{ secrets.COMPONENT_VELOCITY }} > target/deploy/component_velocity-keypair.json
  129. echo ${{ secrets.SYSTEM_APPLY_VELOCITY }} > target/deploy/system_apply_velocity-keypair.json
  130. echo ${{ secrets.SYSTEM_FLY }} > target/deploy/system_fly-keypair.json
  131. echo ${{ secrets.SYSTEM_SIMPLE_MOVEMENT }} > target/deploy/system_simple_movement-keypair.json
  132. - name: Check versions are aligned
  133. run: |
  134. # Fails if versions are not aligned
  135. cargo install git-cliff
  136. ./version-align.sh --check
  137. - name: run build
  138. run: |
  139. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  140. cargo install --path cli --force --locked
  141. bolt build
  142. - name: run tests
  143. run: |
  144. export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
  145. cargo install --path cli --force --locked
  146. bolt test
  147. - name: cargo publish
  148. run: |
  149. DRY_RUN_FLAG=""
  150. if [ "${DRY_RUN}" = "true" ]; then
  151. DRY_RUN_FLAG="--dry-run"
  152. fi
  153. if [ "${DRY_RUN}" = "true" ]; then
  154. NO_VERIFY_FLAG="--no-verify"
  155. fi
  156. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/utils/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  157. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/component/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  158. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/component-deserialize/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  159. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/component-id/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  160. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/system/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  161. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/system-input/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  162. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/extra-accounts/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  163. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/arguments/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  164. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/attribute/bolt-program/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  165. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-helpers/attribute/system-template/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  166. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-helpers/attribute/world-apply/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  167. cargo publish $DRY_RUN_FLAG --manifest-path=programs/bolt-system/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  168. cargo publish $DRY_RUN_FLAG --manifest-path=programs/bolt-component/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  169. cargo publish $DRY_RUN_FLAG --manifest-path=programs/world/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  170. cargo publish $DRY_RUN_FLAG --manifest-path=crates/bolt-lang/Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
  171. env:
  172. CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
  173. DRY_RUN: ${{ env.DRY_RUN }}