Skip to content

Commit 4032fc2

Browse files
committed
Fix PR review comments and add manual workflow trigger support
Fixes: - Fix find command operator precedence with proper parentheses - Fix heredoc delimiter to allow variable interpolation - Add --disable-16kb-page-size flag to demo APK build - Add validation for exactly 4 AAR files Features: - Add workflow_dispatch trigger for manual builds - Manual builds upload artifacts instead of creating releases - Differentiate manual vs tag-triggered builds in logs and summary
1 parent d2ac74d commit 4032fc2

File tree

1 file changed

+129
-43
lines changed

1 file changed

+129
-43
lines changed

.github/workflows/release.yml

Lines changed: 129 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
push:
55
tags:
66
- 'v*.*.*' # Official release tags (e.g., v3.1.1)
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version number (e.g., 3.1.1) - Manual trigger will NOT publish to Release page'
11+
required: true
12+
type: string
713

814
jobs:
915
validate-and-release:
@@ -43,19 +49,39 @@ jobs:
4349
- name: Extract tag version
4450
id: tag_version
4551
run: |
46-
TAG_NAME="${GITHUB_REF#refs/tags/}"
47-
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
48-
49-
# Extract version numbers (e.g., v3.1.1 -> 3.1.1)
50-
if [[ $TAG_NAME =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
51-
VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
52-
echo "version=$VERSION" >> $GITHUB_OUTPUT
53-
echo "✅ Valid version tag: $TAG_NAME (version: $VERSION)"
52+
# Determine if this is a manual trigger or tag push
53+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
54+
# Manual trigger - use input version
55+
VERSION="${{ github.event.inputs.version }}"
56+
TAG_NAME="v$VERSION"
57+
IS_MANUAL="true"
58+
echo "🔧 Manual trigger detected"
5459
else
55-
echo "❌ Invalid tag format: $TAG_NAME"
56-
echo "Tag must be in format: v\${major}.\${minor}.\${patch} (e.g., v3.1.1)"
60+
# Tag push - extract from ref
61+
TAG_NAME="${GITHUB_REF#refs/tags/}"
62+
IS_MANUAL="false"
63+
64+
# Extract version numbers (e.g., v3.1.1 -> 3.1.1)
65+
if [[ $TAG_NAME =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
66+
VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
67+
else
68+
echo "❌ Invalid tag format: $TAG_NAME"
69+
echo "Tag must be in format: v\${major}.\${minor}.\${patch} (e.g., v3.1.1)"
70+
exit 1
71+
fi
72+
fi
73+
74+
# Validate version format
75+
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
76+
echo "❌ Invalid version format: $VERSION"
77+
echo "Version must be in format: \${major}.\${minor}.\${patch} (e.g., 3.1.1)"
5778
exit 1
5879
fi
80+
81+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
82+
echo "version=$VERSION" >> $GITHUB_OUTPUT
83+
echo "is_manual=$IS_MANUAL" >> $GITHUB_OUTPUT
84+
echo "✅ Valid version: $VERSION (tag: $TAG_NAME, manual: $IS_MANUAL)"
5985
6086
- name: Validate version matches project version
6187
run: |
@@ -95,15 +121,15 @@ jobs:
95121
96122
echo "✅ All artifacts built successfully"
97123
echo "📦 Generated artifacts:"
98-
find /tmp/maven-repo -type f -name "*.aar" -o -name "*.pom" | sort
124+
find /tmp/maven-repo -type f \( -name "*.aar" -o -name "*.pom" \) | sort
99125
100126
- name: Build demo APK with video module
101127
run: |
102128
echo "🔨 Building demo APK with video module (default configuration)..."
103-
./tasks.sh --enable-cmake --release --enable-video-module --build
129+
./tasks.sh --enable-cmake --release --enable-video-module --disable-16kb-page-size --build
104130
105131
# Find and copy the APK (look specifically for release build output)
106-
APK_PATH=$(find "cgeDemo/build/outputs/apk/release" -name "*-release.apk" -o -name "*-release-unsigned.apk" | head -1)
132+
APK_PATH=$(find "cgeDemo/build/outputs/apk/release" \( -name "*-release.apk" -o -name "*-release-unsigned.apk" \) | head -1)
107133
if [ -z "$APK_PATH" ]; then
108134
# Fallback: search in build directory
109135
APK_PATH=$(find "cgeDemo/build" -path "*/release/*" -name "*.apk" | head -1)
@@ -139,48 +165,57 @@ jobs:
139165
fi
140166
done < <(find "$MAVEN_REPO/org/wysaid/gpuimage-plus" -name "*.aar")
141167
142-
echo "✅ All AAR artifacts packaged"
168+
# Validate that we have exactly 4 AAR files
169+
AAR_COUNT=$(find "$ARTIFACTS_DIR" -name "*.aar" | wc -l)
170+
if [ "$AAR_COUNT" -ne 4 ]; then
171+
echo "❌ Expected 4 AAR files but found $AAR_COUNT"
172+
exit 1
173+
fi
174+
175+
echo "✅ All AAR artifacts packaged ($AAR_COUNT files)"
143176
echo "📦 Final artifacts:"
144177
ls -lh "$ARTIFACTS_DIR/"
145178
146179
- name: Generate release notes
147180
id: release_notes
148181
run: |
149-
cat > /tmp/release_notes.md << 'EOF'
150-
## 🚀 Android GPUImage Plus ${{ steps.tag_version.outputs.tag_name }}
182+
VERSION="${{ steps.tag_version.outputs.version }}"
183+
TAG_NAME="${{ steps.tag_version.outputs.tag_name }}"
184+
cat > /tmp/release_notes.md << EOF
185+
## 🚀 Android GPUImage Plus $TAG_NAME
151186
152187
### 📦 Downloads
153188
154189
**Demo APK:**
155-
- `cgeDemo-${{ steps.tag_version.outputs.version }}.apk` - Demo application with full video features
190+
- \`cgeDemo-$VERSION.apk\` - Demo application with full video features
156191
157192
**AAR Library Artifacts:**
158193
159194
Four variants are available for different use cases:
160195
161-
1. **gpuimage-plus-${{ steps.tag_version.outputs.version }}.aar**
196+
1. **gpuimage-plus-$VERSION.aar**
162197
- Page size: 4KB (default)
163198
- Full-featured with FFmpeg bundled
164199
- Architectures: armeabi-v7a, arm64-v8a, x86, x86_64
165200
166-
2. **gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k.aar**
201+
2. **gpuimage-plus-$VERSION-16k.aar**
167202
- Page size: 16KB
168203
- Full-featured with FFmpeg bundled
169204
- Architectures: armeabi-v7a, arm64-v8a, x86, x86_64
170205
171-
3. **gpuimage-plus-${{ steps.tag_version.outputs.version }}-min.aar**
206+
3. **gpuimage-plus-$VERSION-min.aar**
172207
- Page size: 4KB (default)
173208
- Image-only version (no video features or FFmpeg)
174209
- Architectures: armeabi-v7a, arm64-v8a, x86, x86_64
175210
176-
4. **gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k-min.aar**
211+
4. **gpuimage-plus-$VERSION-16k-min.aar**
177212
- Page size: 16KB
178213
- Image-only version (no video features or FFmpeg)
179214
- Architectures: armeabi-v7a, arm64-v8a, x86, x86_64
180215
181216
### 🔧 Gradle Dependency
182217
183-
```gradle
218+
\`\`\`gradle
184219
allprojects {
185220
repositories {
186221
maven {
@@ -193,18 +228,18 @@ jobs:
193228
// Choose one of the following based on your needs:
194229
195230
// Full-featured with FFmpeg (4KB page size)
196-
implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}'
231+
implementation 'org.wysaid:gpuimage-plus:$VERSION'
197232
198233
// Full-featured with FFmpeg (16KB page size)
199-
implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}-16k'
234+
implementation 'org.wysaid:gpuimage-plus:$VERSION-16k'
200235
201236
// Image-only, no video (4KB page size)
202-
implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}-min'
237+
implementation 'org.wysaid:gpuimage-plus:$VERSION-min'
203238
204239
// Image-only, no video (16KB page size)
205-
implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}-16k-min'
240+
implementation 'org.wysaid:gpuimage-plus:$VERSION-16k-min'
206241
}
207-
```
242+
\`\`\`
208243
209244
### 📋 System Requirements
210245
@@ -227,6 +262,7 @@ jobs:
227262
echo "✅ Release notes generated"
228263
229264
- name: Create GitHub Release
265+
if: steps.tag_version.outputs.is_manual != 'true'
230266
uses: softprops/action-gh-release@v2
231267
with:
232268
tag_name: ${{ steps.tag_version.outputs.tag_name }}
@@ -242,25 +278,75 @@ jobs:
242278
env:
243279
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244280

281+
- name: Upload artifacts (Manual trigger)
282+
if: steps.tag_version.outputs.is_manual == 'true'
283+
uses: actions/upload-artifact@v4
284+
with:
285+
name: release-artifacts-${{ steps.tag_version.outputs.version }}
286+
path: /tmp/release-artifacts/
287+
retention-days: 7
288+
289+
- name: Manual trigger success message
290+
if: steps.tag_version.outputs.is_manual == 'true'
291+
run: |
292+
echo "🎉 ============================================"
293+
echo "🎉 Manual build completed successfully!"
294+
echo "🎉 ============================================"
295+
echo ""
296+
echo "📦 Version: ${{ steps.tag_version.outputs.version }}"
297+
echo "📦 Artifacts are available for download from the workflow run."
298+
echo ""
299+
echo "⚠️ Note: This is a manual trigger build."
300+
echo "⚠️ Artifacts are NOT published to the Release page."
301+
echo "⚠️ To create an official release, push a tag (e.g., git tag v${{ steps.tag_version.outputs.version }} && git push origin v${{ steps.tag_version.outputs.version }})"
302+
echo ""
303+
echo "📦 Built artifacts:"
304+
ls -lh /tmp/release-artifacts/
305+
245306
- name: Summary
246307
run: |
247-
echo "## 🎉 Release Created Successfully!" >> $GITHUB_STEP_SUMMARY
248-
echo "" >> $GITHUB_STEP_SUMMARY
249-
echo "**Release**: ${{ steps.tag_version.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY
250-
echo "**Version**: ${{ steps.tag_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
251-
echo "" >> $GITHUB_STEP_SUMMARY
252-
echo "### ✅ Version Validation" >> $GITHUB_STEP_SUMMARY
253-
echo "- ✅ Tag format validated: v\${major}.\${minor}.\${patch}" >> $GITHUB_STEP_SUMMARY
254-
echo "- ✅ Version matches project version in build.gradle" >> $GITHUB_STEP_SUMMARY
255-
echo "" >> $GITHUB_STEP_SUMMARY
256-
echo "### 📦 Released Artifacts:" >> $GITHUB_STEP_SUMMARY
308+
IS_MANUAL="${{ steps.tag_version.outputs.is_manual }}"
309+
VERSION="${{ steps.tag_version.outputs.version }}"
310+
TAG_NAME="${{ steps.tag_version.outputs.tag_name }}"
311+
312+
if [ "$IS_MANUAL" = "true" ]; then
313+
echo "## 🔧 Manual Build Completed Successfully!" >> $GITHUB_STEP_SUMMARY
314+
echo "" >> $GITHUB_STEP_SUMMARY
315+
echo "**Version**: $VERSION" >> $GITHUB_STEP_SUMMARY
316+
echo "**Trigger**: Manual (workflow_dispatch)" >> $GITHUB_STEP_SUMMARY
317+
echo "" >> $GITHUB_STEP_SUMMARY
318+
echo "### ⚠️ Note" >> $GITHUB_STEP_SUMMARY
319+
echo "This is a **manual trigger build**. Artifacts are **NOT published** to the Release page." >> $GITHUB_STEP_SUMMARY
320+
echo "" >> $GITHUB_STEP_SUMMARY
321+
echo "To create an official release, push a tag:" >> $GITHUB_STEP_SUMMARY
322+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
323+
echo "git tag v$VERSION && git push origin v$VERSION" >> $GITHUB_STEP_SUMMARY
324+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
325+
echo "" >> $GITHUB_STEP_SUMMARY
326+
echo "### 📦 Built Artifacts (available for download):" >> $GITHUB_STEP_SUMMARY
327+
else
328+
echo "## 🎉 Release Created Successfully!" >> $GITHUB_STEP_SUMMARY
329+
echo "" >> $GITHUB_STEP_SUMMARY
330+
echo "**Release**: $TAG_NAME" >> $GITHUB_STEP_SUMMARY
331+
echo "**Version**: $VERSION" >> $GITHUB_STEP_SUMMARY
332+
echo "" >> $GITHUB_STEP_SUMMARY
333+
echo "### ✅ Version Validation" >> $GITHUB_STEP_SUMMARY
334+
echo "- ✅ Tag format validated: v\${major}.\${minor}.\${patch}" >> $GITHUB_STEP_SUMMARY
335+
echo "- ✅ Version matches project version in build.gradle" >> $GITHUB_STEP_SUMMARY
336+
echo "" >> $GITHUB_STEP_SUMMARY
337+
echo "### 📦 Released Artifacts:" >> $GITHUB_STEP_SUMMARY
338+
fi
339+
257340
echo "**Demo APK:**" >> $GITHUB_STEP_SUMMARY
258-
echo "- cgeDemo-${{ steps.tag_version.outputs.version }}.apk" >> $GITHUB_STEP_SUMMARY
341+
echo "- cgeDemo-$VERSION.apk" >> $GITHUB_STEP_SUMMARY
259342
echo "" >> $GITHUB_STEP_SUMMARY
260343
echo "**AAR Libraries:**" >> $GITHUB_STEP_SUMMARY
261-
echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}.aar (4KB, with video)" >> $GITHUB_STEP_SUMMARY
262-
echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k.aar (16KB, with video)" >> $GITHUB_STEP_SUMMARY
263-
echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}-min.aar (4KB, image-only)" >> $GITHUB_STEP_SUMMARY
264-
echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k-min.aar (16KB, image-only)" >> $GITHUB_STEP_SUMMARY
344+
echo "- gpuimage-plus-$VERSION.aar (4KB, with video)" >> $GITHUB_STEP_SUMMARY
345+
echo "- gpuimage-plus-$VERSION-16k.aar (16KB, with video)" >> $GITHUB_STEP_SUMMARY
346+
echo "- gpuimage-plus-$VERSION-min.aar (4KB, image-only)" >> $GITHUB_STEP_SUMMARY
347+
echo "- gpuimage-plus-$VERSION-16k-min.aar (16KB, image-only)" >> $GITHUB_STEP_SUMMARY
265348
echo "" >> $GITHUB_STEP_SUMMARY
266-
echo "Release page: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.tag_version.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY
349+
350+
if [ "$IS_MANUAL" != "true" ]; then
351+
echo "Release page: ${{ github.server_url }}/${{ github.repository }}/releases/tag/$TAG_NAME" >> $GITHUB_STEP_SUMMARY
352+
fi

0 commit comments

Comments
 (0)