|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' # Official release tags (e.g., v3.1.1) |
| 7 | + |
| 8 | +jobs: |
| 9 | + validate-and-release: |
| 10 | + name: Validate Version and Build Release |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Setup NDK |
| 20 | + |
| 21 | + id: setup-ndk |
| 22 | + with: |
| 23 | + ndk-version: r26d |
| 24 | + link-to-sdk: true |
| 25 | + add-to-path: true |
| 26 | + |
| 27 | + - name: Install Ninja |
| 28 | + run: sudo apt-get update && sudo apt-get install -y ninja-build |
| 29 | + |
| 30 | + - name: Set up JDK 17 |
| 31 | + uses: actions/setup-java@v3 |
| 32 | + with: |
| 33 | + java-version: '17' |
| 34 | + distribution: 'temurin' |
| 35 | + cache: gradle |
| 36 | + |
| 37 | + - name: Grant execute permission for scripts |
| 38 | + run: chmod +x gradlew tasks.sh publish.sh |
| 39 | + |
| 40 | + - name: Extract tag version |
| 41 | + id: tag_version |
| 42 | + run: | |
| 43 | + TAG_NAME="${GITHUB_REF#refs/tags/}" |
| 44 | + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 45 | + |
| 46 | + # Extract version numbers (e.g., v3.1.1 -> 3.1.1) |
| 47 | + if [[ $TAG_NAME =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then |
| 48 | + VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" |
| 49 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 50 | + echo "✅ Valid version tag: $TAG_NAME (version: $VERSION)" |
| 51 | + else |
| 52 | + echo "❌ Invalid tag format: $TAG_NAME" |
| 53 | + echo "Tag must be in format: v\${major}.\${minor}.\${patch} (e.g., v3.1.1)" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | + |
| 57 | + - name: Validate version matches project version |
| 58 | + run: | |
| 59 | + PROJECT_VERSION=$(grep -E '^\s*versionName\s*:' build.gradle | sed -E 's/.*versionName\s*:\s*"([^"]+)".*/\1/') |
| 60 | + TAG_VERSION="${{ steps.tag_version.outputs.version }}" |
| 61 | + |
| 62 | + echo "Project version: $PROJECT_VERSION" |
| 63 | + echo "Tag version: $TAG_VERSION" |
| 64 | + |
| 65 | + if [ "$PROJECT_VERSION" != "$TAG_VERSION" ]; then |
| 66 | + echo "❌ Version mismatch!" |
| 67 | + echo "Tag version ($TAG_VERSION) does not match project version ($PROJECT_VERSION)" |
| 68 | + echo "Please update the versionName in build.gradle to match the tag, or use the correct tag." |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | + |
| 72 | + echo "✅ Version validation passed: $TAG_VERSION" |
| 73 | + |
| 74 | + - name: Setup local.properties for publishing |
| 75 | + run: | |
| 76 | + # Create local.properties with necessary configurations |
| 77 | + mkdir -p /tmp/maven-repo |
| 78 | + cat > local.properties << EOF |
| 79 | + usingCMakeCompile=true |
| 80 | + usingCMakeCompileDebug=false |
| 81 | + deployArtifacts=true |
| 82 | + localRepoDir=/tmp/maven-repo |
| 83 | + EOF |
| 84 | + |
| 85 | + echo "✅ local.properties configured for publishing" |
| 86 | + cat local.properties |
| 87 | + |
| 88 | + - name: Build all artifact variants |
| 89 | + run: | |
| 90 | + echo "🔨 Building all 4 artifact variants..." |
| 91 | + bash -e ./publish.sh |
| 92 | + |
| 93 | + echo "✅ All artifacts built successfully" |
| 94 | + echo "📦 Generated artifacts:" |
| 95 | + find /tmp/maven-repo -type f -name "*.aar" -o -name "*.pom" | sort |
| 96 | + |
| 97 | + - name: Build demo APK with video module |
| 98 | + run: | |
| 99 | + echo "🔨 Building demo APK with video module (default configuration)..." |
| 100 | + ./tasks.sh --enable-cmake --release --enable-video-module --build |
| 101 | + |
| 102 | + # Find and copy the APK |
| 103 | + APK_PATH=$(find "cgeDemo/build" -name "*.apk" | grep -i release | head -1) |
| 104 | + if [ -z "$APK_PATH" ]; then |
| 105 | + echo "❌ APK not found!" |
| 106 | + exit 1 |
| 107 | + fi |
| 108 | + |
| 109 | + mkdir -p /tmp/release-artifacts |
| 110 | + cp "$APK_PATH" /tmp/release-artifacts/cgeDemo-${{ steps.tag_version.outputs.version }}.apk |
| 111 | + |
| 112 | + echo "✅ Demo APK built successfully" |
| 113 | + ls -lh /tmp/release-artifacts/ |
| 114 | + |
| 115 | + - name: Package AAR artifacts |
| 116 | + run: | |
| 117 | + echo "📦 Packaging AAR artifacts..." |
| 118 | + |
| 119 | + VERSION="${{ steps.tag_version.outputs.version }}" |
| 120 | + MAVEN_REPO="/tmp/maven-repo" |
| 121 | + ARTIFACTS_DIR="/tmp/release-artifacts" |
| 122 | + |
| 123 | + # Find all AAR files |
| 124 | + find "$MAVEN_REPO" -name "*.aar" | while read aar_file; do |
| 125 | + # Extract variant info from path |
| 126 | + if [[ $aar_file =~ gpuimage-plus-([0-9.]+(-[^/]+)?)/gpuimage-plus-[0-9.]+(-[^/]+)?\.aar ]]; then |
| 127 | + VARIANT="${BASH_REMATCH[1]}" |
| 128 | + # Normalize variant name for file |
| 129 | + VARIANT_NAME=$(echo "$VARIANT" | sed 's/\./-/g') |
| 130 | + cp "$aar_file" "$ARTIFACTS_DIR/gpuimage-plus-${VARIANT}.aar" |
| 131 | + echo " ✓ Packaged: gpuimage-plus-${VARIANT}.aar" |
| 132 | + fi |
| 133 | + done |
| 134 | + |
| 135 | + echo "✅ All AAR artifacts packaged" |
| 136 | + echo "📦 Final artifacts:" |
| 137 | + ls -lh "$ARTIFACTS_DIR/" |
| 138 | + |
| 139 | + - name: Generate release notes |
| 140 | + id: release_notes |
| 141 | + run: | |
| 142 | + cat > /tmp/release_notes.md << 'EOF' |
| 143 | + ## 🚀 Android GPUImage Plus ${{ steps.tag_version.outputs.tag_name }} |
| 144 | + |
| 145 | + ### 📦 Downloads |
| 146 | + |
| 147 | + **Demo APK:** |
| 148 | + - `cgeDemo-${{ steps.tag_version.outputs.version }}.apk` - Demo application with full video features |
| 149 | + |
| 150 | + **AAR Library Artifacts:** |
| 151 | + |
| 152 | + Four variants are available for different use cases: |
| 153 | + |
| 154 | + 1. **gpuimage-plus-${{ steps.tag_version.outputs.version }}.aar** |
| 155 | + - Page size: 4KB (default) |
| 156 | + - Full-featured with FFmpeg bundled |
| 157 | + - Architectures: armeabi-v7a, arm64-v8a, x86, x86_64 |
| 158 | + |
| 159 | + 2. **gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k.aar** |
| 160 | + - Page size: 16KB |
| 161 | + - Full-featured with FFmpeg bundled |
| 162 | + - Architectures: armeabi-v7a, arm64-v8a, x86, x86_64 |
| 163 | + |
| 164 | + 3. **gpuimage-plus-${{ steps.tag_version.outputs.version }}-min.aar** |
| 165 | + - Page size: 4KB (default) |
| 166 | + - Image-only version (no video features or FFmpeg) |
| 167 | + - Architectures: armeabi-v7a, arm64-v8a, x86, x86_64 |
| 168 | + |
| 169 | + 4. **gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k-min.aar** |
| 170 | + - Page size: 16KB |
| 171 | + - Image-only version (no video features or FFmpeg) |
| 172 | + - Architectures: armeabi-v7a, arm64-v8a, x86, x86_64 |
| 173 | + |
| 174 | + ### 🔧 Gradle Dependency |
| 175 | + |
| 176 | + ```gradle |
| 177 | + allprojects { |
| 178 | + repositories { |
| 179 | + maven { |
| 180 | + url 'https://maven.wysaid.org/' |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + |
| 185 | + dependencies { |
| 186 | + // Choose one of the following based on your needs: |
| 187 | + |
| 188 | + // Full-featured with FFmpeg (4KB page size) |
| 189 | + implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}' |
| 190 | + |
| 191 | + // Full-featured with FFmpeg (16KB page size) |
| 192 | + implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}-16k' |
| 193 | + |
| 194 | + // Image-only, no video (4KB page size) |
| 195 | + implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}-min' |
| 196 | + |
| 197 | + // Image-only, no video (16KB page size) |
| 198 | + implementation 'org.wysaid:gpuimage-plus:${{ steps.tag_version.outputs.version }}-16k-min' |
| 199 | + } |
| 200 | + ``` |
| 201 | + |
| 202 | + ### 📋 System Requirements |
| 203 | + |
| 204 | + - **Minimum Android SDK**: API 21 (Android 5.0) |
| 205 | + - **Target Android SDK**: API 25 |
| 206 | + - **NDK Version**: r26d |
| 207 | + - **Supported Architectures**: armeabi-v7a, arm64-v8a, x86, x86_64 |
| 208 | + |
| 209 | + ### 📚 Documentation |
| 210 | + |
| 211 | + - **GitHub Repository**: https://github.com/wysaid/android-gpuimage-plus |
| 212 | + - **Wiki**: https://github.com/wysaid/android-gpuimage-plus/wiki |
| 213 | + - **Filter Rule Documentation**: https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(EN) |
| 214 | + |
| 215 | + --- |
| 216 | + |
| 217 | + For complete changelog, see the auto-generated content below. |
| 218 | + EOF |
| 219 | + |
| 220 | + echo "✅ Release notes generated" |
| 221 | + |
| 222 | + - name: Create GitHub Release |
| 223 | + uses: softprops/action-gh-release@v2 |
| 224 | + with: |
| 225 | + tag_name: ${{ steps.tag_version.outputs.tag_name }} |
| 226 | + name: Release ${{ steps.tag_version.outputs.tag_name }} |
| 227 | + body_path: /tmp/release_notes.md |
| 228 | + files: | |
| 229 | + /tmp/release-artifacts/*.apk |
| 230 | + /tmp/release-artifacts/*.aar |
| 231 | + draft: false |
| 232 | + prerelease: false |
| 233 | + generate_release_notes: true |
| 234 | + make_latest: true |
| 235 | + env: |
| 236 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 237 | + |
| 238 | + - name: Summary |
| 239 | + run: | |
| 240 | + echo "## 🎉 Release Created Successfully!" >> $GITHUB_STEP_SUMMARY |
| 241 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 242 | + echo "**Release**: ${{ steps.tag_version.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY |
| 243 | + echo "**Version**: ${{ steps.tag_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
| 244 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 245 | + echo "### ✅ Version Validation" >> $GITHUB_STEP_SUMMARY |
| 246 | + echo "- ✅ Tag format validated: v\${major}.\${minor}.\${patch}" >> $GITHUB_STEP_SUMMARY |
| 247 | + echo "- ✅ Version matches project version in build.gradle" >> $GITHUB_STEP_SUMMARY |
| 248 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 249 | + echo "### 📦 Released Artifacts:" >> $GITHUB_STEP_SUMMARY |
| 250 | + echo "**Demo APK:**" >> $GITHUB_STEP_SUMMARY |
| 251 | + echo "- cgeDemo-${{ steps.tag_version.outputs.version }}.apk" >> $GITHUB_STEP_SUMMARY |
| 252 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 253 | + echo "**AAR Libraries:**" >> $GITHUB_STEP_SUMMARY |
| 254 | + echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}.aar (4KB, with video)" >> $GITHUB_STEP_SUMMARY |
| 255 | + echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k.aar (16KB, with video)" >> $GITHUB_STEP_SUMMARY |
| 256 | + echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}-min.aar (4KB, image-only)" >> $GITHUB_STEP_SUMMARY |
| 257 | + echo "- gpuimage-plus-${{ steps.tag_version.outputs.version }}-16k-min.aar (16KB, image-only)" >> $GITHUB_STEP_SUMMARY |
| 258 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 259 | + echo "Release page: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.tag_version.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments