cli-release.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. name: CLI release
  2. on:
  3. push:
  4. tags: ['v*']
  5. pull_request:
  6. paths:
  7. - '.github/workflows/cli-release.yml'
  8. - 'scripts/build.mjs'
  9. - 'scripts/*cli-release.mjs'
  10. - 'scripts/release-cli.mjs'
  11. - 'scripts/lib/cli-release.mjs'
  12. - 'scripts/verify.mjs'
  13. - 'test/smoke.test.mjs'
  14. - 'test/byok.test.mjs'
  15. - 'pnpm-lock.yaml'
  16. - 'package.json'
  17. - 'packages/tui/package.json'
  18. workflow_dispatch:
  19. inputs:
  20. tag:
  21. description: 'Optional tag matching the source version (dry run; does not publish)'
  22. required: false
  23. type: string
  24. permissions:
  25. contents: read
  26. concurrency:
  27. group: cli-release-${{ inputs.tag || github.ref }}
  28. cancel-in-progress: false
  29. jobs:
  30. build:
  31. runs-on: ubuntu-latest
  32. timeout-minutes: 25
  33. outputs:
  34. version: ${{ steps.release.outputs.version }}
  35. matrix: ${{ steps.release.outputs.matrix }}
  36. tag: ${{ steps.release.outputs.tag }}
  37. steps:
  38. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  39. with:
  40. fetch-depth: 0
  41. persist-credentials: false
  42. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  43. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  44. with:
  45. node-version: '24'
  46. cache: pnpm
  47. - name: Validate release version and revision
  48. id: release
  49. shell: bash
  50. run: |
  51. node --input-type=module -e 'import { appendFileSync } from "node:fs"; import { cliBuildVersion, cliReleaseTargets } from "./scripts/lib/cli-release.mjs"; const tag = process.env.REQUESTED_TAG || `v${cliBuildVersion(process.cwd())}`; const version = cliBuildVersion(process.cwd(), tag); appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}\ntag=${tag}\nmatrix=${JSON.stringify({include: cliReleaseTargets})}\n`); appendFileSync(process.env.GITHUB_ENV, `MCODE_RELEASE_TAG=${tag}\n`);'
  52. if [ "$EVENT_NAME" = push ]; then
  53. test "$(git rev-parse "refs/tags/$REQUESTED_TAG^{commit}")" = "$(git rev-parse HEAD)"
  54. fi
  55. env:
  56. EVENT_NAME: ${{ github.event_name }}
  57. REQUESTED_TAG: ${{ inputs.tag || (github.event_name == 'push' && github.ref_name) || '' }}
  58. - run: pnpm install --frozen-lockfile
  59. - uses: ./.github/actions/setup-gitleaks
  60. - name: Scan source history
  61. run: gitleaks git --redact --config .gitleaks.toml --log-opts=--all
  62. - run: pnpm verify
  63. env:
  64. MCODE_VERIFY_REPORT_DIR: ${{ runner.temp }}/build-report
  65. - name: Scan distribution
  66. run: gitleaks dir dist --redact --config .gitleaks.toml
  67. - name: Package the tagged CLI
  68. shell: bash
  69. run: node scripts/package-cli-release.mjs "$MCODE_RELEASE_TAG" "$RUNNER_TEMP/package"
  70. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  71. with:
  72. name: cli-package
  73. path: ${{ runner.temp }}/package/
  74. retention-days: 14
  75. if-no-files-found: error
  76. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  77. if: ${{ always() }}
  78. with:
  79. name: cli-build-report
  80. path: ${{ runner.temp }}/build-report/
  81. retention-days: 14
  82. install:
  83. needs: build
  84. env:
  85. MCODE_RELEASE_TAG: ${{ needs.build.outputs.tag }}
  86. runs-on: ${{ matrix.os }}
  87. timeout-minutes: 20
  88. strategy:
  89. fail-fast: false
  90. matrix: ${{ fromJSON(needs.build.outputs.matrix) }}
  91. steps:
  92. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  93. with:
  94. persist-credentials: false
  95. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  96. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  97. with:
  98. node-version: ${{ matrix.node }}
  99. cache: pnpm
  100. - run: pnpm install --frozen-lockfile
  101. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  102. with:
  103. name: cli-package
  104. path: ${{ runner.temp }}/package
  105. - run: pnpm verify --profile package
  106. env:
  107. MCODE_RELEASE_ARCHIVE: ${{ runner.temp }}/package/minimax-code-${{ needs.build.outputs.version }}.tar.gz
  108. MCODE_VERIFY_REPORT_DIR: ${{ runner.temp }}/install-report
  109. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  110. if: ${{ always() }}
  111. with:
  112. name: cli-install-${{ matrix.os }}-${{ matrix.node }}
  113. path: ${{ runner.temp }}/install-report/
  114. retention-days: 14
  115. publish:
  116. needs: [build, install]
  117. if: github.event_name == 'push'
  118. permissions:
  119. contents: write
  120. runs-on: ubuntu-latest
  121. timeout-minutes: 5
  122. env:
  123. MCODE_RELEASE_TAG: ${{ needs.build.outputs.tag }}
  124. steps:
  125. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  126. with:
  127. persist-credentials: false
  128. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  129. with:
  130. node-version: '24'
  131. package-manager-cache: false
  132. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  133. with:
  134. name: cli-package
  135. path: ${{ runner.temp }}/package
  136. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  137. with:
  138. pattern: cli-install-*
  139. path: ${{ runner.temp }}/reports
  140. - name: Publish only the authenticated, validated archive
  141. run: node scripts/publish-cli-release.mjs
  142. env:
  143. GH_TOKEN: ${{ github.token }}
  144. GH_REPO: ${{ github.repository }}
  145. MCODE_RELEASE_DIRECTORY: ${{ runner.temp }}/package
  146. MCODE_RELEASE_REPORTS: ${{ runner.temp }}/reports