publish-rust-client.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Publish Rust Client
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. level:
  6. description: Level
  7. required: true
  8. default: patch
  9. type: choice
  10. options:
  11. - patch
  12. - minor
  13. - major
  14. - rc
  15. - beta
  16. - alpha
  17. - release
  18. - version
  19. version:
  20. description: Version
  21. required: false
  22. type: string
  23. dry_run:
  24. description: Dry run
  25. required: true
  26. default: true
  27. type: boolean
  28. create_release:
  29. description: Create a GitHub release
  30. required: true
  31. type: boolean
  32. default: true
  33. jobs:
  34. test_rust:
  35. name: Test Rust client
  36. runs-on: ubuntu-latest
  37. steps:
  38. - name: Git Checkout
  39. uses: actions/checkout@v4
  40. - name: Setup Environment
  41. uses: ./.github/actions/setup
  42. with:
  43. cargo-cache-key: cargo-rust-client
  44. clippy: true
  45. rustfmt: true
  46. solana: true
  47. - name: Format Rust Client
  48. run: pnpm clients:rust:format
  49. - name: Lint Rust Client
  50. run: pnpm clients:rust:lint
  51. - name: Build Programs
  52. run: pnpm programs:build
  53. - name: Test Rust Client
  54. run: pnpm clients:rust:test
  55. publish_rust:
  56. name: Publish Rust Client
  57. runs-on: ubuntu-latest
  58. needs: test_rust
  59. permissions:
  60. contents: write
  61. steps:
  62. - name: Git Checkout
  63. uses: actions/checkout@v4
  64. - name: Setup Environment
  65. uses: ./.github/actions/setup
  66. with:
  67. cargo-cache-key: cargo-publish-rust-client
  68. cargo-cache-fallback-key: cargo-rust-client
  69. clippy: true
  70. rustfmt: true
  71. - name: Install Cargo Release
  72. run: which cargo-release || cargo install cargo-release
  73. - name: Ensure CARGO_REGISTRY_TOKEN variable is set
  74. env:
  75. token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  76. if: ${{ env.token == '' }}
  77. run: |
  78. echo "The CARGO_REGISTRY_TOKEN secret variable is not set"
  79. echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
  80. exit 1
  81. - name: Set Git Author
  82. run: |
  83. git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  84. git config --global user.name "github-actions[bot]"
  85. - name: Publish Rust Client
  86. id: publish
  87. env:
  88. CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  89. run: |
  90. if [ "${{ inputs.level }}" == "version" ]; then
  91. LEVEL=${{ inputs.version }}
  92. else
  93. LEVEL=${{ inputs.level }}
  94. fi
  95. if [ "${{ inputs.dry_run }}" == "true" ]; then
  96. OPTIONS="--dry-run"
  97. else
  98. OPTIONS=""
  99. fi
  100. pnpm clients:rust:publish $LEVEL $OPTIONS
  101. - name: Push Commit and Tag
  102. if: github.event.inputs.dry_run != 'true'
  103. run: git push origin --follow-tags
  104. - name: Create GitHub release
  105. if: github.event.inputs.create_release == 'true' && github.event.inputs.dry_run != 'true'
  106. uses: ncipollo/release-action@v1
  107. with:
  108. tag: rust@v${{ steps.publish.outputs.new_version }}