Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used flutter distributor instead of fastlane for deployment #126

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
62 changes: 29 additions & 33 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Deploy Android & Web
on:
# Enable manual run
push:
branches:
- 125-use-flutter-distributor-instead-of-fastlane-for-deployment

workflow_dispatch:
inputs:
bump_version:
Expand All @@ -10,7 +13,7 @@ on:
type: string

create_tag_and_push:
description: 'Create new tag & Push bump version'
description: "Create new tag & Push bump version"
required: true
default: true
type: boolean
Expand All @@ -28,24 +31,24 @@ on:

permissions: read-all
jobs:
build_web:
name: Build Flutter (Web)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: flutter pub get
- run: flutter config --enable-web
- run: flutter build web
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting --public web-build
env:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
PROJECT_ID: default
# build_web:
# name: Build Flutter (Web)
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: subosito/flutter-action@v2
# with:
# channel: 'stable'
# - run: flutter pub get
# - run: flutter config --enable-web
# - run: flutter build web
# - name: Deploy to Firebase
# uses: w9jds/firebase-action@master
# with:
# args: deploy --only hosting --public web-build
# env:
# GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
# PROJECT_ID: default

deploy-android:
name: Build & Deploy Android Release to ${{ github.event.inputs.track }} track
Expand All @@ -56,16 +59,10 @@ jobs:
with:
channel: stable
- run: flutter doctor -v
# Checkout Repo code
- name: Checkout Repo
uses: actions/checkout@v3
# Setup Ruby, Bundler, Gemfile & flutter dependencies & Build Android
- name: Setup Fastlane
uses: ruby/setup-ruby@72d59482210349c1114eca714b6c5df19fbbec34
with:
ruby-version: "2.6"
bundler-cache: true
working-directory: android
- name: install flutter distributor
run: dart pub global activate -sgit https://github.com/bixat/flutter_distributor.git --git-path packages/flutter_distributor

- name: Configure Keystore
run: |
Expand All @@ -74,16 +71,15 @@ jobs:
echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> key.properties
echo "storePassword=$KEYSTORE_STORE_PASSWORD" >> key.properties
echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> key.properties
echo "$PLAY_STORE_CONFIG_JSON" >> app/playstore_cer.json
env:
PLAY_STORE_UPLOAD_KEY: ${{ secrets.PLAY_STORE_UPLOAD_KEY }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
PLAY_STORE_CONFIG_JSON: ${{ secrets.PLAY_STORE_CONFIG_JSON }}
working-directory: android

- run: bundle exec fastlane bump_version bump:${{ github.event.inputs.bump_version }} push:${{ github.event.inputs.create_tag_and_push }} branch:${{ github.ref_name }}
working-directory: android
- run: bundle exec fastlane android deploy track:${{ github.event.inputs.track }}
working-directory: android
- run: flutter_distributor release --name dev
env:
PLAY_STORE_CONFIG_JSON: ${{ secrets.PLAY_STORE_CONFIG_JSON }}
PLAYSTORE_CREDENTIALS: "android/app/playstore_cer.json"
16 changes: 16 additions & 0 deletions distribute_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
output: dist/
releases:
- name: dev
jobs:
- name: build-aab
package:
platform: android
target: aab
build_args:
target-platform: android-arm
# Publish to playstore
publish:
target: playstore
args:
package-name: com.flutter.cicd
track: alpha
3 changes: 2 additions & 1 deletion lib/models/photo_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Photo extends RocketModel<Photo> {
});

@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
albumId = json[photoAlbumIdField];
id = json[photoIdField];
title = json[photoTitleField];
Expand Down
3 changes: 2 additions & 1 deletion lib/models/post_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class Post extends RocketModel<Post> {
});

@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
userId = json[postUserIdField];
id = json[postIdField];
title = json[postTitleField];
Expand Down
3 changes: 2 additions & 1 deletion lib/models/todo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Todos extends RocketModel<Todos> {
});

@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
userId = json[todoUserIdField];
id = json[todoIdField];
title = json[todoTitleField];
Expand Down
3 changes: 2 additions & 1 deletion lib/models/todos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Todos extends RocketModel<Todos> {
});

@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
userId = json[todosUserIdField];
id = json[todosIdField];
title = json[todosTitleField];
Expand Down
3 changes: 2 additions & 1 deletion lib/models/user_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class User extends RocketModel<User> {
}

@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
id = json[userIdField];
name = json[userNameField];
username = json[userUsernameField];
Expand Down
3 changes: 2 additions & 1 deletion lib/models/user_submodel/address_submodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Address extends RocketModel<Address> {
}

@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
street = json[addressStreetField];
suite = json[addressSuiteField];
city = json[addressCityField];
Expand Down
3 changes: 2 additions & 1 deletion lib/models/user_submodel/company_submodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Company extends RocketModel<Company> {
});

@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
name = json[companyNameField];
catchPhrase = json[companyCatchPhraseField];
bs = json[companyBsField];
Expand Down
3 changes: 2 additions & 1 deletion lib/models/user_submodel/geo_submodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Geo extends RocketModel<Geo> {
this.lng,
});
@override
void fromJson(Map<String, dynamic> json, {bool isSub = false}) {
void fromJson(Map<String, dynamic>? json, {bool isSub = false}) {
if (json == null) return;
lat = json[geoLatField];
lng = json[geoLngField];
super.fromJson(json, isSub: isSub);
Expand Down
2 changes: 1 addition & 1 deletion lib/views/photo_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PhotoExample extends StatelessWidget {
width: MediaQuery.of(context).size.width,
child: RocketView(
model: photo,
loader: const CircularProgressIndicator(),
onLoading: () => const CircularProgressIndicator(),
// get 5000 items
call: () => GetPhotos.getPhotos(photo),
builder: (context, modelState) {
Expand Down
2 changes: 1 addition & 1 deletion lib/views/post_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PostExample extends StatelessWidget {
// callType: CallType.callAsStream,
// secondsOfStream: 1,
// customized your loading (default widget is CircularProgressIndicator)
loader: const CircularProgressIndicator(),
onLoading: () => const CircularProgressIndicator(),

// handle errors
onError: (RocketException exception, Function() reload) {
Expand Down
2 changes: 1 addition & 1 deletion lib/views/todos_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TodosExample extends StatelessWidget {
body: RocketView(
model: todoModel,
call: () => GetTodos.getTodos(todoModel),
loader: const CircularProgressIndicator(),
onLoading: () => const CircularProgressIndicator(),
callType: CallType.callIfModelEmpty,
builder: (context, state) {
return ListView.builder(
Expand Down
2 changes: 1 addition & 1 deletion lib/views/user_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class UserExample extends StatelessWidget {
// your model
model: users,
// your widget for show data from model
loader: const CircularProgressIndicator(),
onLoading: () => const CircularProgressIndicator(),
builder: (context, modelState) {
return ListView.builder(
itemCount: users.all!.length,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 2.8.0+25
version: 2.8.0+28

environment:
sdk: ">=2.17.6 <3.0.0"
Expand All @@ -30,7 +30,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_rocket: ^0.0.1
flutter_rocket: ^0.0.7


# The following adds the Cupertino Icons font to your application.
Expand Down
11 changes: 7 additions & 4 deletions test/fake_rocket_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ class RocketClientTest extends RocketClient {
this.dummyData,
) : super(url: '');
@override
Future request<T>(String endpoint,
@override
Future<RocketModel> request<T>(String endpoint,
{RocketModel<T>? model,
HttpMethods method = HttpMethods.get,
Function(dynamic data)? inspect,
List<String>? targetData,
RocketDataCallback? inspect,
List<String>? target,
RocketOnError? onError,
Map<String, dynamic>? data,
Map<String, dynamic>? params}) async {
Map<String, dynamic>? params,
RetryOptions retryOptions = const RetryOptions()}) async {
model!.state = RocketState.loading;
await Future.delayed(const Duration(seconds: 1));
try {
Expand Down
Loading