Skip to content

Commit b47d541

Browse files
author
Suyunjing
authored
perf(ci): Optimize release changelog expression (#52)
1 parent 7bdf157 commit b47d541

10 files changed

Lines changed: 75 additions & 178 deletions

File tree

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/bin/bash
22

3-
# 更新pubspec.yaml中的版本号以与OpenList主程序版本同步
4-
# pubspec.yaml使用三段式版本号,Android版本号会自动添加时间戳
5-
63
VERSION_FILE="$GITHUB_WORKSPACE/openlist_version"
74
PUBSPEC_FILE="$GITHUB_WORKSPACE/pubspec.yaml"
85

@@ -16,16 +13,12 @@ if [ ! -f "$PUBSPEC_FILE" ]; then
1613
exit 1
1714
fi
1815

19-
# 读取OpenList版本号
2016
OPENLIST_VERSION=$(cat "$VERSION_FILE")
2117

22-
# 去掉版本号前缀'v'
2318
BASE_VERSION=${OPENLIST_VERSION#v}
2419

2520
echo "Updating pubspec.yaml version to: $BASE_VERSION"
2621

27-
# 使用sed更新pubspec.yaml中的版本号
28-
# 保持build number为+1,只更新版本号部分(三段式)
29-
sed -i "s/^version: [0-9]\+\.[0-9]\+\.[0-9]\++[0-9]\+.*/version: ${BASE_VERSION}+1 # 与OpenList主程序版本同步,Android版本号自动添加时间戳/" "$PUBSPEC_FILE"
22+
sed -i "s/^version: [0-9]\+\.[0-9]\+\.[0-9]\++[0-9]\+.*/version: ${BASE_VERSION}+1/" "$PUBSPEC_FILE"
3023

3124
echo "pubspec.yaml version updated successfully"

.github/workflows/build.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616

1717
jobs:
1818
version:
19+
name: Get OpenList Version Information
1920
runs-on: ubuntu-latest
2021
outputs:
2122
version_name: ${{ steps.generate.outputs.version_name }}
@@ -36,7 +37,6 @@ jobs:
3637
TIMESTAMP=$(date +%y%m%d%H)
3738
VERSION_NAME="${BASE_VERSION}.${TIMESTAMP}"
3839
echo "version_name=${VERSION_NAME}" >> $GITHUB_OUTPUT
39-
echo "Generated version: ${VERSION_NAME}"
4040
4141
- name: Download OpenList Source Code
4242
run: |
@@ -68,13 +68,9 @@ jobs:
6868
echo "openlist_git_commit=${OPENLIST_GIT_COMMIT}" >> $GITHUB_OUTPUT
6969
echo "openlist_web_version=${OPENLIST_WEB_VERSION}" >> $GITHUB_OUTPUT
7070
echo "openlist_built_at=${OPENLIST_BUILT_AT}" >> $GITHUB_OUTPUT
71-
72-
echo "OpenList Backend Version: ${OPENLIST_VERSION}"
73-
echo "OpenList Git Commit: ${OPENLIST_GIT_COMMIT}"
74-
echo "OpenList Web Version: ${OPENLIST_WEB_VERSION}"
75-
echo "Built At: ${OPENLIST_BUILT_AT}"
7671
7772
android:
73+
name: Build OpenList Android APK (Dev)
7874
needs: [version]
7975
runs-on: ubuntu-latest
8076
env:
@@ -151,7 +147,6 @@ jobs:
151147
152148
echo "output_path=$OUTPUT_DIR" >> $GITHUB_ENV
153149
echo "build_type=$BUILD_TYPE" >> $GITHUB_ENV
154-
echo "Using version: ${{ needs.version.outputs.version_name }}"
155150
156151
- name: Upload App To Artifact arm64-v8a
157152
if: success () || failure ()
@@ -181,6 +176,7 @@ jobs:
181176
${{ env.output_path }}/*x64*.apk
182177
183178
ios:
179+
name: Build OpenList iOS App (Dev)
184180
needs: [version]
185181
runs-on: macos-latest
186182
env:
@@ -220,13 +216,11 @@ jobs:
220216
221217
- name: Set iOS Version
222218
run: |
223-
# Use unified version from version job
224219
if [ "${{ github.event_name }}" == "pull_request" ]; then
225220
echo "ver_name=${{ needs.version.outputs.version_name }}-debug" >> $GITHUB_ENV
226221
else
227222
echo "ver_name=${{ needs.version.outputs.version_name }}" >> $GITHUB_ENV
228223
fi
229-
echo "Using iOS version: ${{ needs.version.outputs.version_name }}"
230224
231225
- name: Upload iOS App To Artifact
232226
if: success() || failure()

.github/workflows/build_openlist.yaml

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ permissions:
99

1010
jobs:
1111
version:
12+
name: Get OpenList Version Information
1213
runs-on: ubuntu-latest
1314
outputs:
1415
openlist_version: ${{ steps.openlist_version.outputs.openlist_version }}
@@ -41,13 +42,9 @@ jobs:
4142
echo "openlist_git_commit=${OPENLIST_GIT_COMMIT}" >> $GITHUB_OUTPUT
4243
echo "openlist_web_version=${OPENLIST_WEB_VERSION}" >> $GITHUB_OUTPUT
4344
echo "openlist_built_at=${OPENLIST_BUILT_AT}" >> $GITHUB_OUTPUT
44-
45-
echo "OpenList Backend Version: ${OPENLIST_VERSION}"
46-
echo "OpenList Git Commit: ${OPENLIST_GIT_COMMIT}"
47-
echo "OpenList Web Version: ${OPENLIST_WEB_VERSION}"
48-
echo "Built At: ${OPENLIST_BUILT_AT}"
4945
5046
build_android:
47+
name: Build OpenList Android AAR
5148
needs: [version]
5249
runs-on: ubuntu-latest
5350
steps:
@@ -101,6 +98,7 @@ jobs:
10198
retention-days: 50
10299

103100
build_ios:
101+
name: Build OpenList iOS Framework
104102
needs: [version]
105103
runs-on: macos-latest
106104
steps:
@@ -119,13 +117,6 @@ jobs:
119117
./init_openlist.sh
120118
./init_web_ios.sh
121119
122-
- name: Verify Go Installation
123-
run: |
124-
which go
125-
go version
126-
echo "GOPATH: $GOPATH"
127-
echo "GOROOT: $GOROOT"
128-
129120
- name: Build OpenList iOS Framework
130121
run: |
131122
cd $GITHUB_WORKSPACE/openlist-lib/scripts
@@ -139,27 +130,6 @@ jobs:
139130
OPENLIST_GIT_COMMIT: ${{ needs.version.outputs.openlist_git_commit }}
140131
OPENLIST_GIT_AUTHOR: The OpenList Projects Contributors <noreply@openlist.team>
141132

142-
- name: Verify iOS Framework Generation
143-
run: |
144-
echo "=== Verifying xcframework generation ==="
145-
ls -la $GITHUB_WORKSPACE/ios/Frameworks/ || echo "ios/Frameworks directory not found"
146-
147-
if [ -d "$GITHUB_WORKSPACE/ios/Frameworks" ]; then
148-
FRAMEWORK_COUNT=$(find $GITHUB_WORKSPACE/ios/Frameworks -name "*.xcframework" -type d | wc -l)
149-
echo "Found $FRAMEWORK_COUNT xcframework(s)"
150-
151-
if [ "$FRAMEWORK_COUNT" -eq 0 ]; then
152-
echo "❌ ERROR: No xcframework files found!"
153-
exit 1
154-
else
155-
echo "✅ Found xcframework files:"
156-
find $GITHUB_WORKSPACE/ios/Frameworks -name "*.xcframework" -type d
157-
fi
158-
else
159-
echo "❌ ERROR: ios/Frameworks directory does not exist!"
160-
exit 1
161-
fi
162-
163133
- name: Upload OpenList iOS Framework
164134
uses: actions/upload-artifact@v4
165135
with:

.github/workflows/release.yaml

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
name: Release
22

33
on:
4-
push:
5-
branches:
6-
- "main"
7-
paths:
8-
- "CHANGELOG.md"
94
workflow_dispatch:
105

116
permissions:
127
contents: write
138

149
jobs:
1510
version:
11+
name: Get OpenList Version Information
1612
runs-on: ubuntu-latest
1713
outputs:
1814
version_name: ${{ steps.generate.outputs.version_name }}
@@ -33,7 +29,6 @@ jobs:
3329
TIMESTAMP=$(date +%y%m%d%H)
3430
VERSION_NAME="${BASE_VERSION}.${TIMESTAMP}"
3531
echo "version_name=${VERSION_NAME}" >> $GITHUB_OUTPUT
36-
echo "Generated version: ${VERSION_NAME}"
3732
3833
- name: Download OpenList Source Code
3934
run: |
@@ -65,13 +60,9 @@ jobs:
6560
echo "openlist_git_commit=${OPENLIST_GIT_COMMIT}" >> $GITHUB_OUTPUT
6661
echo "openlist_web_version=${OPENLIST_WEB_VERSION}" >> $GITHUB_OUTPUT
6762
echo "openlist_built_at=${OPENLIST_BUILT_AT}" >> $GITHUB_OUTPUT
68-
69-
echo "OpenList Backend Version: ${OPENLIST_VERSION}"
70-
echo "OpenList Git Commit: ${OPENLIST_GIT_COMMIT}"
71-
echo "OpenList Web Version: ${OPENLIST_WEB_VERSION}"
72-
echo "Built At: ${OPENLIST_BUILT_AT}"
7363
7464
android:
65+
name: Build OpenList Android APK
7566
needs: [version]
7667
runs-on: ubuntu-latest
7768
env:
@@ -132,6 +123,7 @@ jobs:
132123
path: "${{ env.output }}/*.apk"
133124

134125
# ios:
126+
# name: Build OpenList iOS App
135127
# needs: [version]
136128
# runs-on: macos-latest
137129
# env:
@@ -168,25 +160,58 @@ jobs:
168160
# cp -r Runner.app Payload/
169161
# zip -r ${{ env.output }}/OpenList-Mobile.ipa Payload/
170162

171-
# - name: Verify iOS Version Consistency
172-
# run: |
173-
# # Use same version generated by version job
174-
# echo "iOS using version: ${{ needs.version.outputs.version_name }}"
175-
176163
# - name: Upload iOS IPA for Release
177164
# uses: actions/upload-artifact@v4
178165
# with:
179166
# name: "ios-release-files"
180167
# path: "${{ env.output }}/OpenList-Mobile.ipa"
181168

182169
release:
170+
name: Create GitHub Release
183171
needs: [version, android] # Add ios when iOS build is enabled: [version, android, ios]
184172
runs-on: ubuntu-latest
185173
steps:
186174
- uses: actions/checkout@v3
187175
with:
188176
fetch-depth: 0
189177

178+
- name: Setup Node
179+
uses: actions/setup-node@v4
180+
with:
181+
node-version: "22"
182+
183+
- name: Prepare changelog generation
184+
id: prepare_changelog
185+
run: |
186+
git tag -d rolling 2>/dev/null || true
187+
PRE_RELEASE_TAGS=$(git tag -l | grep -E "(-|\+)" || true)
188+
if [ -n "$PRE_RELEASE_TAGS" ]; then
189+
echo "$PRE_RELEASE_TAGS" | xargs -r git tag -d
190+
fi
191+
192+
- name: Generate changelog
193+
id: generate_changelog
194+
run: |
195+
npx changelogithub --output ${{ github.workspace }}/GENERATED_CHANGELOG.txt || echo "" > ${{ github.workspace }}/GENERATED_CHANGELOG.txt
196+
197+
- name: Create final changelog
198+
id: create_changelog
199+
run: |
200+
echo "[Auto Sync OpenList] ${{ needs.version.outputs.openlist_version }}" > ${{ github.workspace }}/FINAL_CHANGELOG.txt
201+
echo "" >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
202+
echo "**OpenList Backend:** ${{ needs.version.outputs.openlist_version }} (${{ needs.version.outputs.openlist_git_commit }})" >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
203+
echo "**OpenList Frontend:** ${{ needs.version.outputs.openlist_web_version }}" >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
204+
echo "**Built at:** ${{ needs.version.outputs.openlist_built_at }}" >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
205+
echo "" >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
206+
echo "---" >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
207+
echo "" >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
208+
209+
if [ -s "${{ github.workspace }}/GENERATED_CHANGELOG.txt" ]; then
210+
cat ${{ github.workspace }}/GENERATED_CHANGELOG.txt >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
211+
else
212+
echo "No changes in this release." >> ${{ github.workspace }}/FINAL_CHANGELOG.txt
213+
fi
214+
190215
- name: Download Android artifacts
191216
uses: actions/download-artifact@v4
192217
with:
@@ -203,7 +228,7 @@ jobs:
203228
with:
204229
name: ${{ needs.version.outputs.version_name }}
205230
tag_name: ${{ needs.version.outputs.version_name }}
206-
body_path: ${{ github.workspace }}/CHANGELOG.md
231+
body_path: ${{ github.workspace }}/FINAL_CHANGELOG.txt
207232
draft: false
208233
prerelease: false
209234
files: release_files/*

.github/workflows/sync_openlist.yaml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
name: Check OpenList Version
1+
name: Check Updates
22

33
on:
44
schedule:
55
- cron: "0 5,17 * * *" # 每日5点和17点执行
66
workflow_dispatch:
7+
inputs:
8+
force_build:
9+
description: 'Force build OpenList libraries'
10+
required: false
11+
type: boolean
12+
default: false
713
push:
814
branches:
915
- "master"
@@ -16,6 +22,7 @@ permissions:
1622

1723
jobs:
1824
check_and_update:
25+
name: Check for version updates
1926
runs-on: ubuntu-latest
2027
outputs:
2128
openlist_update: ${{ steps.set_output.outputs.openlist_update }}
@@ -38,37 +45,45 @@ jobs:
3845
run: |
3946
echo "openlist_version=${{ env.openlist_version }}" >> $GITHUB_OUTPUT
4047
echo "openlist_update=${{ env.openlist_update }}" >> $GITHUB_OUTPUT
41-
echo "OpenList Version: ${{ env.openlist_version }}"
42-
echo "Update Required: ${{ env.openlist_update }}"
48+
49+
- name: Import GPG key
50+
if: env.openlist_update == '1'
51+
uses: crazy-max/ghaction-import-gpg@v6
52+
with:
53+
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
54+
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
55+
git_user_signingkey: true
56+
git_commit_gpgsign: true
57+
git_tag_gpgsign: true
4358

4459
- name: Update Version Files
4560
if: env.openlist_update == '1'
4661
run: |
47-
echo -e "[自动同步OpenList] ${{ env.openlist_version }}\n\n[Auto Sync OpenList] ${{ env.openlist_version }}" > $GITHUB_WORKSPACE/CHANGELOG.md
4862
echo -e "${{ env.openlist_version }}" > ${{ env.VERSION_FILE }}
4963
5064
chmod +x $GITHUB_WORKSPACE/.github/scripts/update_pubspec_version.sh
5165
$GITHUB_WORKSPACE/.github/scripts/update_pubspec_version.sh
5266
53-
git config user.name "github-actions[bot]"
54-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
67+
git config user.name "${{ secrets.BOT_USERNAME }}"
68+
git config user.email "${{ secrets.BOT_USEREMAIL }}"
5569
git add .
5670
git commit -m "[bot] Update openlist to ${{ env.openlist_version }}"
5771
git push
5872
5973
build_openlist_libraries:
74+
name: Build OpenList Libraries
6075
needs: [check_and_update]
61-
if: needs.check_and_update.outputs.openlist_update == '1'
76+
if: needs.check_and_update.outputs.openlist_update == '1' || inputs.force_build == true
6277
uses: ./.github/workflows/build_openlist.yaml
6378

6479
trigger_release:
80+
name: Trigger Release Workflow
6581
needs: [check_and_update, build_openlist_libraries]
6682
if: needs.check_and_update.outputs.openlist_update == '1' && ( success() || failure() )
6783
runs-on: ubuntu-latest
6884
steps:
6985
- name: Trigger Release Workflow
7086
run: |
71-
echo "OpenList libraries built successfully, triggering release workflow..."
72-
gh workflow run release.yaml -R OpenListTeam/OpenList-Mobile
87+
gh workflow run release.yaml -R ${{ github.repository }}
7388
env:
7489
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
migrate_working_dir/
1212
docs/
1313
.github/prompts/
14+
CHANGELOG.md
1415

1516
# IntelliJ related
1617
*.iml

CHANGELOG.md

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

0 commit comments

Comments
 (0)