Skip to content

Commit 91dea05

Browse files
committed
更新Action文件
1 parent a4bb912 commit 91dea05

File tree

2 files changed

+87
-48
lines changed

2 files changed

+87
-48
lines changed

.github/workflows/build-android-apk.yml

Lines changed: 87 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,17 @@ with open('app/build.gradle.backup', 'r') as f:
122122
content = f.read()
123123

124124
# Add signing configuration before buildTypes
125-
signing_config = """ // Signing configuration added by GitHub Actions
126-
if (project.hasProperty('RELEASE_STORE_FILE')) {
127-
signingConfigs {
128-
release {
129-
storeFile file(RELEASE_STORE_FILE)
130-
storePassword RELEASE_STORE_PASSWORD
131-
keyAlias RELEASE_KEY_ALIAS
132-
keyPassword RELEASE_KEY_PASSWORD
133-
}
134-
}
135-
}
136-
137-
"""
125+
signing_config = " // Signing configuration added by GitHub Actions\n if (project.hasProperty('RELEASE_STORE_FILE')) {\n signingConfigs {\n release {\n storeFile file(RELEASE_STORE_FILE)\n storePassword RELEASE_STORE_PASSWORD\n keyAlias RELEASE_KEY_ALIAS\n keyPassword RELEASE_KEY_PASSWORD\n }\n }\n }\n\n"
138126

139127
# Insert signing config before buildTypes
140-
content = content.replace(' buildTypes {', signing_config + ' buildTypes {')
128+
if ' buildTypes {' in content:
129+
content = content.replace(' buildTypes {', signing_config + ' buildTypes {')
130+
else:
131+
print("Error: Could not find buildTypes section in build.gradle")
132+
exit(1)
141133

142134
# Update release build type to use signing config
143-
old_release = """ release {
144-
minifyEnabled false
145-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
146-
}"""
147-
135+
old_release_pattern = r"(\s+release\s+\{[\s\S]*?minifyEnabled\s+\w+\s*[\s\S]*?proguardFiles\s+.*?[\s\S]*?\})"
148136
new_release = """ release {
149137
minifyEnabled false
150138
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
@@ -153,7 +141,19 @@ new_release = """ release {
153141
}
154142
}"""
155143

156-
content = content.replace(old_release, new_release)
144+
# Try to replace the release build type
145+
if re.search(old_release_pattern, content):
146+
content = re.sub(old_release_pattern, new_release, content)
147+
else:
148+
print("Warning: Could not find release build type to update")
149+
# Try to find and update just the signing config part
150+
if 'release {' in content and 'signingConfig' not in content:
151+
# Add signing config to existing release block
152+
content = re.sub(
153+
r'(\s+release\s+\{[\s\S]*?proguardFiles\s+.*?[\s\S]*?\})',
154+
r'\1\n if (project.hasProperty(\'RELEASE_STORE_FILE\')) {\n signingConfig signingConfigs.release\n }',
155+
content
156+
)
157157

158158
# Write updated content
159159
with open('app/build.gradle', 'w') as f:
@@ -165,6 +165,15 @@ EOF
165165
# Run the script
166166
python3 add_signing.py
167167

168+
# Verify the changes were applied
169+
if grep -q "signingConfigs" app/build.gradle; then
170+
echo "Signing configuration added successfully"
171+
else
172+
echo "Warning: Signing configuration may not have been added correctly"
173+
echo "Checking build.gradle for buildTypes section:"
174+
grep -A 10 "buildTypes" app/build.gradle || echo "buildTypes section not found"
175+
fi
176+
168177
# Clean up
169178
rm add_signing.py
170179
shell: bash
@@ -173,6 +182,21 @@ EOF
173182
run: |
174183
cd android
175184
./gradlew assembleDebug
185+
186+
# Check if debug APK was created
187+
echo "Checking for debug APK..."
188+
ls -la app/build/outputs/apk/debug/
189+
190+
# Verify the debug APK exists
191+
DEBUG_APK="app/build/outputs/apk/debug/app-debug.apk"
192+
if [ -f "$DEBUG_APK" ]; then
193+
echo "Debug APK created successfully: $DEBUG_APK"
194+
else
195+
echo "Error: Debug APK not found at $DEBUG_APK"
196+
echo "Contents of debug directory:"
197+
ls -la app/build/outputs/apk/debug/
198+
exit 1
199+
fi
176200
shell: bash
177201

178202
- name: Build Release APK
@@ -196,14 +220,23 @@ EOF
196220
./gradlew assembleRelease
197221
fi
198222
199-
# Verify the APK was created with the expected name
223+
# Check if APK was created
224+
echo "Checking for release APK..."
225+
ls -la app/build/outputs/apk/release/
226+
227+
# Try to find the APK with expected name or fallback to default
200228
VERSION="${{ steps.version.outputs.version }}"
201229
EXPECTED_APK="app/build/outputs/apk/release/lemon_push_v${VERSION}.apk"
230+
FALLBACK_APK="app/build/outputs/apk/release/app-release.apk"
231+
202232
if [ -f "$EXPECTED_APK" ]; then
203-
echo "Release APK created successfully: $EXPECTED_APK"
233+
echo "Found release APK with expected name: $EXPECTED_APK"
234+
elif [ -f "$FALLBACK_APK" ]; then
235+
echo "Found release APK with default name, renaming to expected name..."
236+
cp "$FALLBACK_APK" "$EXPECTED_APK"
204237
else
205-
echo "Error: Expected release APK not found at $EXPECTED_APK"
206-
echo "Listing release directory contents:"
238+
echo "Error: No release APK found!"
239+
echo "Contents of release directory:"
207240
ls -la app/build/outputs/apk/release/
208241
exit 1
209242
fi
@@ -217,6 +250,19 @@ EOF
217250
# Copy release APK (release builds are renamed by applicationVariants.all)
218251
cp android/app/build/outputs/apk/release/lemon_push_v${{ steps.version.outputs.version }}.apk "release/${{ env.ENGLISH_NAME }}_v${{ steps.version.outputs.version }}_release.apk"
219252
253+
# Verify APKs exist
254+
if [ ! -f "release/${{ env.ENGLISH_NAME }}_v${{ steps.version.outputs.version }}_debug.apk" ]; then
255+
echo "Error: Debug APK not found!"
256+
ls -la android/app/build/outputs/apk/debug/
257+
exit 1
258+
fi
259+
260+
if [ ! -f "release/${{ env.ENGLISH_NAME }}_v${{ steps.version.outputs.version }}_release.apk" ]; then
261+
echo "Error: Release APK not found!"
262+
ls -la android/app/build/outputs/apk/release/
263+
exit 1
264+
fi
265+
220266
# Create checksums
221267
cd release
222268
sha256sum *.apk > checksums.txt
@@ -245,6 +291,23 @@ EOF
245291
name: android-checksums
246292
path: release/checksums.txt
247293
retention-days: 90
294+
295+
- name: Clean up temporary files
296+
if: always()
297+
run: |
298+
cd android
299+
# Clean up keystore if it exists
300+
if [ -f "app/keystore.jks" ]; then
301+
echo "Removing temporary keystore file"
302+
rm app/keystore.jks
303+
fi
304+
305+
# Restore original build.gradle if backup exists
306+
if [ -f "app/build.gradle.backup" ]; then
307+
echo "Restoring original build.gradle"
308+
mv app/build.gradle.backup app/build.gradle
309+
fi
310+
shell: bash
248311

249312
create-release:
250313
needs: build-android

.github/workflows/build.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- os: macos-latest
2727
platform: darwin/arm64
2828
artifact_suffix: darwin_arm64
29-
- os: ubuntu-latest
30-
platform: linux/amd64
31-
artifact_suffix: linux_amd64
3229

3330
runs-on: ${{ matrix.os }}
3431

@@ -51,14 +48,6 @@ jobs:
5148
- name: Install Wails
5249
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
5350

54-
- name: Install Linux system dependencies
55-
if: matrix.os == 'ubuntu-latest'
56-
run: |
57-
sudo apt-get update
58-
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
59-
sudo apt-get install -y libayatana-appindicator3-dev
60-
sudo apt-get install -y libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
61-
6251
- name: Set version from tag or input
6352
run: |
6453
if [[ "${{ github.ref_type }}" == "tag" ]]; then
@@ -107,13 +96,6 @@ jobs:
10796
cp "desktop_gui/build/bin/${{ env.APP_NAME }}" "release/${{ env.ENGLISH_NAME }}_v${{ env.VERSION }}_darwin_arm64"
10897
shell: bash
10998

110-
- name: Prepare artifacts (Linux)
111-
if: matrix.os == 'ubuntu-latest'
112-
run: |
113-
mkdir -p release
114-
cp "desktop_gui/build/bin/${{ env.APP_NAME }}" "release/${{ env.ENGLISH_NAME }}_v${{ env.VERSION }}_linux_amd64"
115-
shell: bash
116-
11799
- name: Create ZIP archive
118100
run: |
119101
cd release
@@ -161,7 +143,6 @@ jobs:
161143
### 下载链接:
162144
- Windows (amd64): lemon_push_gui_v${{ env.VERSION }}_windows_amd64.zip
163145
- macOS (arm64): lemon_push_gui_v${{ env.VERSION }}_darwin_arm64.zip
164-
- Linux (amd64): lemon_push_gui_v${{ env.VERSION }}_linux_amd64.zip
165146
166147
### 安装说明:
167148
#### Windows:
@@ -171,14 +152,9 @@ jobs:
171152
#### macOS:
172153
1. 下载并解压 lemon_push_gui_v${{ env.VERSION }}_darwin_arm64.zip
173154
2. 将 lemon_push_gui_v${{ env.VERSION }}_darwin_arm64 移动到应用程序文件夹
174-
175-
#### Linux:
176-
1. 下载并解压 lemon_push_gui_v${{ env.VERSION }}_linux_amd64.zip
177-
2. 运行 lemon_push_gui_v${{ env.VERSION }}_linux_amd64
178155
files: |
179156
artifacts/windows/amd64/lemon_push_gui_v${{ env.VERSION }}_windows_amd64.zip
180157
artifacts/darwin/arm64/lemon_push_gui_v${{ env.VERSION }}_darwin_arm64.zip
181-
artifacts/linux/amd64/lemon_push_gui_v${{ env.VERSION }}_linux_amd64.zip
182158
draft: false
183159
prerelease: false
184160
env:

0 commit comments

Comments
 (0)