2
0

publish-to-version.yml 2.8 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. echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
  40. - uses: actions/setup-node@v3
  41. with:
  42. node-version: 18
  43. registry-url: "https://registry.npmjs.org/"
  44. - name: Rush Install
  45. run: node common/scripts/install-run-rush.js install
  46. - name: Rush build
  47. run: node common/scripts/install-run-rush.js build
  48. # version bump 之前保证是远端最新的,这样无需 commit package.json version
  49. - name: Sync versions
  50. run: |
  51. echo "[
  52. {
  53. \"policyName\": \"publishPolicy\",
  54. \"definitionName\": \"lockStepVersion\",
  55. \"version\": \"$LATEST_VERSION\"
  56. }
  57. ]" > common/config/rush/version-policies.json
  58. - name: Version Bump
  59. run: node common/scripts/install-run-rush.js version --ensure-version-policy --override-version=$LATEST_VERSION --version-policy publishPolicy
  60. - name: Publish
  61. env:
  62. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  63. run: node common/scripts/install-run-rush.js publish --include-all -p --tag latest
  64. - name: Get new Version
  65. id: get_new_version
  66. run: |
  67. NEW_VERSION=$(npm view @flowgram.ai/core version --tag=latest latest)
  68. echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
  69. - name: Create tag
  70. env:
  71. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  72. run: |
  73. git tag "v$NEW_VERSION"
  74. git push origin "v$NEW_VERSION"