publish-to-version.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. name: Publish To Version
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. sdk-version:
  6. description: '要升级到的 SDK 版本(e.g. 1.0.0)'
  7. required: true
  8. default: ''
  9. concurrency:
  10. group: "main-branch-workflow" # 唯一标识符,确保只运行一个实例
  11. cancel-in-progress: false # 不取消正在运行的实例,后续触发需要等待当前实例完成
  12. jobs:
  13. build:
  14. runs-on: ubuntu-latest
  15. permissions:
  16. contents: write
  17. steps:
  18. - uses: actions/checkout@v3
  19. with:
  20. fetch-depth: 2
  21. - name: Set up npm token
  22. env:
  23. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  24. run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
  25. - name: Debug Auth
  26. env:
  27. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  28. run: |
  29. npm whoami
  30. - name: Config Git User
  31. run: |
  32. git config --local user.name "dragooncjw"
  33. git config --local user.email "289056872@qq.com"
  34. # https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
  35. - name: Echo version
  36. run: |
  37. LATEST_VERSION=${{ github.event.inputs.sdk-version }}
  38. echo "The package input version is ${{ github.event.inputs.sdk-version }}"
  39. - uses: actions/setup-node@v3
  40. with:
  41. node-version: 22
  42. registry-url: 'https://registry.npmjs.org/'
  43. - name: Rush Install
  44. run: node common/scripts/install-run-rush.js install
  45. - name: Rush build
  46. run: node common/scripts/install-run-rush.js build
  47. # version bump 之前保证是远端最新的,这样无需 commit package.json version
  48. - name: Sync versions
  49. run: |
  50. echo "[
  51. {
  52. \"policyName\": \"publishPolicy\",
  53. \"definitionName\": \"lockStepVersion\",
  54. \"version\": \"$LATEST_VERSION\",
  55. }
  56. ]" > common/config/rush/version-policies.json
  57. - name: Version Bump
  58. run: node common/scripts/install-run-rush.js version --bump --version-policy publishPolicy
  59. - name: Publish
  60. env:
  61. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  62. run: node common/scripts/install-run-rush.js publish --include-all -p --tag latest
  63. - name: Get new Version
  64. id: get_new_version
  65. run: |
  66. NEW_VERSION=$(npm view @flowgram.ai/core version --tag=latest latest)
  67. echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
  68. - name: Create tag
  69. env:
  70. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  71. run: |
  72. git tag "v$NEW_VERSION"
  73. git push origin "v$NEW_VERSION"