publish.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. name: Publish
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. crate:
  6. description: Crate
  7. required: true
  8. default: sdk/pinocchio
  9. type: choice
  10. options:
  11. - programs/associated-token-account
  12. - programs/system
  13. - programs/token
  14. - sdk/log/crate
  15. - sdk/log/macro
  16. - sdk/pinocchio
  17. - sdk/pubkey
  18. level:
  19. description: Level
  20. required: true
  21. default: patch
  22. type: choice
  23. options:
  24. - patch
  25. - minor
  26. - major
  27. dry_run:
  28. description: Dry run
  29. required: true
  30. default: true
  31. type: boolean
  32. create_release:
  33. description: Create a GitHub release
  34. required: true
  35. type: boolean
  36. default: true
  37. env:
  38. CACHE: true
  39. jobs:
  40. publish_release:
  41. name: Publish
  42. runs-on: ubuntu-latest
  43. steps:
  44. - name: Ensure CARGO_REGISTRY_TOKEN variable is set
  45. env:
  46. token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  47. if: ${{ env.token == '' }}
  48. run: |
  49. echo "The CARGO_REGISTRY_TOKEN secret variable is not set"
  50. echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
  51. exit 1
  52. - name: Git checkout
  53. uses: actions/checkout@v4
  54. - name: Setup Environment
  55. uses: ./.github/actions/setup
  56. with:
  57. cargo-cache-key: cargo-publish
  58. toolchain: test
  59. components: semver-checks
  60. solana: true
  61. - name: Build
  62. run: pnpm build-sbf ${{ inputs.crate }}
  63. - name: Test
  64. run: pnpm test ${{ inputs.crate }}
  65. - name: Set Git Author
  66. run: |
  67. git config --global user.email "github-actions@github.com"
  68. git config --global user.name "github-actions"
  69. - name: Check semver
  70. run: |
  71. pnpm semver ${{ inputs.crate }} --release-type ${{ inputs.level }}
  72. - name: Publish Crate
  73. id: publish
  74. env:
  75. CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  76. run: |
  77. if [ "${{ inputs.dry_run }}" == "true" ]; then
  78. OPTIONS="--dry-run"
  79. else
  80. OPTIONS=""
  81. fi
  82. pnpm tsx ./scripts/publish.mts ${{ inputs.crate }} ${{ inputs.level }} $OPTIONS
  83. - name: Create GitHub release
  84. if: github.event.inputs.dry_run != 'true' && github.event.inputs.create_release == 'true'
  85. uses: ncipollo/release-action@v1
  86. with:
  87. tag: ${{ steps.publish.outputs.crate }}@v${{ steps.publish.outputs.version }}