Skip to content

Commit

Permalink
Build script
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Aug 3, 2024
1 parent e81b326 commit 02798d5
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 27 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: CI & CD

on:
workflow_dispatch:

push:
branches: [develop, main]
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"

pull_request:
branches: [develop, main]

# This ensures that previous jobs for the PR are canceled when PR is updated
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build package & run tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Use shallow clone for faster checkout

- name: Check broken links
uses: JustinBeckwith/linkinator-action@v1
with:
paths: "**/*.md"

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
architecture: x64
cache: true

- name: Install dependencies
run: dart pub get

- name: Format code
run: dart format --set-exit-if-changed .

- name: Analyze static code
run: dart analyze

- name: Run tests
run: flutter test --no-pub --coverage

- name: Check publish warnings
run: dart pub publish --dry-run

example:
name: Build example app
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Use shallow clone for faster checkout

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
architecture: x64
cache: true

- name: Install dependencies
run: dart pub get

- name: Build example
run: flutter build appbundle --debug
working-directory: example

deployment:
if: ${{ github.ref_type == 'tag' }}
needs: [build, example]
name: Deploy package
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Use shallow clone for faster checkout

- name: Set up Dart
uses: dart-lang/setup-dart@v1

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
architecture: x64
cache: true

- name: Install dependencies
run: dart pub get

- name: Publish package
run: dart pub publish -v -f
35 changes: 11 additions & 24 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
analyzer:
errors:
missing_required_param: error
missing_return: error
todo: ignore

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
one_member_abstracts: false
prefer_relative_imports: true
always_use_package_imports: false
omit_local_variable_types: false
directives_ordering: true

3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:typed_data';

import 'package:example/sample_animation.dart';
import 'package:flutter/material.dart';
import 'package:screen_recorder/screen_recorder.dart';

import 'sample_animation.dart';

void main() {
runApp(const MyApp());
}
Expand Down
3 changes: 1 addition & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:example/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:example/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down

0 comments on commit 02798d5

Please sign in to comment.