publish.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: Publish
  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. steps:
  11. - uses: actions/checkout@v3
  12. with:
  13. fetch-depth: 2
  14. - name: Set up npm token
  15. env:
  16. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  17. run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
  18. - name: Debug Auth
  19. env:
  20. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  21. run: |
  22. npm whoami
  23. - name: Config Git User
  24. run: |
  25. git config --local user.name "chenjiawei.inizio"
  26. git config --local user.email "chenjiawei.inizio@bytedance.com"
  27. - name: Get latest npm version
  28. id: get_version
  29. run: |
  30. LATEST_VERSION=$(npm view @flowgram.ai/core version --tag=latest latest)
  31. echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
  32. echo "::set-output name=version::$LATEST_VERSION"
  33. - name: Echo version
  34. run: |
  35. echo "The package version is : $LATEST_VERSION"
  36. echo "The package output version is ${{ steps.get_version.outputs.version }}"
  37. - uses: actions/setup-node@v3
  38. with:
  39. node-version: 18
  40. registry-url: 'https://registry.npmjs.org/'
  41. - name: Rush Install
  42. run: node common/scripts/install-run-rush.js install
  43. - name: Rush build
  44. run: node common/scripts/install-run-rush.js build
  45. # version bump 之前保证是远端最新的,这样无需 commit package.json version
  46. - name: Sync versions
  47. run: |
  48. echo "[
  49. {
  50. \"policyName\": \"publishPolicy\",
  51. \"definitionName\": \"lockStepVersion\",
  52. \"version\": \"$LATEST_VERSION\",
  53. \"nextBump\": \"patch\"
  54. }
  55. ]" > common/config/rush/version-policies.json
  56. - name: Version Bump
  57. run: node common/scripts/install-run-rush.js version --bump
  58. - name: Publish
  59. env:
  60. NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
  61. run: node common/scripts/install-run-rush.js publish --include-all -p --tag latest