Skip to content

Commit 42c006e

Browse files
ci: add build assets workflow and update release process
1 parent aeddc23 commit 42c006e

6 files changed

Lines changed: 222 additions & 7 deletions

File tree

.github/workflows/build-assets.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: Build Assets
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
upload_to_release:
7+
description: '上传产物到指定 GitHub Release'
8+
required: false
9+
type: boolean
10+
default: false
11+
release_tag:
12+
description: 'Release tag,例如 v1.2.4;仅在上传到 Release 时需要'
13+
required: false
14+
type: string
15+
default: ''
16+
workflow_call:
17+
inputs:
18+
upload_to_release:
19+
required: false
20+
type: boolean
21+
default: false
22+
release_tag:
23+
required: false
24+
type: string
25+
default: ''
26+
27+
permissions:
28+
contents: write
29+
30+
jobs:
31+
build-assets:
32+
name: Build demo assets
33+
runs-on: macOS-latest
34+
env:
35+
ARTIFACT_DIR: release-artifacts
36+
steps:
37+
- name: Check out code
38+
uses: actions/checkout@v4
39+
40+
- name: Validate release upload inputs
41+
if: inputs.upload_to_release
42+
run: |
43+
if [ -z "${{ inputs.release_tag }}" ]; then
44+
echo "release_tag 不能为空,因为 upload_to_release=true" >&2
45+
exit 1
46+
fi
47+
48+
- name: Set up JDK 17
49+
uses: actions/setup-java@v4
50+
with:
51+
distribution: 'zulu'
52+
java-version: 17
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v4
56+
with:
57+
python-version: '3.x'
58+
59+
- name: Set up Node.js
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: '20'
63+
64+
- name: Set up Yarn
65+
run: |
66+
echo "📦 安装 Yarn..."
67+
npm install -g yarn
68+
yarn --version
69+
70+
- name: Set version variables
71+
id: version
72+
run: |
73+
if [ -n "${{ inputs.release_tag }}" ]; then
74+
VERSION="${{ inputs.release_tag }}"
75+
else
76+
VERSION=$(python scripts/read_version.py)
77+
fi
78+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
79+
echo "📦 当前构建版本: $VERSION"
80+
81+
- name: Validate Gradle wrapper
82+
uses: gradle/wrapper-validation-action@v1
83+
84+
- name: Install WASM dependencies
85+
run: |
86+
echo "📦 安装 WASM 构建依赖..."
87+
if [ -f "kotlin-js-store/wasm/yarn.lock" ]; then
88+
cd kotlin-js-store/wasm
89+
yarn install --frozen-lockfile
90+
cd ../..
91+
echo "✅ WASM 依赖安装完成"
92+
else
93+
echo "ℹ️ 未找到 WASM 依赖文件,跳过安装"
94+
fi
95+
96+
- name: Setup Gradle
97+
uses: gradle/gradle-build-action@v2
98+
with:
99+
gradle-home-cache-cleanup: true
100+
101+
- name: Build Android Debug APK
102+
run: ./gradlew :composeApp:assembleDebug --stacktrace
103+
104+
- name: Build Wasm distribution
105+
run: ./gradlew :composeApp:wasmJsBrowserDistribution --stacktrace
106+
107+
- name: Build Desktop DMG
108+
run: ./gradlew :composeApp:packageReleaseDmg --stacktrace
109+
110+
- name: Build iOS simulator app
111+
run: |
112+
xcodebuild \
113+
-project iosApp/iosApp.xcodeproj \
114+
-target iosApp \
115+
-configuration Debug \
116+
-sdk iphonesimulator \
117+
-derivedDataPath build/ios-simulator \
118+
CODE_SIGNING_ALLOWED=NO \
119+
CODE_SIGNING_REQUIRED=NO \
120+
build
121+
122+
- name: Collect release artifacts
123+
run: |
124+
set -euo pipefail
125+
mkdir -p "$ARTIFACT_DIR"
126+
127+
ANDROID_APK=$(find composeApp/build/outputs/apk/debug -name "*.apk" -print -quit)
128+
if [ -z "$ANDROID_APK" ]; then
129+
echo "Android Debug APK 未找到" >&2
130+
exit 1
131+
fi
132+
cp "$ANDROID_APK" "$ARTIFACT_DIR/compose-data-saver-android-debug.apk"
133+
134+
WASM_DIR="composeApp/build/dist/wasmJs/productionExecutable"
135+
if [ ! -d "$WASM_DIR" ]; then
136+
echo "Wasm 产物目录未找到: $WASM_DIR" >&2
137+
exit 1
138+
fi
139+
ditto -c -k --sequesterRsrc --keepParent "$WASM_DIR" "$ARTIFACT_DIR/compose-data-saver-wasm.zip"
140+
141+
DESKTOP_DMG=$(find composeApp/build/compose -name "*.dmg" -print -quit)
142+
if [ -z "$DESKTOP_DMG" ]; then
143+
echo "Desktop DMG 未找到" >&2
144+
exit 1
145+
fi
146+
cp "$DESKTOP_DMG" "$ARTIFACT_DIR/compose-data-saver-desktop-macos.dmg"
147+
148+
IOS_APP="build/ios-simulator/Build/Products/Debug-iphonesimulator/ComposeDataSaver.app"
149+
if [ ! -d "$IOS_APP" ]; then
150+
echo "iOS Simulator App 未找到: $IOS_APP" >&2
151+
exit 1
152+
fi
153+
ditto -c -k --sequesterRsrc --keepParent "$IOS_APP" "$ARTIFACT_DIR/compose-data-saver-ios-simulator-debug.zip"
154+
155+
ls -lah "$ARTIFACT_DIR"
156+
157+
- name: Upload workflow artifacts
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: compose-data-saver-release-assets
161+
path: ${{ env.ARTIFACT_DIR }}/*
162+
if-no-files-found: error
163+
164+
- name: Upload assets to GitHub Release
165+
if: inputs.upload_to_release
166+
uses: softprops/action-gh-release@v2
167+
with:
168+
tag_name: ${{ inputs.release_tag }}
169+
files: ${{ env.ARTIFACT_DIR }}/*
170+
fail_on_unmatched_files: true
171+
overwrite_files: true
172+
173+
- name: Summary
174+
run: |
175+
echo "🎉 产物构建完成!"
176+
echo "📦 版本: ${{ steps.version.outputs.version }}"
177+
echo "📱 Android Debug APK: compose-data-saver-android-debug.apk"
178+
echo "🧩 Wasm: compose-data-saver-wasm.zip"
179+
echo "🖥️ Desktop (macOS): compose-data-saver-desktop-macos.dmg"
180+
echo "📦 iOS Simulator Debug: compose-data-saver-ios-simulator-debug.zip"
181+
if [ "${{ inputs.upload_to_release }}" = "true" ]; then
182+
echo "🔗 Release Tag: ${{ inputs.release_tag }}"
183+
else
184+
echo "🔧 当前为调试构建,产物已上传为 workflow artifact"
185+
fi

.github/workflows/publish.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ on:
1313
type: boolean
1414
default: false
1515

16+
permissions:
17+
contents: write
18+
1619
jobs:
17-
publish:
18-
name: Release build and publish
20+
publish-maven:
21+
name: Publish Maven artifacts
1922
environment: Product
2023
runs-on: macOS-latest
2124
steps:
@@ -128,10 +131,21 @@ jobs:
128131

129132
- name: Summary
130133
run: |
131-
echo "🎉 发布流程完成!"
134+
echo "🎉 Maven 发布流程完成!"
132135
echo "📦 版本: ${{ steps.version.outputs.version }}"
133136
if [ "${{ github.event_name }}" = "release" ]; then
134137
echo "🔗 Release: ${{ github.event.release.html_url }}"
135138
else
136139
echo "🔧 手动运行完成"
137-
fi
140+
fi
141+
142+
build-release-assets:
143+
name: Build release assets
144+
if: github.event_name == 'release'
145+
permissions:
146+
contents: write
147+
uses: ./.github/workflows/build-assets.yml
148+
with:
149+
upload_to_release: true
150+
release_tag: ${{ github.event.release.tag_name }}
151+
secrets: inherit

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ class MyViewModel: ViewModel() {
4646
| --- | --- | --- |
4747
| <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/CN_1.jpg" alt="中文界面预览 1" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/CN_2.jpg" alt="中文界面预览 2" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/CN_3.jpg" alt="中文界面预览 3" width="240" /></a> |
4848

49-
您可以点击 [这里下载demo体验](demo.apk)(Debug 包,相较于 release 包较卡顿)
49+
示例产物下载(始终指向最新正式版 Release):
50+
51+
- [Android Debug APK](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-android-debug.apk)
52+
- [macOS Desktop DMG](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-desktop-macos.dmg)
53+
- [Wasm 打包产物](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-wasm.zip)
54+
- [iOS Simulator Debug 包](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-ios-simulator-debug.zip)
55+
- [Latest Release 页面](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest)
56+
57+
`iOS` 产物为未签名的 Simulator 调试包,适合在模拟器或 Xcode 中验证,不能直接作为真机 `IPA` 安装。
5058

5159
---
5260

README_en.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ Click any screenshot to view the online preview.
4545
| --- | --- | --- |
4646
| <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/EN_1.jpg" alt="English UI Preview 1" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/EN_2.jpg" alt="English UI Preview 2" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/EN_3.jpg" alt="English UI Preview 3" width="240" /></a> |
4747

48-
You can click [here to download the demo for experience](demo.apk) (Debug package, may be slower compared to the release package)
48+
Demo artifacts (always pointing to the latest stable release):
49+
50+
- [Android Debug APK](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-android-debug.apk)
51+
- [macOS Desktop DMG](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-desktop-macos.dmg)
52+
- [Wasm bundle](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-wasm.zip)
53+
- [iOS Simulator Debug bundle](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest/download/compose-data-saver-ios-simulator-debug.zip)
54+
- [Latest Release page](https://github.com/FunnySaltyFish/ComposeDataSaver/releases/latest)
55+
56+
The `iOS` artifact is an unsigned Simulator debug build for simulator/Xcode verification, not a device-installable `IPA`.
4957

5058
---
5159

demo.apk

-7.1 MB
Binary file not shown.

iosApp/iosApp.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
);
152152
runOnlyForDeploymentPostprocessing = 0;
153153
shellPath = /bin/zsh;
154-
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\nsource ~/.zshrc\n./gradlew :composeApp:embedAndSignAppleFrameworkForXcode\n";
154+
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\nif [ -f ~/.zshrc ]; then\n source ~/.zshrc\nfi\n./gradlew :composeApp:embedAndSignAppleFrameworkForXcode\n";
155155
};
156156
/* End PBXShellScriptBuildPhase section */
157157

0 commit comments

Comments
 (0)