-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from madmini/feature/gh-actions
Add GitHub Actions workflow
- Loading branch information
Showing
15 changed files
with
210 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# for reference see: | ||
# - Workflow syntax: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | ||
# - Contexts: https://docs.github.com/en/actions/learn-github-actions/contexts | ||
# - Expressions: https://docs.github.com/en/actions/learn-github-actions/expressions | ||
name: CI | ||
|
||
on: | ||
workflow_dispatch: # run from the Actions tab | ||
push: | ||
branches: [ "main" ] | ||
tags: [ "v*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
DART_DEFINES: >- | ||
--dart-define=GIT_URL=https://github.com/madmini/epc-qr | ||
--dart-define=GIT_REF=${{ github.ref_name }} | ||
--dart-define=CI_PROVIDER=GitHubActions | ||
--dart-define=COMMIT_HASH=${{ github.sha }} | ||
--dart-define=VERSION_TAG=${{ github.ref_name }} | ||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
container: cirrusci/flutter:stable | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install dependencies | ||
run: flutter pub get | ||
|
||
- name: Build web | ||
run: flutter build web --release --base-href "/epc-qr/" $DART_DEFINES | ||
|
||
- name: Compress web build | ||
run: zip -r ../web.zip . | ||
working-directory: build/web | ||
|
||
- name: Store web build | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-web | ||
path: build/web.zip | ||
|
||
- if: github.ref_type == 'tag' | ||
name: Set-up GitHub Pages deployment | ||
run: apt-get update && apt-get install -y rsync | ||
|
||
- if: github.ref_type == 'tag' | ||
name: Deploy to GitHub Pages | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: build/web | ||
|
||
- name: Build Android | ||
run: flutter build apk --release $DART_DEFINES | ||
|
||
- name: Store android build | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-android | ||
path: build/app/outputs/flutter-apk/app-release.apk | ||
|
||
- if: github.ref_type == 'tag' | ||
name: Prepare release | ||
run: | | ||
mkdir artifacts | ||
mv build/web.zip artifacts/epc-qr_${{ github.ref_name }}_web.zip | ||
mv build/app/outputs/flutter-apk/app-release.apk artifacts/epc-qr_${{ github.ref_name }}.apk | ||
- if: github.ref_type == 'tag' | ||
name: Create release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
draft: true | ||
artifacts: artifacts/* |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:epc_qr/widgets/linkify_on_open.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_linkify/flutter_linkify.dart'; | ||
|
||
const kGitUrl = String.fromEnvironment('GIT_URL'); | ||
const kGitRef = String.fromEnvironment('GIT_REF'); | ||
const kCommitHash = String.fromEnvironment('COMMIT_HASH'); | ||
const kCiProvider = String.fromEnvironment('CI_PROVIDER'); | ||
const kVersionTag = String.fromEnvironment('VERSION_TAG'); | ||
|
||
class AboutButton extends StatelessWidget { | ||
const AboutButton({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return IconButton( | ||
icon: const Icon(Icons.info), | ||
onPressed: () => showAboutDialog( | ||
context: context, | ||
applicationName: 'EPC-QR Generator', | ||
applicationVersion: kVersionTag != '' ? kVersionTag : null, | ||
children: kGitUrl != '' ? const [AboutSourceText()] : null, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class AboutSourceText extends StatelessWidget { | ||
const AboutSourceText({Key? key}) : super(key: key); | ||
|
||
TextStyle _codeStyle(BuildContext context) => TextStyle( | ||
fontFamily: 'RobotoMono', | ||
color: Theme.of(context).textTheme.headline4?.color, | ||
fontWeight: Theme.of(context).brightness == Brightness.light | ||
? FontWeight.bold | ||
: null, | ||
); | ||
|
||
TextStyle _linkStyle(BuildContext context) => TextStyle( | ||
fontFamily: 'RobotoMono', | ||
color: Theme.of(context).brightness == Brightness.dark | ||
? const Color(0xFF9BCAFF) | ||
: const Color(0xFF0062A0), | ||
); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (kGitUrl == '') return const SizedBox(); | ||
|
||
return SelectableText.rich( | ||
TextSpan(children: [ | ||
const TextSpan( | ||
text: 'Built${kCiProvider != '' ? ' by $kCiProvider' : ''} from ', | ||
), | ||
LinkifySpan( | ||
text: kGitUrl, | ||
linkStyle: _linkStyle(context), | ||
onOpen: onOpenLaunchUrl, | ||
), | ||
if (kCommitHash != '') | ||
TextSpan(children: [ | ||
const TextSpan(text: ' at '), | ||
TextSpan(text: kCommitHash, style: _codeStyle(context)), | ||
]), | ||
if (kGitRef != '') | ||
TextSpan(children: [ | ||
const TextSpan(text: ' ('), | ||
TextSpan(text: kGitRef, style: _codeStyle(context)), | ||
const TextSpan(text: ')'), | ||
]), | ||
const TextSpan(text: '.'), | ||
]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:flutter_linkify/flutter_linkify.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
|
||
/// Launches the given URL. | ||
void onOpenLaunchUrl(LinkableElement link) async { | ||
final uri = Uri.parse(link.url); | ||
await launchUrl(uri); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
bool get shareFeatureAvailable { | ||
throw (UnimplementedError("STUB")); | ||
return false; | ||
} | ||
|
||
Future<void> shareFile(String name, List<int> data, {String? mimeType}) { | ||
throw UnimplementedError(); | ||
throw UnimplementedError('Sharing files is not supported on this platform.'); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters