Skip to content

Commit

Permalink
Web3App and Web3Wallet for Android done
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Jul 17, 2024
1 parent 17d4e1e commit 58b7a73
Show file tree
Hide file tree
Showing 14 changed files with 573 additions and 18 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/release_dapp_android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Android Web3Dapp deploy

on:
workflow_dispatch:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

jobs:
build:
runs-on: macos-latest-xlarge

steps:
# Checkout the repo
- name: Checkout repository
uses: actions/checkout@v4

# Create temp firebase key
# - name: Create temp firebase key
# env:
# FIREBASE_KEY_BASE64: ${{ secrets.FIREBASE_KEY_BASE64 }}
# run: |
# # create variables
# FIREBASE_KEY_PATH=$RUNNER_TEMP/flutter-c7c2c-6df892fe6ddb.json

# # import certificate and provisioning profile from secrets
# echo -n "$FIREBASE_KEY_BASE64" | base64 --decode -o $FIREBASE_KEY_PATH

# Install Java 17
- name: Install Java 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
architecture: x86_64
cache: 'gradle'

# Cache Gradle
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# # Install Fastlane
# - name: Install Fastlane
# run: gem install fastlane

# Install Flutter and Dependencies
- uses: ./.github/actions/dependencies

# Fastlane
- name: Fastlane
working-directory: example/dapp/android
env:
PROJECT_ID: ${{ secrets.DAPP_PROJECT_ID }}
SLACK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_DAPP_ID: ${{ secrets.FIREBASE_DAPP_ID }}
run: |
PUBSPEC_FILE=../../../pubspec.yaml
FILE_VALUE=$(echo | grep "^version: " $PUBSPEC_FILE)
PARTS=(${FILE_VALUE//:/ })
FULL_VERSION=${PARTS[1]}
VERSION_NUMBER=(${FULL_VERSION//-/ })
fastlane add_plugin firebase_app_distribution
fastlane release_firebase project_id:$PROJECT_ID app_version:$VERSION_NUMBER
# Launch locally
# act -j build --container-architecture linux/amd64 -P macos-latest-xlarge=-self-hosted --secret-file .github/workflows/.env.secret -W .github/workflows/release_dapp_android.yml
75 changes: 75 additions & 0 deletions .github/workflows/release_wallet_android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Android Web3Wallet deploy

on:
workflow_dispatch:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

jobs:
build:
runs-on: macos-latest-xlarge

steps:
# Checkout the repo
- name: Checkout repository
uses: actions/checkout@v4

# Create temp firebase key
# - name: Create temp firebase key
# env:
# FIREBASE_KEY_BASE64: ${{ secrets.FIREBASE_KEY_BASE64 }}
# run: |
# # create variables
# FIREBASE_KEY_PATH=$RUNNER_TEMP/flutter-c7c2c-6df892fe6ddb.json

# # import certificate and provisioning profile from secrets
# echo -n "$FIREBASE_KEY_BASE64" | base64 --decode -o $FIREBASE_KEY_PATH

# Install Java 17
- name: Install Java 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
architecture: x86_64
cache: 'gradle'

# Cache Gradle
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# # Install Fastlane
# - name: Install Fastlane
# run: gem install fastlane

# Install Flutter and Dependencies
- uses: ./.github/actions/dependencies

# Fastlane
- name: Fastlane
working-directory: example/wallet/android
env:
PROJECT_ID: ${{ secrets.WALLET_PROJECT_ID }}
SLACK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_WALLET_ID: ${{ secrets.FIREBASE_WALLET_ID }}
run: |
PUBSPEC_FILE=../../../pubspec.yaml
FILE_VALUE=$(echo | grep "^version: " $PUBSPEC_FILE)
PARTS=(${FILE_VALUE//:/ })
FULL_VERSION=${PARTS[1]}
VERSION_NUMBER=(${FULL_VERSION//-/ })
fastlane add_plugin firebase_app_distribution
fastlane release_firebase project_id:$PROJECT_ID app_version:$VERSION_NUMBER
# Launch locally
# act -j build --container-architecture linux/amd64 -P macos-latest-xlarge=-self-hosted --secret-file .github/workflows/.env.secret -W .github/workflows/release_wallet_android.yml
3 changes: 3 additions & 0 deletions example/dapp/android/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
source "https://rubygems.org"

gem "fastlane"

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
8 changes: 8 additions & 0 deletions example/dapp/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-firebase_app_distribution (0.9.1)
google-apis-firebaseappdistribution_v1 (~> 0.3.0)
google-apis-firebaseappdistribution_v1alpha (~> 0.2.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
Expand All @@ -120,6 +123,10 @@ GEM
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
google-apis-firebaseappdistribution_v1 (0.3.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-firebaseappdistribution_v1alpha (0.2.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
Expand Down Expand Up @@ -215,6 +222,7 @@ PLATFORMS

DEPENDENCIES
fastlane
fastlane-plugin-firebase_app_distribution

BUNDLED WITH
2.5.14
85 changes: 70 additions & 15 deletions example/dapp/android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,78 @@
default_platform(:android)

platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end

desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do
gradle(task: "clean assembleRelease")
crashlytics

# sh "your_script.sh"
# You can also use other beta testing services here
# Helper method to read the changelog
def read_changelog
changelog_file = '../../../../CHANGELOG.md'
changelog = ""

if File.exist?(changelog_file)
File.open(changelog_file, 'r') do |file|
changelog = file.read
end

# Split the changelog into entries based on the version header pattern
entries = changelog.split(/^##\s/)

# Get the latest entry, which is the first one after splitting
latest_entry = entries[1]

# Re-add the '##' header to the latest entry and remove empty lines
changelog = latest_entry.strip if latest_entry
changelog = changelog.gsub /^$\n/, ''
else
UI.user_error!("CHANGELOG.md file not found")
end

changelog
end

desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(task: "clean assembleRelease")
upload_to_play_store

lane :release_firebase do |options|

slack_url = ENV['SLACK_URL']
firebase_token = ENV['FIREBASE_TOKEN']
firebase_dapp_id = ENV['FIREBASE_DAPP_ID']

_latest_release = firebase_app_distribution_get_latest_release(
app: "#{firebase_dapp_id}",
)
_new_build_number = _latest_release[:buildVersion].to_i + 1
_app_version = "#{options[:app_version]}"
_project_id = "#{options[:project_id]}"

# gradle(task: 'assemble', build_type: 'Release')
sh "flutter build apk --build-name #{_app_version} --build-number #{_new_build_number} --dart-define='PROJECT_ID=#{_project_id}' --release"

changelog = read_changelog

firebase_app_distribution(
app: "#{firebase_dapp_id}",
groups: "flutter-team, javascript-team, kotlin-team, rust-team, unity, wc-testers",
android_artifact_path: '../build/app/outputs/flutter-apk/app-release.apk',
release_notes: changelog,
android_artifact_type: "APK",
)

slack(
message: "📱 Web3Dapp Flutter #{_app_version} (#{_new_build_number}) for 🤖 Android successfully released!\n\n",
default_payloads: [],
attachment_properties: {
fields: [
{
title: "CHANGELOG",
value: changelog,
# short: true
},
{
title: "LINK",
value: "https://appdistribution.firebase.dev/i/2c6573f6956fa7b5",
# short: true
},
]
}
)

end
end
5 changes: 5 additions & 0 deletions example/dapp/android/fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-firebase_app_distribution'
2 changes: 1 addition & 1 deletion example/dapp/ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ platform :ios do
)

slack(
message: "📱 Web3Dapp Flutter #{options[:app_version]} (#{new_build_number}) successfully released!\n\n",
message: "📱 Web3Dapp Flutter #{options[:app_version]} (#{new_build_number}) for 🍎 iOS successfully released!\n\n",
default_payloads: [],
attachment_properties: {
fields: [
Expand Down
6 changes: 6 additions & 0 deletions example/wallet/android/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"

gem "fastlane"

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
Loading

0 comments on commit 58b7a73

Please sign in to comment.