Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
81e49f6
chore: release package via ci
oasis-cloud Feb 11, 2025
aee957f
chore: release package via ci
oasis-cloud Feb 11, 2025
6a63d0f
chore: release package via ci
oasis-cloud Feb 11, 2025
b1e3750
chore: release package via ci
oasis-cloud Feb 11, 2025
b6e32ca
chore: release package via ci
oasis-cloud Feb 11, 2025
3c509e1
chore: release package via ci
oasis-cloud Feb 11, 2025
4ee850e
chore: release package via ci
oasis-cloud Feb 11, 2025
c29fcca
chore: release package via ci
oasis-cloud Feb 11, 2025
123c17e
chore: release package via ci
oasis-cloud Feb 11, 2025
7b5eb81
chore: 测试手动执行
oasis-cloud Feb 11, 2025
59f4a3b
chore: 测试手动执行
oasis-cloud Feb 11, 2025
578ad3e
chore: 测试手动执行
oasis-cloud Feb 11, 2025
d39c0f6
chore: 测试手动执行
oasis-cloud Feb 11, 2025
da96a90
chore: 测试手动执行
oasis-cloud Feb 11, 2025
0586197
chore: 测试手动执行
oasis-cloud Feb 11, 2025
4c42296
chore: 测试手动执行
oasis-cloud Feb 11, 2025
761927b
chore: 测试手动执行
oasis-cloud Feb 11, 2025
7bebe36
chore: 测试手动执行
oasis-cloud Feb 11, 2025
bbe6ae3
chore: 测试手动执行
oasis-cloud Feb 11, 2025
22cbc88
chore: 测试beta
oasis-cloud Feb 11, 2025
8412fd7
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
17fbacb
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
acb8b58
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
3a7955f
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
661b7a2
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
542c53a
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
e9227b9
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
8eec51f
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
6c8a839
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
38beddf
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
46cf9e8
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
959019b
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
efea6cd
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
4798d00
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
3e3b0d9
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
e4a8d58
chore(release): v3.0.0-beta.12
oasis-cloud Feb 11, 2025
0419a9f
fix: review
oasis-cloud Feb 13, 2025
d5b1d9d
fix: review
oasis-cloud Feb 13, 2025
8f16cea
chore(release): v3.0.0-beta.12
oasis-cloud Feb 13, 2025
d387997
chore(release): v3.0.0-beta.12
oasis-cloud Feb 13, 2025
27dd1f9
chore: remove --dry-run
oasis-cloud Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/release-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release 3x Beta NPM Packages

on:
push:
branches:
- feat_v3.x
pull_request:
branches:
- feat_v3.x

jobs:
release-beta:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Get commit message
run: |
COMMIT_MESSAGE=$(git log --format=%s -n 1)
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
- name: Show commit message
run: echo "$COMMIT_MESSAGE"

- name: Commit message compliance verification
if: startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) != true && contains( env.COMMIT_MESSAGE , '-beta' ) != true
run: echo "ABORT=true" >> $GITHUB_ENV

- name: Get Tag message
if: contains( env.COMMIT_MESSAGE , '-beta')
run: echo "RELEASE_TAG=beta" >> $GITHUB_ENV

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

改进提交消息处理的安全性和可靠性

当前的提交消息处理存在以下问题:

  1. 直接在环境变量中使用未经过滤的提交消息可能存在安全风险
  2. 条件判断可以更简洁和可靠
 - name: Get commit message
   run: |
-    COMMIT_MESSAGE=$(git log --format=%s -n 1)
-    echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
+    # 使用 shell 参数扩展来过滤特殊字符
+    COMMIT_MESSAGE=$(git log --format=%s -n 1)
+    FILTERED_MESSAGE="${COMMIT_MESSAGE//[^a-zA-Z0-9.()_:, -]/}"
+    echo "COMMIT_MESSAGE=${FILTERED_MESSAGE}" >> $GITHUB_ENV

 - name: Show commit message
   run: echo "$COMMIT_MESSAGE"

 - name: Commit message compliance verification
-  if: startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) != true && contains( env.COMMIT_MESSAGE , '-beta' ) != true
+  if: |
+    !startsWith(env.COMMIT_MESSAGE, 'chore(release):') ||
+    !contains(env.COMMIT_MESSAGE, '-beta')
   run: echo "ABORT=true" >> $GITHUB_ENV
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Get commit message
run: |
COMMIT_MESSAGE=$(git log --format=%s -n 1)
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
- name: Show commit message
run: echo "$COMMIT_MESSAGE"
- name: Commit message compliance verification
if: startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) != true && contains( env.COMMIT_MESSAGE , '-beta' ) != true
run: echo "ABORT=true" >> $GITHUB_ENV
- name: Get Tag message
if: contains( env.COMMIT_MESSAGE , '-beta')
run: echo "RELEASE_TAG=beta" >> $GITHUB_ENV
- name: Get commit message
run: |
# 使用 shell 参数扩展来过滤特殊字符
COMMIT_MESSAGE=$(git log --format=%s -n 1)
FILTERED_MESSAGE="${COMMIT_MESSAGE//[^a-zA-Z0-9.()_:, -]/}"
echo "COMMIT_MESSAGE=${FILTERED_MESSAGE}" >> $GITHUB_ENV
- name: Show commit message
run: echo "$COMMIT_MESSAGE"
- name: Commit message compliance verification
if: |
!startsWith(env.COMMIT_MESSAGE, 'chore(release):') ||
!contains(env.COMMIT_MESSAGE, '-beta')
run: echo "ABORT=true" >> $GITHUB_ENV
- name: Get Tag message
if: contains( env.COMMIT_MESSAGE , '-beta')
run: echo "RELEASE_TAG=beta" >> $GITHUB_ENV

- name: Install pnpm
run: npm install -g pnpm@v9

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- name: Install dependencies
if: env.ABORT != 'true'
run: pnpm install --no-frozen-lockfile

- name: Run Build
if: env.ABORT != 'true'
run: pnpm build && pnpm build:taro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

优化构建命令

当前的构建命令缺少错误处理机制。

 - name: Run Build
   if: env.ABORT != 'true'
-  run: pnpm build && pnpm build:taro
+  run: |
+    if ! pnpm build; then
+      echo "构建 nutui-react 失败"
+      exit 1
+    fi
+    if ! pnpm build:taro; then
+      echo "构建 nutui-react-taro 失败"
+      exit 1
+    fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Run Build
if: env.ABORT != 'true'
run: pnpm build && pnpm build:taro
- name: Run Build
if: env.ABORT != 'true'
run: |
if ! pnpm build; then
echo "构建 nutui-react 失败"
exit 1
fi
if ! pnpm build:taro; then
echo "构建 nutui-react-taro 失败"
exit 1
fi


- name: Run Release @nutui/nutui-react
if: env.ABORT != 'true'
run: cd ./release/h5 && npm publish --dry-run --tag beta

- name: Run Releases @nutui/nutui-react-taro
if: env.ABORT != 'true'
run: cd ./release/taro && npm publish --dry-run --tag beta
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

改进发布步骤的错误处理和标签使用

发布步骤存在以下问题:

  1. 使用了硬编码的 beta 标签
  2. 缺少错误处理机制
  3. 缺少文件末尾的换行符
 - name: Run Release @nutui/nutui-react
   if: env.ABORT != 'true'
-  run: cd ./release/h5 && npm publish --dry-run --tag beta
+  run: |
+    cd ./release/h5 || exit 1
+    if ! npm publish --dry-run --tag ${{ env.RELEASE_TAG }}; then
+      echo "发布 @nutui/nutui-react 失败"
+      exit 1
+    fi

 - name: Run Releases @nutui/nutui-react-taro
   if: env.ABORT != 'true'
-  run: cd ./release/taro && npm publish --dry-run --tag beta
+  run: |
+    cd ./release/taro || exit 1
+    if ! npm publish --dry-run --tag ${{ env.RELEASE_TAG }}; then
+      echo "发布 @nutui/nutui-react-taro 失败"
+      exit 1
+    fi
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Run Release @nutui/nutui-react
if: env.ABORT != 'true'
run: cd ./release/h5 && npm publish --dry-run --tag beta
- name: Run Releases @nutui/nutui-react-taro
if: env.ABORT != 'true'
run: cd ./release/taro && npm publish --dry-run --tag beta
- name: Run Release @nutui/nutui-react
if: env.ABORT != 'true'
run: |
cd ./release/h5 || exit 1
if ! npm publish --dry-run --tag ${{ env.RELEASE_TAG }}; then
echo "发布 @nutui/nutui-react 失败"
exit 1
fi
- name: Run Releases @nutui/nutui-react-taro
if: env.ABORT != 'true'
run: |
cd ./release/taro || exit 1
if ! npm publish --dry-run --tag ${{ env.RELEASE_TAG }}; then
echo "发布 @nutui/nutui-react-taro 失败"
exit 1
fi
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 60-60: no new line character at the end of file

(new-line-at-end-of-file)

36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release NPM Packages

on:
push:
tags:
- v3.*
workflow_dispatch:

jobs:
release:
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_CONFIG_PROVENANCE: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm install -g pnpm@v9

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Run Build
run: pnpm build & pnpm build:taro

- name: Run Release @nutui/nutui-react
run: cd ./release/h5 && npm publish

- name: Run Releases @nutui/nutui-react-taro
run: cd ./release/taro && npm publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
.npmrc
/dist
/dist-demo
/release
/libs
/jd/upload.js
# yarn.lock
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/jdf2e/nutui-react.git"
"url": "git+https://github.com/jdf2e/nutui-react.git"
},
"files": [
"dist",
Expand Down Expand Up @@ -77,9 +77,7 @@
"generate:file:taro:pages": "node scripts/taro/generate-taro-pages.js",
"lint": "eslint ./src/packages/*/",
"lint:fix": "eslint --fix ./src/packages",
"postpublish": "node scripts/postpublish.js",
"prepare": "husky && npm run generate:file && npm run generate:file:taro && npm run generate:file:taro:pages",
"prepublishOnly": "node scripts/prepublish.js",
"publish:beta": "npm publish --tag beta",
"test": "vitest --coverage",
"test:ui": "vitest --ui --coverage",
Expand Down
9 changes: 5 additions & 4 deletions scripts/build-comments-to-dts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { dirname } from 'path'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const dist = 'release/h5/dist'

/**
* 通过 cofnig.json 获取所有组件的数据
Expand Down Expand Up @@ -135,15 +136,15 @@ function addComments(dtsPath, propsTable, componentName) {
}
}

function getDtsPath(key) {
function getDtsPath(key, outDir) {
// Tabs.Tabpane -> tabpane
let name
if (key === 'Tabs.Tabpane') {
name = 'tabpane'
} else {
name = key.toLowerCase().replace('.', '')
}
const file = path.join(__dirname, '../dist/es/packages', name, name + '.d.ts')
const file = path.join(__dirname, `../${outDir}/es/packages`, name, name + '.d.ts')
return file
}

Expand All @@ -170,14 +171,14 @@ export function codeShift(env) {
__dirname,
'../src/packages',
name.toLowerCase(),
env === 'Taro' ? 'doc.taro.md' : 'doc.md'
env === 'taro' ? 'doc.taro.md' : 'doc.md'
)
if (fse.pathExistsSync(componentDocumentPath)) {
const tables = extractPropsTable(
readComponentDocument(componentDocumentPath)
)
Object.keys(tables).forEach((key) => {
const dtsPath = getDtsPath(key)
const dtsPath = getDtsPath(key, env !== 'taro' ? dist : dist.replace('h5', env))
if (fse.pathExistsSync(dtsPath)) {
const table = markdownTable2Json(tables[key])
addComments(dtsPath, table, getComponentName(key))
Expand Down
Loading
Loading