Skip to content

Commit

Permalink
ci: github
Browse files Browse the repository at this point in the history
  • Loading branch information
borgoat committed Dec 21, 2024
1 parent d2a1aa6 commit ce5bee8
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 1 deletion.
93 changes: 93 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build

on:
workflow_dispatch:
push:
branches:
- main

jobs:
flutter:
runs-on: ubuntu-latest

permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: Download dependencies
run: flutter pub get

# - name: Run tests
# run: |
# flutter test

- name: Compare pubspec version and git tag
id: pubspec_tag
run: |
PUBSPEC_VERSION=v$(grep -oP '^version:\s*\K[0-9]+\.[0-9]+\.[0-9]+' pubspec.yaml)
echo "Found version in pubspec.yaml: $PUBSPEC_VERSION"
echo "tag_name=$PUBSPEC_VERSION" >> $GITHUB_OUTPUT
# This step prepares a draft release with the release notes generated from the commit messages,
# and the tag name from the pubspec.yaml file. It will only update the release if it is a draft
# and has not been published yet. If the release is already published, it will not be updated and fail.
# Once a version is published to the app store, the release should be marked as published.
- name: Create or update draft release
uses: ncipollo/release-action@v1
with:
name: ${{ steps.pubspec_tag.outputs.tag_name }}
tag: ${{ steps.pubspec_tag.outputs.tag_name }}
generateReleaseNotes: true
makeLatest: true
draft: true
allowUpdates: true
updateOnlyUnreleased: true

# - name: Configure git
# run: |
# git config --global user.name "GitHub Actions Bot"
# git config --global user.email "tech+gitbot@sealambda.com"
# git fetch origin gh-pages:gh-pages
#
# - name: Compile web and put in gh-pages branch
# run: dart run peanut
#
# - name: Push gh-pages
# run: git push origin gh-pages

- name: Retrieve the Android keystore and key properties
env:
UPLOAD_KEYSTORE_B64: ${{ secrets.UPLOAD_KEYSTORE_B64 }}
KEY_PROPERTIES: ${{ secrets.KEY_PROPERTIES }}
run: |
echo "$UPLOAD_KEYSTORE_B64" | base64 --decode > android/keystore.jks
echo "$KEY_PROPERTIES" > android/key.properties
- name: Compile Android app
run: flutter build appbundle --build-number ${{ github.run_number }}

- name: Upload Android app to Play Store
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: com.sealambda.artificialstupidity
releaseFiles: build/app/outputs/bundle/release/app-release.aab
track: internal
status: completed
mappingFile: build/app/outputs/mapping/release/mapping.txt
debugSymbols: build/app/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib
17 changes: 16 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ plugins {
id "dev.flutter.flutter-gradle-plugin"
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
namespace = "com.sealambda.artificialstupidity"
compileSdk = flutter.compileSdkVersion
Expand All @@ -30,11 +36,20 @@ android {
versionName = flutter.versionName
}

signingConfigs {
release {
keyAlias = keystoreProperties['keyAlias']
keyPassword = keystoreProperties['keyPassword']
storeFile = keystoreProperties['storeFile'] ? rootProject.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
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
mocktail:
dependency: "direct dev"
description:
name: mocktail
sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
nested:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ dev_dependencies:
build_runner: ^2.4.13
freezed: ^2.5.7
json_serializable: ^6.9.0
mocktail: ^1.0.4

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
14 changes: 14 additions & 0 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@ import 'dart:async';
import 'package:artificialstupidity/app/app.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:mocktail/mocktail.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';

class MockStorage extends Mock implements Storage {}

void main() {
late Storage storage;

setUp(() {
storage = MockStorage();
when(
() => storage.write(any(), any<dynamic>()),
).thenAnswer((_) async {});
HydratedBloc.storage = storage;
});

testWidgets('Receive SharedMediaFile', (WidgetTester tester) async {
final streamController = StreamController<List<SharedMediaFile>>();

Expand Down

0 comments on commit ce5bee8

Please sign in to comment.