Skip to content

Commit

Permalink
app releasing and ci / cd init (#99)
Browse files Browse the repository at this point in the history
* example app is signable & releasable in internal SBB store
* example android app can be released using android_release.yml workflow
* tests are automatically run on every commit
* added pub scorer workflow, runs on pushes to main - creates report
  • Loading branch information
smallTrogdor authored Oct 19, 2023
1 parent fd49d8a commit 25a52fd
Show file tree
Hide file tree
Showing 57 changed files with 201 additions and 211 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/android_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: android_release
on: workflow_dispatch

jobs:
build-and-release:
runs-on: ubuntu-latest

steps:
- name: Set up JDK 11.
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin

- name: Checkout design_system_flutter code.
uses: actions/checkout@v4

- name: Write Keystore from base64 encoded secret.
id: write_keystore
uses: timheuer/[email protected]
with:
fileName: "fdsm_keystore.jks"
fileDir: "./example/android/app/keys"
encodedString: ${{ secrets.KEYSTORE_64 }}

- name: Parse flutter version and channel specified in .fvm into env vars.
uses: kuhnroyal/flutter-fvm-config-action@v1

- name: Clone flutter version specified in .fvm.
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}

- name: Run flutter doctor.
run: flutter doctor -v

- name: Install dependencies.
run: flutter pub get
working-directory: example

- name: Build appbundle.
run: flutter build appbundle --no-pub
working-directory: example
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}

- name: Create Signing Report.
run: ./gradlew signingReport
working-directory: example/android

- name: Upload appbundle as artifact.
uses: actions/upload-artifact@v3
with:
name: app-release.aab
path: example/build/app/outputs/bundle/release/
retention-days: 1

- name: Write Google SA json from base64 encoded secret.
id: write_google_sa
uses: timheuer/[email protected]
with:
fileName: "gp_service_account.json"
fileDir: "./example/android/app/keys"
encodedString: ${{ secrets.GOOGLE_PLAYSTORE_SERVICE_ACCOUNT_64 }}

- name: Release using GPP.
run: ./gradlew publishBundle --artifact-dir ../build/app/outputs/bundle/release/
working-directory: example/android
50 changes: 0 additions & 50 deletions .github/workflows/dart.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/pubdev_score.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Workflow evaluates the score on pub.dev.
# Runs on each push to main.

name: pubdev_score

on:
push:
branches:
- main

jobs:
scoring:
runs-on: ubuntu-latest

steps:
- name: Clone repository.
uses: actions/checkout@v4
with:
ref: main
- name: Evaluate Score
uses: axel-op/dart-package-analyzer@v3
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Runs flutter test on every push.
# Failed goldens are uploaded and can be seen in the artifact summary of the job.

name: test

on:
push:

jobs:
test:
runs-on: macos-latest

steps:
- name: Checkout design_system_flutter code.
uses: actions/checkout@v4

- name: Parse flutter version and channel specified in .fvm into env vars.
uses: kuhnroyal/flutter-fvm-config-action@v1

- name: Clone flutter version specified in .fvm.
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}

- name: Run flutter doctor.
run: flutter doctor -v

- name: Install dependencies.
run: flutter pub get

- name: Run flutter test.
id: test
run: flutter test

- name: Upload goldens if tests fail.
uses: actions/upload-artifact@v3
if: ${{ failure() && steps.test.conclusion == 'failure' }}
with:
name: goldens
path: test/failures/


3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
.history
.svn/

# no keystores
*.jks

# IntelliJ related
*.iml
*.ipr
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Generally speaking, we are welcoming contributions improving existing UI element

General instructions on _how_ to contribute can be found under [Contributing](Contributing.md).

### Github Actions

This project is built and tested using [Github Actions](https://docs.github.com/en/actions). On every push to any branch, a `test` workflow is triggered, running all tests in the `.\test\` dir. Failed golden tests will be uploaded to the job artifacts. The tests run on a _macos_ runner.

## Authors

* **Hoang Tran**
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/key.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
Expand Down
21 changes: 12 additions & 9 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# example
# Showcase App - Flutter DSM

A new Flutter project.
This showcase app illustrates the components of the design_system_flutter package.

## Getting Started

This project is a starting point for a Flutter application.
* Install `fvm`, following the instructions [here](https://fvm.app/docs/getting_started/installation).
* For running this application locally, run the following command from your shell:

A few resources to get you started if this is your first Flutter project:
```shell

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
fvm flutter run

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
```
This will install all the necessary dependencies and run the application on your local emulator.

## Deployment

This app is built and deployed using github actions. Check the `android_release.yml` inside `./.github/workflows`. The necessary secrets are set within the repository. They are also securely stored by the SBB AppBakery Team.
30 changes: 25 additions & 5 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
// for local signing
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.github.triplet.play'

android {
compileSdkVersion 31
Expand All @@ -37,24 +44,37 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "ch.sbb.mds.example.example"
applicationId "ch.sbb.fdsm.example"
minSdkVersion 16
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
// these will be given in Github Workflow
storeFile file(System.getenv('PUBLISH_KEYSTORE_FILE') ?: file("keys/fdsm_keystore.jks"))
storePassword System.getenv('KEYSTORE_PASSWORD') ?: keystoreProperties['storePassword']
keyAlias System.getenv('SIGNING_KEY_ALIAS') ?: keystoreProperties['keyAlias']
keyPassword System.getenv('KEY_PASSWORD') ?: keystoreProperties['keyPassword']
}
}

buildTypes {
debug
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
}
}
}

play {
track.set('alpha')
serviceAccountCredentials.set(file("keys/gp_service_account.json"))
}

flutter {
source '../..'
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.sbb.mds.example.example">
package="ch.sbb.fdsm.example">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
7 changes: 5 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.sbb.mds.example.example">
package="ch.sbb.fdsm.example">

<uses-permission android:name="android.permission.INTERNET"/>

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
Expand All @@ -8,7 +10,8 @@
FlutterApplication and put your custom class here. -->
<application
android:name="${applicationName}"
android:label="example"
android:label="Flutter DSM"
android:roundIcon="@mipmap/round_launcher"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.sbb.mds.example.example
package ch.sbb.fdsm.example

import androidx.annotation.NonNull

Expand Down
Binary file modified example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion example/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.sbb.mds.example.example">
package="ch.sbb.fdsm.example">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
1 change: 1 addition & 0 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.triplet.gradle:play-publisher:3.8.4"
}
}

Expand Down
1 change: 0 additions & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ org.gradle.jvmargs=-Xmx1536M

android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
18 changes: 0 additions & 18 deletions example/ios/Flutter/Flutter.podspec

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Loading

0 comments on commit 25a52fd

Please sign in to comment.