Skip to content

Commit 9b16d0f

Browse files
Tecvan-fefanwenjie
and
fanwenjie
authored
feat: setup auto publish pipeline (#7)
* feat: setup auto publish pipeline * chore: for test only, should be revert * feat: setup auto publish pipeline * chore: Publish release/20250516-bcd068 (#8) Co-authored-by: fanwenjie <tecvan.fe@gmail.com> * feat: setup auto publish pipeline * chore: for test only, should be revert * chore: for test only, should be revert * chore: for test only, should be revert * feat: setup auto publish pipeline * chore: for test only, should be revert * chore: for test only, should be revert * chore: for test only, should be revert * chore: for test only, should be revert2 * feat: setup auto publish pipeline * feat: setup auto publish pipeline * chore: trigger change * chore: trigger change * chore: trigger change * chore: trigger change * chore: trigger change * chore: Publish release/20250519-c55845 (#9) Co-authored-by: fanwenjie <tecvan.fe@gmail.com> * chore: better logic * chore: Publish release/20250519-472b91 (#10) Co-authored-by: fanwenjie <tecvan.fe@gmail.com> * chore: setup publish * chore: Publish release/20250519-5e5bcd (#11) Co-authored-by: fanwenjie <tecvan.fe@gmail.com> * chore: fix ci --------- Co-authored-by: fanwenjie <tecvan.fe@gmail.com>
1 parent 27894a0 commit 9b16d0f

40 files changed

+658
-199
lines changed

.github/workflows/pr-merged-tag.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Auto Tag on PR Merge
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**/package.json'
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
create-tag:
15+
strategy:
16+
matrix:
17+
include:
18+
- NodeVersion: 20.14.x
19+
NodeVersionDisplayName: 20
20+
OS: ubuntu-latest
21+
name: Node.js v${{ matrix.NodeVersionDisplayName }} (${{ matrix.OS }})
22+
runs-on: ubuntu-latest
23+
if: github.repository == 'coze-dev/rush-arch'
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Config Git User
31+
run: |
32+
git config --local user.name "tecvan"
33+
git config --local user.email "tecvan.fe@gmail.com"
34+
35+
- name: Install jq
36+
run: sudo apt-get install jq
37+
38+
- name: Check Version Change and Create Tag
39+
id: check_version
40+
run: |
41+
# 创建一个JSON数组来保存标签信息
42+
echo "tags_json=[]" >> $GITHUB_OUTPUT
43+
44+
# 标记是否找到变更
45+
HAS_CHANGES=false
46+
47+
# 找出所有修改过的package.json文件
48+
CHANGED_PACKAGES=$(git diff --name-only HEAD^ HEAD | grep package.json)
49+
50+
# 对每个修改的package.json文件检查版本是否变更
51+
for PKG_FILE in $CHANGED_PACKAGES; do
52+
# 获取当前版本
53+
CURRENT_VERSION=$(cat $PKG_FILE | jq -r '.version')
54+
55+
# 获取之前的版本
56+
PREVIOUS_VERSION=$(git show HEAD^:$PKG_FILE 2>/dev/null | jq -r '.version' 2>/dev/null)
57+
58+
# 如果版本发生变化,则创建标签
59+
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
60+
PKG_NAME=$(cat $PKG_FILE | jq -r '.name')
61+
TAG_NAME="v/${PKG_NAME}@${CURRENT_VERSION}"
62+
63+
echo "Version changed for $PKG_NAME: $PREVIOUS_VERSION -> $CURRENT_VERSION"
64+
echo "Creating tag: $TAG_NAME"
65+
66+
git tag -a "$TAG_NAME" -m "Release $PKG_NAME@$CURRENT_VERSION"
67+
68+
# 将此标签添加到输出数组
69+
tags_json=$(echo $tags_json | jq -c --arg tag "$TAG_NAME" '. += [$tag]')
70+
HAS_CHANGES=true
71+
fi
72+
done
73+
74+
# 输出标签JSON和变更状态
75+
echo "tags_json=$tags_json" >> $GITHUB_OUTPUT
76+
echo "has_changes=$HAS_CHANGES" >> $GITHUB_OUTPUT
77+
78+
- uses: actions/setup-node@v3
79+
with:
80+
node-version: ${{ matrix.NodeVersion }}
81+
registry-url: 'https://registry.npmjs.org'
82+
node-version-file: '.nvmrc'
83+
84+
- name: Cache
85+
if: steps.check_version.outputs.has_changes == 'true'
86+
uses: actions/cache@v4
87+
with:
88+
path: |
89+
common/temp/pnpm-local
90+
common/temp/pnpm-store
91+
common/temp/install-run
92+
key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/**/pnpm-lock.yaml') }}
93+
restore-keys: |
94+
${{ runner.os }}-rush-store-main
95+
${{ runner.os }}-rush-store
96+
97+
- name: Install Dependencies
98+
if: steps.check_version.outputs.has_changes == 'true'
99+
run: |
100+
npm i -g @microsoft/rush@5.150.0
101+
sudo apt-get update
102+
sudo apt-get install -y libasound2-dev
103+
node common/scripts/install-run-rush.js install
104+
105+
- name: Run Release
106+
if: steps.check_version.outputs.has_changes == 'true'
107+
run: |
108+
git tag --points-at ${{ github.event.head_commit.id }}
109+
node common/scripts/install-run-rush.js release --commit ${{ github.event.head_commit.id }}
110+
env:
111+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
112+
113+
- name: Push Tags
114+
if: steps.check_version.outputs.has_changes == 'true'
115+
run: |
116+
git push origin --tags

.github/workflows/release.yml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Release Pipeline
22

33
on:
44
push:
5-
branches:
6-
- '**/*'
5+
tags:
6+
- 'v/**'
77

88
jobs:
99
publish:
@@ -21,33 +21,18 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Check Release Tag
25-
id: check_tag
26-
run: |
27-
HAS_VALID_TAG=$(git tag --points-at HEAD | grep -E "^v/.+/.+$" || true)
28-
if [ ! -z "$HAS_VALID_TAG" ]; then
29-
echo "has_valid_tag=true" >> $GITHUB_OUTPUT
30-
echo "Found valid tag: $HAS_VALID_TAG"
31-
else
32-
echo "has_valid_tag=false" >> $GITHUB_OUTPUT
33-
echo "No valid tag found"
34-
fi
35-
3624
- name: Config Git User
37-
if: steps.check_tag.outputs.has_valid_tag == 'true'
3825
run: |
3926
git config --local user.name "tecvan"
4027
git config --local user.email "tecvan.fe@gmail.com"
4128
4229
- uses: actions/setup-node@v3
43-
if: steps.check_tag.outputs.has_valid_tag == 'true'
4430
with:
4531
node-version: ${{ matrix.NodeVersion }}
4632
registry-url: 'https://registry.npmjs.org'
4733
node-version-file: '.nvmrc'
4834

4935
- name: Cache
50-
if: steps.check_tag.outputs.has_valid_tag == 'true'
5136
uses: actions/cache@v4
5237
with:
5338
path: |
@@ -60,15 +45,13 @@ jobs:
6045
${{ runner.os }}-rush-store
6146
6247
- name: Install Dependencies
63-
if: steps.check_tag.outputs.has_valid_tag == 'true'
6448
run: |
6549
npm i -g @microsoft/rush@5.150.0
6650
sudo apt-get update
6751
sudo apt-get install -y libasound2-dev
6852
node common/scripts/install-run-rush.js install
6953
7054
- name: Run Release
71-
if: steps.check_tag.outputs.has_valid_tag == 'true'
7255
run: node common/scripts/install-run-rush.js release --commit ${{ github.event.head_commit.id }}
7356
env:
7457
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,5 @@ packages/chat-sdk/.env.development
173173

174174
opensource_git_commit.log
175175
sensitive_info_result.txt
176+
177+
.rollup.cache

common/autoinstallers/plugins/pnpm-lock.yaml

Lines changed: 27 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)