Skip to content

Publish(both v19 && <v19) #23

Publish(both v19 && <v19)

Publish(both v19 && <v19) #23

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 'semi-team@bytedance.com'
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 'semi-team@bytedance.com'
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 }}
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