react-versions.yml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. name: Publish(both v19 && <v19)
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. release_type:
  6. description: 'release type: minor | patch | beta'
  7. required: true
  8. default: 'patch'
  9. publish_react19:
  10. description: 'publish React 19 version'
  11. type: boolean
  12. required: false
  13. default: true
  14. jobs:
  15. # 暂时不加测试
  16. # test-react-18:
  17. # name: Test with React 18
  18. # runs-on: ubuntu-latest
  19. # steps:
  20. # - uses: actions/checkout@v4
  21. # - name: Setup Node.js
  22. # uses: actions/setup-node@v4
  23. # with:
  24. # node-version: '20'
  25. # cache: 'yarn'
  26. # - name: Install dependencies
  27. # run: yarn install --frozen-lockfile
  28. # - name: Run tests with React 18
  29. # run: |
  30. # yarn test
  31. # yarn build
  32. # test-react-19:
  33. # name: Test with React 19
  34. # runs-on: ubuntu-latest
  35. # steps:
  36. # - uses: actions/checkout@v4
  37. # - name: Setup Node.js
  38. # uses: actions/setup-node@v4
  39. # with:
  40. # node-version: '20'
  41. # cache: 'yarn'
  42. # - name: Install dependencies with React 19
  43. # run: |
  44. # yarn install --frozen-lockfile
  45. # # 升级到 React 19 预发布版本
  46. # yarn add react@beta react-dom@beta --dev
  47. # - name: Build React 19 compatible version
  48. # run: |
  49. # node scripts/react19-build.js 19
  50. # - name: Test React 19 version
  51. # run: |
  52. # # 在这里运行适合 React 19 的测试
  53. # echo "Running React 19 specific tests..."
  54. build-and-publish:
  55. name: Build and Publish
  56. runs-on: ubuntu-latest
  57. steps:
  58. - name: gen token
  59. run: |
  60. git config --global user.name 'semi-team'
  61. git config --global user.email '[email protected]'
  62. mkdir ~/.ssh
  63. echo $SEMI_TEAM_PRIVATE_KEY > ~/.ssh/ssh-ed25519
  64. echo $SEMI_TEAM_PRIVATE_KEY_PUB > ~/.ssh/ssh-ed25519.pub
  65. echo "Host\n github.com\n AddKeysToAgent yes\n UseKeychain yes\n IdentityFile ~/.ssh/id_ed25519" > ~/.ssh/config
  66. - uses: actions/checkout@v4
  67. with:
  68. ref: ${{ github.head_ref || github.ref_name }}
  69. - name: Print branch
  70. run: echo "branch=${{ github.head_ref || github.ref_name }}"
  71. - name: Setup Node.js
  72. uses: actions/setup-node@v4
  73. with:
  74. node-version: '20'
  75. cache: 'yarn'
  76. registry-url: 'https://registry.npmjs.org'
  77. # 安装
  78. - name: npm install
  79. run: npm i -g lerna@^4.0.0 && npm run bootstrap
  80. # 生成 semi-ui-19 的包
  81. - name: Build React 19 version
  82. if: ${{ github.event.inputs.publish_react19 }}
  83. run: |
  84. node scripts/react19-build.js 19
  85. echo "Build semi-ui-19";
  86. # 再运行一次,保证 semi-ui-19 中的依赖包安装正确
  87. - name: npm install again
  88. run: npm run bootstrap
  89. - name: get version list
  90. run: |
  91. PKG_NAME=@douyinfe/semi-ui
  92. echo "VERSION_LIST="$(npm view $PKG_NAME versions --json)"" >> $GITHUB_ENV
  93. - name: get version
  94. run: echo "RELEASE_VERSION="$(node scripts/version.js)"" >> $GITHUB_ENV
  95. env:
  96. RELEASE_TYPE: ${{ github.event.inputs.release_type }}
  97. # publish 的时候不提交 semi-ui-19 相关的修改
  98. - name: publish
  99. run: |
  100. git config --global user.name 'semi-team'
  101. git config --global user.email '[email protected]'
  102. node scripts/sitemap_update.js
  103. if [ -n "$(git status --porcelain)" ]; then
  104. echo "there are changes";
  105. git add . ':(exclude)packages/semi-ui-19'
  106. git commit --no-verify -m "chore: publish ${{ env.RELEASE_VERSION }}"
  107. else
  108. echo "no changes";
  109. fi
  110. git add packages/semi-ui-19
  111. git commit --no-verify -m "chore: semi-ui-19-related"
  112. npm config set registry=https://registry.npmjs.org/
  113. npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_NEW }}
  114. npm whoami
  115. DIST_TAG=latest
  116. if [[ ${{ github.event.inputs.release_type }} == 'beta' ]]; then
  117. DIST_TAG=beta
  118. elif [[ ${{ github.event.inputs.release_type }} == 'alpha' ]]; then
  119. DIST_TAG=alpha
  120. fi
  121. echo "$RELEASE_VERSION"
  122. echo "$DIST_TAG"
  123. lerna version $RELEASE_VERSION --exact --force-publish --yes --no-push
  124. lerna publish from-package --dist-tag $DIST_TAG --yes
  125. git tag -d "v${{env.RELEASE_VERSION}}"
  126. git reset HEAD~2
  127. rm -rf packages/semi-ui-19
  128. git add .
  129. git commit --no-verify -m "v${{env.RELEASE_VERSION}}"
  130. git tag "v${{env.RELEASE_VERSION}}"
  131. git tag --list "v${{env.RELEASE_VERSION}}"
  132. git rev-parse "v${{env.RELEASE_VERSION}}"
  133. git push -o ci.skip --follow-tags --no-verify --atomic
  134. git push origin "v${{env.RELEASE_VERSION}}" --no-verify