-
Notifications
You must be signed in to change notification settings - Fork 294
chore: release package via ci #2982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 34 commits
81e49f6
aee957f
6a63d0f
b1e3750
b6e32ca
3c509e1
4ee850e
c29fcca
123c17e
7b5eb81
59f4a3b
578ad3e
d39c0f6
da96a90
0586197
4c42296
761927b
7bebe36
bbe6ae3
22cbc88
8412fd7
17fbacb
acb8b58
3a7955f
661b7a2
542c53a
e9227b9
8eec51f
6c8a839
38beddf
46cf9e8
959019b
efea6cd
4798d00
3e3b0d9
e4a8d58
0419a9f
d5b1d9d
8f16cea
d387997
27dd1f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 改进提交消息处理的安全性和可靠性 当前的提交消息处理存在以下问题:
- 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 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 |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
改进发布步骤的错误处理和标签使用
发布步骤存在以下问题:
- 使用了硬编码的 beta 标签
- 缺少错误处理机制
- 缺少文件末尾的换行符
- 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.
| - 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)
| 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 | ||
oasis-cloud marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ node_modules | |
| .npmrc | ||
| /dist | ||
| /dist-demo | ||
| /release | ||
| /libs | ||
| /jd/upload.js | ||
| # yarn.lock | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.