publish-minor.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. name: Publish-Minor
  2. on:
  3. workflow_dispatch
  4. concurrency:
  5. group: "main-branch-workflow" # 唯一标识符,确保只运行一个实例
  6. cancel-in-progress: false # 不取消正在运行的实例,后续触发需要等待当前实例完成
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: write
  12. steps:
  13. - uses: actions/checkout@v3
  14. with:
  15. fetch-depth: 2
  16. - name: Set up npm token
  17. env:
  18. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  19. run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
  20. - name: Debug Auth
  21. env:
  22. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  23. run: |
  24. npm whoami
  25. - name: Config Git User
  26. run: |
  27. git config --local user.name "dragooncjw"
  28. git config --local user.email "289056872@qq.com"
  29. - name: Get latest npm version
  30. id: get_version
  31. run: |
  32. LATEST_VERSION=$(npm view @flowgram.ai/core version --tag=latest latest)
  33. echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
  34. # https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
  35. - name: Echo version
  36. run: |
  37. echo "The package version is : $LATEST_VERSION"
  38. echo "The package output version is ${{ steps.get_version.outputs.version }}"
  39. - uses: actions/setup-node@v3
  40. with:
  41. node-version: 18
  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. \"nextBump\": \"minor\"
  56. }
  57. ]" > common/config/rush/version-policies.json
  58. - name: Version Bump
  59. run: node common/scripts/install-run-rush.js version --bump --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"