Browse Source

Added github workflow

pull/1/head
Daven Casia 1 year ago
parent
commit
d1cf14e157
  1. 51
      .github/workflows/shipit.yml
  2. 2
      .gitignore
  3. 3
      android/.gitignore
  4. 4
      android/app/build.gradle
  5. 41
      android/fastlane/Fastfile
  6. 16
      android/fastlane/README.md
  7. 3
      lib/api.dart
  8. 2
      lib/common_widgets.dart
  9. 8
      lib/main.dart
  10. 2
      lib/screens/auth_widget.dart
  11. 5
      lib/viewmodels.dart
  12. 6
      pubspec.yaml
  13. 37
      scripts/setenv.sh
  14. 2
      test/widget_test.dart

51
.github/workflows/shipit.yml

@ -0,0 +1,51 @@
name: shipit
on:
push:
branches:
- "master"
- "actions/release_android__*"
paths:
- "goryon/pubspec.yaml"
- "goryon/android/fastlane/**/*"
- "goryon/android/fastlane/Fastfile"
- ".github/workflows/shipit.yml"
- "goryon/android/Gemfile"
- "goryon/android/Gemfile.lock"
jobs:
release-android:
name: release android app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.x'
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.12.13+hotfix.5'
channel: 'stable'
- name: upgrade flutter
run: |
flutter channel dev
flutter upgrade
- name: install gem packages
run: |
cd goryon/android
gem install bundler:1.17.3
bundle install
bundle exec fastlane install_plugins
bundle exec fastlane update_plugins
- name: build apk and app bundle package
env:
ANDROID_SIGN_PWD: ${{ secrets.ANDROID_SIGN_PWD }}
ANDROID_KEY_STORE_PWD: ${{ secrets.ANDROID_KEY_STORE_PWD }}
RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }}
RELEASE_KEYSTORE_PASSPHRASE: ${{ secrets.RELEASE_KEYSTORE_PASSPHRASE }}
RELEASE_SERVICE_ACCOUNT_KEYSTORE: ${{ secrets.RELEASE_SERVICE_ACCOUNT_KEYSTORE }}
run: |
./scripts/setenv.sh
flutter pub get
flutter build appbundle

2
.gitignore

@ -44,8 +44,8 @@ app.*.map.json
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
# Deploy keys
keys/
goryon-secrets/
# Fastlane files
android/fastlane/report.xml

3
android/.gitignore

@ -8,4 +8,5 @@ GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
/key.properties
/key.jks

4
android/app/build.gradle

@ -9,7 +9,7 @@ if (localPropertiesFile.exists()) {
def flutterRoot = localProperties.getProperty('flutter.sdk')
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('../keys/android/key.properties')
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.withReader('UTF-8') { reader ->
keystoreProperties.load(reader)
@ -57,7 +57,7 @@ android {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile rootProject.file('../keys/android/upload-keystore.jks')
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}

41
android/fastlane/Fastfile

@ -20,15 +20,40 @@ platform :android do
version_info = flutter_version()
version_code = version_info["version_code"]
desc "Deploy a new version to the Google Play to Alpha track"
lane :deploy_alpha do
desc "Submit to internal track in Google Play Store"
lane :internal do
sh("flutter", "build", "appbundle")
upload_to_play_store(
track: 'alpha',
version_code: version_code,
track_promote_to: 'production',
skip_upload_screenshots: true,
skip_upload_images: true
)
track: 'internal',
aab: '../build/app/outputs/bundle/release/app-release.aab',
skip_upload_screenshots: true,
skip_upload_images: true
)
end
desc "promote to alpha track in Google Play Store"
lane :alpha do
sh("flutter", "build", "appbundle")
upload_to_play_store(
track: 'internal',
version_code: flutter_version(),
track_promote_to: 'alpha',
skip_upload_aab: true,
skip_upload_screenshots: true,
skip_upload_images: true
)
end
desc "promote to production track in Google Play Store"
lane :production do
sh("flutter", "build", "appbundle")
upload_to_play_store(
track: 'alpha',
version_code: flutter_version(),
track_promote_to: 'production',
skip_upload_aab: true,
skip_upload_screenshots: true,
skip_upload_images: true
)
end
end

16
android/fastlane/README.md

@ -16,13 +16,23 @@ or alternatively using `brew install fastlane`
# Available Actions
## Android
### android deploy_alpha
### android internal
```
fastlane android deploy_alpha
fastlane android internal
```
Runs all the tests
Deploy a new version to the Google Play to Alpha track
Submit to internal track in Google Play Store
### android alpha
```
fastlane android alpha
```
promote to alpha track in Google Play Store
### android production
```
fastlane android production
```
promote to production track in Google Play Store
----

3
lib/api.dart

@ -2,9 +2,10 @@ import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:twtxt_flutter/models.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'models.dart';
class Api {
final http.Client _httpClient;
final FlutterSecureStorage _flutterSecureStorage;

2
lib/common_widgets.dart

@ -1,7 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:twtxt_flutter/viewmodels.dart';
import 'package:goryon/viewmodels.dart';
import 'models.dart';
import 'screens/discover.dart';

8
lib/main.dart

@ -4,10 +4,10 @@ import 'package:flutter/services.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
import 'package:twtxt_flutter/api.dart';
import 'package:twtxt_flutter/common_widgets.dart';
import 'package:twtxt_flutter/strings.dart';
import 'package:twtxt_flutter/viewmodels.dart';
import 'package:goryon/api.dart';
import 'package:goryon/common_widgets.dart';
import 'package:goryon/strings.dart';
import 'package:goryon/viewmodels.dart';
import 'screens/auth_widget.dart';

2
lib/screens/auth_widget.dart

@ -2,11 +2,11 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:twtxt_flutter/screens/discover.dart';
import '../api.dart';
import '../models.dart';
import '../viewmodels.dart';
import 'discover.dart';
import 'login.dart';
import 'timeline.dart';

5
lib/viewmodels.dart

@ -2,8 +2,9 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:rxdart/rxdart.dart';
import 'package:twtxt_flutter/api.dart';
import 'package:twtxt_flutter/models.dart';
import 'api.dart';
import 'models.dart';
class AuthViewModel {
final Api _api;

6
pubspec.yaml

@ -1,5 +1,5 @@
name: twtxt_flutter
description: A new Flutter project.
name: goryon
description: A twtxt mobile app
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+2
version: 1.0.0+3
environment:
sdk: ">=2.7.0 <3.0.0"

37
scripts/setenv.sh

@ -0,0 +1,37 @@
#!/usr/bin/env bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
echo "Script absolute path is $SCRIPT_DIR"
PROJ_ROOT="$(dirname "$SCRIPT_DIR")"
echo "Project root path is $PROJ_ROOT"
if [ -z "${ANDROID_KEY_STORE_PWD}" ]; then
echo "ANDROID_KEY_STORE_PWD not found, abort"
exit 1
else
echo "ANDROID_KEY_STORE_PWD detected, proceeding..."
fi
if [ -z "${ANDROID_KEY_PWD}" ]; then
echo "ANDROID_KEY_PWD not found, abort"
exit 1
else
echo "ANDROID_KEY_PWD detected, proceeding..."
fi
# Create the keystore for signing the Android app.
rm -f "${PROJ_ROOT}"/android/key.properties
{
echo "storePassword=${ANDROID_KEY_STORE_PWD}"
echo "keyPassword=${ANDROID_KEY_PWD}"
echo "keyAlias=key"
echo "storeFile=key.jks"
} >>"$PROJ_ROOT"/android/key.properties
echo "${RELEASE_KEYSTORE}" > release.keystore.asc
gpg -d --passphrase "${RELEASE_KEYSTORE_PASSPHRASE}" --batch release.keystore.asc >"${PROJ_ROOT}"/android/app/key.jks
mkdir -p "$PROJ_ROOT"/keys
echo "${RELEASE_SERVICE_ACCOUNT_KEYSTORE}" > service_account.keystore.asc
gpg -d --passphrase "${RELEASE_KEYSTORE_PASSPHRASE}" --batch service_account.keystore.asc >"${PROJ_ROOT}"/keys/android/service_account.json

2
test/widget_test.dart

@ -8,7 +8,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:twtxt_flutter/main.dart';
import 'package:goryon/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {

Loading…
Cancel
Save