Build #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| Alpha: | |
| description: 'Alpha' | |
| required: true | |
| default: 'true' | |
| Premium: | |
| description: 'Premium' | |
| required: true | |
| default: 'false' | |
| Foss: | |
| description: 'Foss' | |
| required: true | |
| default: 'false' | |
| release_type: | |
| description: 'Release Type' | |
| required: true | |
| type: choice | |
| options: | |
| - pre-release | |
| - release | |
| default: 'pre-release' | |
| version_name: | |
| description: 'Version Name (e.g., 2.0.13-S3)' | |
| required: false | |
| default: '' | |
| version_code: | |
| description: 'Version Code (e.g., 3501200)' | |
| required: false | |
| default: '' | |
| jobs: | |
| build: | |
| name: "Build APKs" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: s3 | |
| - name: Validate gradle wrapper | |
| uses: gradle/wrapper-validation-action@v1 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: 17 | |
| - name: Setup gradle | |
| uses: gradle/gradle-build-action@v2 | |
| - name: Change to source directory | |
| run: cd source | |
| - name: Setup gradlew | |
| run: chmod +x gradlew | |
| working-directory: source | |
| - name: Check build-logic | |
| run: ./gradlew check -p build-logic | |
| working-directory: source | |
| - name: Get version info | |
| id: version | |
| run: | | |
| if [ -n "${{ github.event.inputs.version_name }}" ]; then | |
| VERSION="${{ github.event.inputs.version_name }}" | |
| else | |
| VERSION=$(grep "versionName" gradle/libs.versions.toml | awk -F'"' '{print $2}') | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| if [ -n "${{ github.event.inputs.version_code }}" ]; then | |
| CODE="${{ github.event.inputs.version_code }}" | |
| else | |
| CODE=$(grep "versionCode" gradle/libs.versions.toml | awk -F'"' '{print $2}') | |
| fi | |
| echo "code=$CODE" >> $GITHUB_OUTPUT | |
| working-directory: source | |
| - name: Build with gradle (Release variants with version override) | |
| id: gradle | |
| env: | |
| BUILD_ALPHA: ${{ github.event.inputs.Alpha }} | |
| BUILD_PREMIUM: ${{ github.event.inputs.Premium }} | |
| BUILD_FOSS: ${{ github.event.inputs.Foss }} | |
| VERSION_NAME: ${{ steps.version.outputs.version }} | |
| VERSION_CODE: ${{ steps.version.outputs.code }} | |
| run: | | |
| echo "Building release variants (without signing)" | |
| echo "Version Name: $VERSION_NAME" | |
| echo "Version Code: $VERSION_CODE" | |
| TASKS="" | |
| if [ "${BUILD_ALPHA}" = 'true' ]; then | |
| TASKS="$TASKS assembleArm64-v8aAlphaRelease assembleArmeabi-v7aAlphaRelease assembleX86AlphaRelease assembleX86_64AlphaRelease" | |
| fi | |
| if [ "${BUILD_PREMIUM}" = 'true' ]; then | |
| TASKS="$TASKS assembleArm64-v8aPremiumRelease assembleArmeabi-v7aPremiumRelease assembleX86PremiumRelease assembleX86_64PremiumRelease" | |
| fi | |
| if [ "${BUILD_FOSS}" = 'true' ]; then | |
| TASKS="$TASKS assembleArm64-v8aFossRelease assembleArmeabi-v7aFossRelease assembleX86FossRelease assembleX86_64FossRelease" | |
| fi | |
| if [ -z "${TASKS}" ]; then | |
| TASKS="assembleRelease" | |
| fi | |
| echo "Running tasks: $TASKS" | |
| # 关键修改:传递版本参数给Gradle | |
| ./gradlew $TASKS -PversionName="$VERSION_NAME" -PversionCode="$VERSION_CODE" --daemon --parallel | |
| working-directory: source | |
| - name: Move and rename APKs | |
| run: | | |
| # 创建输出目录 | |
| mkdir -p ../build-output | |
| # 查找所有release APK文件并复制到build-output | |
| find . -name "*-release.apk" -exec cp {} ../build-output/ \; | |
| # 进入build-output目录进行重命名 | |
| cd ../build-output | |
| # 重命名文件,移除"-release"后缀 | |
| for file in *-release.apk; do | |
| if [ -f "$file" ]; then | |
| new_name=$(echo "$file" | sed 's/-release//g') | |
| mv "$file" "$new_name" | |
| echo "Renamed: $file -> $new_name" | |
| fi | |
| done | |
| echo "Final APK files:" | |
| ls -la | |
| working-directory: source | |
| - name: Upload APKs as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: APKs | |
| path: build-output/*.apk | |
| - name: Create Release | |
| if: github.event.inputs.release_type != '' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: v${{ steps.version.outputs.version }} | |
| prerelease: ${{ github.event.inputs.release_type == 'pre-release' }} | |
| files: build-output/*.apk | |
| body: | | |
| ## What's New in v${{ steps.version.outputs.version }} | |
| ### Version Info | |
| - Version Name: ${{ steps.version.outputs.version }} | |
| - Version Code: ${{ steps.version.outputs.code }} | |
| ### Build Configuration | |
| - Build type: ${{ github.event.inputs.release_type }} | |
| - Alpha: ${{ github.event.inputs.Alpha }} | |
| - Premium: ${{ github.event.inputs.Premium }} | |
| - Foss: ${{ github.event.inputs.Foss }} | |
| - Branch: s3 (S3-specific features) | |
| ### Note | |
| ⚠️ This is an UNSIGNED RELEASE build for testing purposes only. | |
| ### Download | |
| Choose the APK file matching your device architecture: | |
| - arm64-v8a (recommended for most modern devices) | |
| - armeabi-v7a (for older 32-bit ARM devices) | |
| - x86_64 (for x86 64-bit devices) | |
| - x86 (for x86 32-bit devices) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |