| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- name: Publish(both v19 && <v19)
- on:
- workflow_dispatch:
- inputs:
- release_type:
- description: 'release type: minor | patch | beta'
- required: true
- default: 'patch'
- publish_react19:
- description: 'publish React 19 version'
- type: boolean
- required: false
- default: true
- jobs:
- # 暂时不加测试
- # test-react-18:
- # name: Test with React 18
- # runs-on: ubuntu-latest
- # steps:
- # - uses: actions/checkout@v4
-
- # - name: Setup Node.js
- # uses: actions/setup-node@v4
- # with:
- # node-version: '20'
- # cache: 'yarn'
-
- # - name: Install dependencies
- # run: yarn install --frozen-lockfile
-
- # - name: Run tests with React 18
- # run: |
- # yarn test
- # yarn build
-
- # test-react-19:
- # name: Test with React 19
- # runs-on: ubuntu-latest
-
- # steps:
- # - uses: actions/checkout@v4
-
- # - name: Setup Node.js
- # uses: actions/setup-node@v4
- # with:
- # node-version: '20'
- # cache: 'yarn'
-
- # - name: Install dependencies with React 19
- # run: |
- # yarn install --frozen-lockfile
- # # 升级到 React 19 预发布版本
- # yarn add react@beta react-dom@beta --dev
-
- # - name: Build React 19 compatible version
- # run: |
- # node scripts/react19-build.js 19
-
- # - name: Test React 19 version
- # run: |
- # # 在这里运行适合 React 19 的测试
- # echo "Running React 19 specific tests..."
-
- build-and-publish:
- name: Build and Publish
- runs-on: ubuntu-latest
-
- steps:
- - name: gen token
- run: |
- git config --global user.name 'semi-team'
- git config --global user.email '[email protected]'
- mkdir ~/.ssh
- echo $SEMI_TEAM_PRIVATE_KEY > ~/.ssh/ssh-ed25519
- echo $SEMI_TEAM_PRIVATE_KEY_PUB > ~/.ssh/ssh-ed25519.pub
- echo "Host\n github.com\n AddKeysToAgent yes\n UseKeychain yes\n IdentityFile ~/.ssh/id_ed25519" > ~/.ssh/config
- - uses: actions/checkout@v4
- with:
- ref: ${{ github.head_ref || github.ref_name }}
- - name: Print branch
- run: echo "branch=${{ github.head_ref || github.ref_name }}"
-
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- cache: 'yarn'
- registry-url: 'https://registry.npmjs.org'
- # 安装
- - name: npm install
- run: npm i -g lerna@^4.0.0 && npm run bootstrap
-
- # 生成 semi-ui-19 的包
- - name: Build React 19 version
- if: ${{ github.event.inputs.publish_react19 }}
- run: |
- node scripts/react19-build.js 19
- echo "Build semi-ui-19";
- # 再运行一次,保证 semi-ui-19 中的依赖包安装正确
- - name: npm install again
- run: npm run bootstrap
-
- - name: get version list
- run: |
- PKG_NAME=@douyinfe/semi-ui
- echo "VERSION_LIST="$(npm view $PKG_NAME versions --json)"" >> $GITHUB_ENV
-
- - name: get version
- run: echo "RELEASE_VERSION="$(node scripts/version.js)"" >> $GITHUB_ENV
- env:
- RELEASE_TYPE: ${{ github.event.inputs.release_type }}
- # publish 的时候不提交 semi-ui-19 相关的修改
- - name: publish
- run: |
- git config --global user.name 'semi-team'
- git config --global user.email '[email protected]'
- node scripts/sitemap_update.js
- if [ -n "$(git status --porcelain)" ]; then
- echo "there are changes";
- git add . ':(exclude)packages/semi-ui-19'
- git commit --no-verify -m "chore: publish ${{ env.RELEASE_VERSION }}"
- else
- echo "no changes";
- fi
- git add packages/semi-ui-19
- git commit --no-verify -m "chore: semi-ui-19-related"
- npm config set registry=https://registry.npmjs.org/
- npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_NEW }}
- npm whoami
- DIST_TAG=latest
- if [[ ${{ github.event.inputs.release_type }} == 'beta' ]]; then
- DIST_TAG=beta
- elif [[ ${{ github.event.inputs.release_type }} == 'alpha' ]]; then
- DIST_TAG=alpha
- fi
- echo "$RELEASE_VERSION"
- echo "$DIST_TAG"
- lerna version $RELEASE_VERSION --exact --force-publish --yes --no-push
- lerna publish from-package --dist-tag $DIST_TAG --yes
- git tag -d "v${{env.RELEASE_VERSION}}"
- git reset HEAD~2
- rm -rf packages/semi-ui-19
- git add .
- git commit --no-verify -m "v${{env.RELEASE_VERSION}}"
- git tag "v${{env.RELEASE_VERSION}}"
- git tag --list "v${{env.RELEASE_VERSION}}"
- git rev-parse "v${{env.RELEASE_VERSION}}"
- git push -o ci.skip --follow-tags --no-verify --atomic
- git push origin "v${{env.RELEASE_VERSION}}" --no-verify
|