Skip to content

Commit

Permalink
ci: Add Release Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
khaled-0 committed Oct 30, 2024
1 parent e68e006 commit 449cf20
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 6 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
with:
distribution: "zulu"
java-version: "17"
cache: "gradle"
check-latest: true
cache: gradle


- run: flutter --version

Expand All @@ -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
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

*.jks
23 changes: 21 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}
Expand Down

0 comments on commit 449cf20

Please sign in to comment.