publish-rust-client.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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: Test Rust Client
  52. run: pnpm clients:rust:test
  53. publish_rust:
  54. name: Publish Rust Client
  55. runs-on: ubuntu-latest
  56. needs: test_rust
  57. permissions:
  58. contents: write
  59. steps:
  60. - name: Git Checkout
  61. uses: actions/checkout@v4
  62. - name: Setup Environment
  63. uses: ./.github/actions/setup
  64. with:
  65. cargo-cache-key: cargo-publish-rust-client
  66. cargo-cache-fallback-key: cargo-rust-client
  67. clippy: true
  68. rustfmt: true
  69. - name: Install Cargo Release
  70. run: which cargo-release || cargo install cargo-release
  71. - name: Ensure CARGO_REGISTRY_TOKEN variable is set
  72. env:
  73. token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  74. if: ${{ env.token == '' }}
  75. run: |
  76. echo "The CARGO_REGISTRY_TOKEN secret variable is not set"
  77. echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
  78. exit 1
  79. - name: Set Git Author
  80. run: |
  81. git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  82. git config --global user.name "github-actions[bot]"
  83. - name: Publish Rust Client
  84. id: publish
  85. env:
  86. CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  87. run: |
  88. if [ "${{ inputs.level }}" == "version" ]; then
  89. LEVEL=${{ inputs.version }}
  90. else
  91. LEVEL=${{ inputs.level }}
  92. fi
  93. if [ "${{ inputs.dry_run }}" == "true" ]; then
  94. OPTIONS="--dry-run"
  95. else
  96. OPTIONS=""
  97. fi
  98. pnpm clients:rust:publish $LEVEL $OPTIONS
  99. - name: Push Commit and Tag
  100. if: github.event.inputs.dry_run != 'true'
  101. run: git push origin --follow-tags
  102. - name: Create GitHub release
  103. if: github.event.inputs.create_release == 'true' && github.event.inputs.dry_run != 'true'
  104. uses: ncipollo/release-action@v1
  105. with:
  106. tag: rust@v${{ steps.publish.outputs.new_version }}