Skip to content

Commit b50a219

Browse files
authored
ci: new auto release (#4180)
* ci: new auto release * ci: new auto release * chore: update pr template * chore: fix build
1 parent 88d3373 commit b50a219

File tree

6 files changed

+190
-145
lines changed

6 files changed

+190
-145
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,29 @@
3232
从用户角度描述具体变化,以及可能的 breaking change 和其他风险。
3333
-->
3434

35-
- fix(组件名称): 处理问题或特性描述 ...
36-
3735
- [ ] 本条 PR 不需要纳入 Changelog
3836

37+
#### tdesign-miniprogram
38+
<!--
39+
- feat(组件名称): 处理问题或特性描述
40+
-->
41+
42+
43+
44+
#### tdesign-uniapp
45+
<!--
46+
- feat(组件名称): 处理问题或特性描述
47+
-->
48+
49+
50+
51+
#### tdesign-uniapp-chat
52+
<!--
53+
- feat(组件名称): 处理问题或特性描述
54+
-->
55+
56+
57+
3958
### ☑️ 请求合并前的自查清单
4059

4160
⚠️ 请自检并全部**勾选全部选项**。⚠️
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: auto-changelog-callback
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- auto-changelog
7+
types:
8+
- completed
9+
10+
jobs:
11+
commit-changelog:
12+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request_review' }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Download pr id
16+
uses: dawidd6/action-download-artifact@v8
17+
with:
18+
workflow: ${{ github.event.workflow_run.workflow_id }}
19+
run_id: ${{ github.event.workflow_run.id }}
20+
name: pr-id
21+
22+
- name: Output pr id
23+
id: pr
24+
run: echo "id=$(cat pr-id.txt)" >> $GITHUB_OUTPUT
25+
26+
- name: auto-changelog
27+
uses: TDesignOteam/flow-pilot-action@develop
28+
with:
29+
token: ${{ secrets.TDESIGN_BOT_TOKEN }}
30+
packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat'
31+
pr_number: ${{ steps.pr.outputs.id }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: auto-changelog
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
pull_request_review:
8+
types: [submitted]
9+
10+
issue_comment:
11+
types: [edited]
12+
13+
jobs:
14+
changelog:
15+
if: github.event.review.state == 'approved'
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: echo ${{ github.event.pull_request.number }} > pr-id.txt
19+
20+
- uses: actions/upload-artifact@v4
21+
with:
22+
name: pr-id
23+
path: pr-id.txt
24+
retention-days: 5
25+
26+
comment-release-changelog:
27+
if: github.event.pull_request && startsWith(github.head_ref, 'release/')
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: auto-changelog
31+
uses: TDesignOteam/flow-pilot-action@develop
32+
with:
33+
token: ${{ secrets.TDESIGN_BOT_TOKEN }}
34+
packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat'
35+
36+
commit-changelog:
37+
if: github.event.issue.pull_request
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: auto-changelog
41+
uses: TDesignOteam/flow-pilot-action@develop
42+
with:
43+
token: ${{ secrets.TDESIGN_BOT_TOKEN }}
44+
packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat'

.github/workflows/auto-publish.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: auto-publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish-official-website:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v6
12+
with:
13+
ref: main
14+
fetch-depth: 0
15+
submodules: recursive
16+
token: ${{ secrets.TDESIGN_BOT_TOKEN }}
17+
18+
- name: update official website
19+
run: |
20+
git config --local user.email "[email protected]"
21+
git config --local user.name "tdesign-bot"
22+
git status
23+
git fetch origin
24+
git merge origin/develop
25+
git push origin main
26+
27+
publish-miniprogram:
28+
if: startsWith(github.event.release.tag_name,'tdesign-miniprogram')
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v6
32+
with:
33+
submodules: recursive
34+
35+
- uses: pnpm/action-setup@v4
36+
37+
- uses: actions/setup-node@v6
38+
with:
39+
node-version: 18
40+
41+
- run: pnpm install
42+
43+
- run: pnpm build
44+
45+
- name: extract version
46+
id: version
47+
run: |
48+
const tagName = '${{ github.event.release.tag_name }}'
49+
const lastIndex = tagName.lastIndexOf('@');
50+
const version = tagName.slice(lastIndex + 1);
51+
echo "version=$version" >> $GITHUB_OUTPUT
52+
shell: bash
53+
54+
- name: release miniprogram
55+
uses: LeeJim/setup-miniprogram@main
56+
with:
57+
project_type: miniProgram
58+
action_type: upload
59+
project_path: ./_example
60+
version: ${{ steps.version.outputs.version }}
61+
es6: true
62+
es7: true
63+
minify: true
64+
env:
65+
MINI_APP_ID: ${{ secrets.TDESIGN_APP_ID }}
66+
MINI_APP_PRIVATE_KEY: ${{ secrets.TDESIGN_MINI_KEY }}

.github/workflows/auto-release.yml

Lines changed: 28 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,39 @@
1-
name: Auto Release
1+
name: auto-release
22

33
on:
44
pull_request:
5-
branches: [develop]
6-
types: [opened, synchronize, reopened, closed]
7-
paths:
8-
- 'packages/tdesign-miniprogram/package.json'
9-
issue_comment:
10-
types: [edited]
5+
types: [closed]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
1110

1211
jobs:
13-
generator:
12+
publish:
13+
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release/')
1414
runs-on: ubuntu-latest
15-
if: >
16-
github.event_name == 'pull_request' &&
17-
github.event.pull_request.merged == false &&
18-
startsWith(github.head_ref, 'release/')
1915
steps:
20-
- run: echo "The head of this PR starts with 'release/'"
21-
- uses: actions/checkout@v3
22-
- name: Extract version
23-
id: version
24-
run: |
25-
echo "version=$(node -p 'require("./packages/tdesign-miniprogram/package.json").version')" >> $GITHUB_OUTPUT
26-
- uses: TDesignOteam/tdesign-changelog-action@main
27-
id: changelog
16+
- uses: actions/checkout@v4
2817
with:
29-
tag: ${{ steps.version.outputs.version }}
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
- name: Add comment
33-
uses: peter-evans/create-or-update-comment@v1
18+
submodules: recursive
19+
20+
- uses: pnpm/action-setup@v4
21+
22+
- uses: actions/setup-node@v4
3423
with:
35-
issue-number: ${{ github.event.pull_request.number }}
36-
body: |
37-
${{ steps.changelog.outputs.changelog }}
38-
comment_add_log:
39-
runs-on: ubuntu-latest
40-
if: >
41-
github.event_name == 'issue_comment'
42-
&& github.event.issue.pull_request
43-
&& github.event.sender.login == github.event.issue.user.login
44-
&& startsWith(github.event.comment.body, '## 🌈 ')
45-
steps:
46-
- id: comment
47-
shell: bash
48-
run: |
49-
result=$(curl ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}")
50-
headrefreg='"ref": "(release/[[:digit:]]{1,2}\.[[:digit:]]{1,2}\.[[:digit:]]{1,2})",'
51-
if [[ $result =~ $headrefreg ]]
52-
then
53-
echo "属于 release pr 的 comment ${BASH_REMATCH[1]}"
54-
else
55-
echo "不属于 release pr 的 comment" && exit 1
56-
fi
57-
echo "branch=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
58-
# zsh $match[1]
59-
- uses: actions/checkout@v3
24+
node-version: 18
25+
26+
- run: pnpm install
27+
28+
- run: pnpm build
29+
30+
- run: pnpm run uniapp build:npm
31+
32+
- uses: actions/setup-node@v4
6033
with:
61-
ref: ${{ steps.comment.outputs.branch }}
62-
- name: Commit and push if needed
63-
env:
64-
BODY: ${{ github.event.comment.body }}
65-
run: |
66-
txt=$(cat packages/tdesign-miniprogram/CHANGELOG.md)
67-
echo "${txt%%##*}$BODY${txt##*---}" > packages/tdesign-miniprogram/CHANGELOG.md
68-
git add .
69-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
70-
git config --local user.name "github-actions[bot]"
71-
git commit -m "chore: changelog's changes"
72-
git push
73-
echo "💾 pushed changelog's changes"
74-
merge_tag:
75-
runs-on: ubuntu-latest
76-
if: >
77-
github.event_name == 'pull_request' &&
78-
github.event.pull_request.merged == true &&
79-
startsWith(github.head_ref, 'release/')
80-
steps:
81-
- uses: actions/checkout@v3
34+
node-version: 24
35+
36+
- uses: TDesignOteam/flow-pilot-action@develop
8237
with:
83-
ref: develop
84-
token: ${{ secrets.PERSONAL_TOKEN }}
85-
- name: tag and push if needed
86-
run: |
87-
data=$(cat packages/tdesign-miniprogram/package.json)
88-
re="\"version\": \"([^\"]*)\""
89-
[[ $data =~ $re ]]
90-
echo "${BASH_REMATCH[1]}"
91-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
92-
git config --local user.name "github-actions[bot]"
93-
git tag ${BASH_REMATCH[1]}
94-
git push origin ${BASH_REMATCH[1]}
95-
echo "pushed tag ${BASH_REMATCH[1]}"
38+
token: ${{ secrets.TDESIGN_BOT_TOKEN }}
39+
packages: 'tdesign-miniprogram,tdesign-uniapp,tdesign-uniapp-chat'

.github/workflows/tag-push.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)