diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6fd5e0b..dd77ebc 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -20,8 +20,8 @@ jobs: with: distribution: "zulu" java-version: "17" - cache: "gradle" - check-latest: true + cache: gradle + - run: flutter --version @@ -37,11 +37,20 @@ jobs: - name: Generate Launcher Icons run: flutter pub run flutter_launcher_icons -f flutter_launcher_icons.yaml - - name: Build Android Release + - name: Decode Release Key + run: | + echo "$TUBESYNC_JKS" > tubesync.b64 + base64 --decode tubesync.b64 > tubesync.jks + env: + TUBESYNC_JKS: ${{ secrets.TUBESYNC_JKS }} + + - name: Build Android Profile Apk run: flutter build apk --profile + env: + TUBESYNC_KEY_PASSWORD: ${{ secrets.TUBESYNC_KEY_PASSWORD }} - name: Upload Build Artifact uses: actions/upload-artifact@v4 with: - name: tubesync_android_${{ github.sha }} + name: tubesync_android_nightly path: build/app/outputs/flutter-apk/app-profile.apk diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d60899f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Create Release + +permissions: write-all + +on: + release: + types: [ published , prereleased ] + workflow_dispatch: + + +jobs: + build-android-apk: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: "17" + cache: gradle + + + - run: flutter --version + + - name: Install dependencies + run: flutter pub get + + - name: Perform Code Generation + run: flutter pub run build_runner build --delete-conflicting-outputs + + - name: Generate SplashScreen + run: flutter pub run flutter_native_splash:create + + - name: Generate Launcher Icons + run: flutter pub run flutter_launcher_icons -f flutter_launcher_icons.yaml + + - name: Decode Release Key + run: | + echo "$TUBESYNC_JKS" > tubesync.b64 + base64 --decode tubesync.b64 > tubesync.jks + env: + TUBESYNC_JKS: ${{ secrets.TUBESYNC_JKS }} + + - name: Build Android Release + run: flutter build apk --release + env: + TUBESYNC_KEY_PASSWORD: ${{ secrets.TUBESYNC_KEY_PASSWORD }} + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: build/app/outputs/flutter-apk/app-release.apk + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: tubesync_android_release + path: build/app/outputs/flutter-apk/app-release.apk + diff --git a/.gitignore b/.gitignore index 29a3a50..1a0ae4b 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +*.jks \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index a0078ad..cbe3f12 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -4,6 +4,11 @@ plugins { id "dev.flutter.flutter-gradle-plugin" } +def process = "git rev-parse --short HEAD".execute() +process.waitFor() +def gitCommitHash = process.in.text.trim() +process.destroy() + android { namespace = "tubesync.app" compileSdk = flutter.compileSdkVersion @@ -28,10 +33,24 @@ android { versionName = flutter.versionName } + signingConfigs { + release { + keyAlias = "tubesync" + keyPassword = System.getenv("TUBESYNC_KEY_PASSWORD") + storeFile = file("../../tubesync.jks") + storePassword = System.getenv("TUBESYNC_KEY_PASSWORD") + } + } + + buildTypes { + profile { + signingConfig = signingConfigs.release + versionNameSuffix = "+" + gitCommitHash + } + release { - // TODO: Add your own signing config for the release build. - signingConfig = signingConfigs.debug + signingConfig = signingConfigs.release } } }