Skip to content

Commit

Permalink
Merge pull request #1 from ahmedsaadx/main
Browse files Browse the repository at this point in the history
test
  • Loading branch information
ahmedsaadx authored Aug 20, 2024
2 parents e6e66d5 + 1c46a59 commit fbe9472
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 3 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/apk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
run-name: Release apk Signing
on:
push:
branches:
- 'dev'
permissions:
contents: write
jobs:
release-signing-build:
if: contains(github.event.head_commit.message, 'apk') || contains(github.event.head_commit.message, 'all')
name: Release Signing Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract Version Code and Version Number
id: extract_version
run: |
# Extract versionCode and versionNumber from commit message
versionCode=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=versionCode=)\d+')
versionNumber=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=versionNumber=)[^\s]+')
echo "VERSION_CODE=$versionCode" >> $GITHUB_ENV
echo "VERSION_NUMBER=$versionNumber" >> $GITHUB_ENV
- name: Update Version in pubspec.yaml
run: |
# Replace the version line with the extracted VERSION_NUMBER and VERSION_CODE
sed -i "s/^version:.*/version: ${VERSION_NUMBER}+${VERSION_CODE}/" pubspec.yaml
grep version: -ri pubspec.yaml
- name: Install GTK and Ninja
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev ninja-build
- uses: gradle/gradle-build-action@v2
- uses: subosito/flutter-action@v1
with:
channel: stable
flutter-version: 3.24
cache: true
- name: Setup JDK 19
uses: actions/setup-java@v3
with:
java-version: '19'
distribution: 'temurin'
cache: gradle

# - name: Setup Android SDK
# uses: android-actions/setup-android@v3


- name: Sign and Build Release Bundle
run: |
flutter clean
flutter pub get
flutter build apk --release
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: true
- name: Upload artefato
uses: actions/upload-artifact@v2
with:
name: appapk
path: build/app/outputs/flutter-apk/app-release.apk
69 changes: 69 additions & 0 deletions .github/workflows/appbundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
run-name: Release appbundle Signing
on:
push:
branches:
- 'dev'
permissions:
contents: write
jobs:
release-signing-build:
#if: contains(github.event.head_commit.message, 'appbundle') || contains(github.event.head_commit.message, 'all')
name: Release Signing Build
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Extract Version Code and Version Number
id: extract_version
run: |
# Extract versionCode and versionNumber from commit message
# versionCode=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=versionCode=)\d+')
# versionNumber=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=versionNumber=)[^\s]+')
echo "VERSION_CODE=1" >> $GITHUB_ENV
echo "VERSION_NUMBER=1.0.0" >> $GITHUB_ENV
- name: Update Version in pubspec.yaml
run: |
# Replace the version line with the extracted VERSION_NUMBER and VERSION_CODE
sed -i "s/^version:.*/version: ${VERSION_NUMBER}+${VERSION_CODE}/" pubspec.yaml
grep version: -ri pubspec.yaml
- name: Install GTK and Ninja
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev ninja-build
- uses: gradle/gradle-build-action@v2
- uses: subosito/flutter-action@v1
with:
channel: stable
flutter-version: 3.24
- name: Setup JDK 19
uses: actions/setup-java@v3
with:
java-version: '19'
distribution: 'temurin'
cache: gradle

# - name: Setup Android SDK
# uses: android-actions/setup-android@v3


- name: Sign and Build Release Bundle
run: |
flutter clean
flutter pub get
flutter build appbundle --release
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: true
- name: Upload artefato
uses: actions/upload-artifact@v2
with:
name: appbundle
path: build/app/outputs/bundle/release/app-release.aab
17 changes: 14 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ plugins {
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
namespace = "com.example.ahmeddev_app"
Expand All @@ -30,11 +35,17 @@ android {
versionName = flutter.versionName
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.debug
signingConfig signingConfigs.release
}
}
}
Expand Down

0 comments on commit fbe9472

Please sign in to comment.