Skip to content

Commit

Permalink
ADD: GitHub Actions CI/CD for web build and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
rydmike committed Aug 12, 2023
1 parent 9492675 commit 9b70cdc
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This GitHub action runs on a release, when the GitHub repo is "published".
# This workflow:
# - Installs dart and flutter
# - Uses flutter stable channel.
# - Enables flutter web
# - Gets package dependencies
# - Runs dart analyze.
# - Show outdated packages, just added for info.
# - Verify that dart format is used by all committed code, fail if not.
# - Build WEB example app.
# Steps:
# - Flutter clean.
# - Flutter build web app, in release mode and with CanvasKit renderer.#
# - Deploy built Web App to GitHub pages.
name: Deploy
on:
push:
branches: [none]
paths-ignore:
- "**.md"
pull_request:
branches: [none]
paths-ignore:
- "**.md"
release:
branches: [master]
types: [publish]

jobs:
flutter_tests:
name: "Analyze app, then build and deploy web version"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Flutter and Dart SDK
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: "Show Dart SDK version"
run: dart --version
- name: "Show Flutter SDK version"
run: flutter --version
- name: "Flutter Enable Web"
run: flutter config --enable-web
- name: "Get Flutter package dependencies"
run: flutter pub get
- name: "Analyze Dart source"
run: dart analyze
- name: "Show outdated packages"
run: flutter pub outdated
- name: "Verify that Dart formatting is used, fail if not"
run: dart format --output=none --set-exit-if-changed .

# Web - Build and deploy
- name: "EXAMPLE START BUILD - Flutter clean before build"
run: flutter clean
- name: "EXAMPLE WEB release build"
run: flutter build web --web-renderer canvaskit --base-href "/squircle/latest/" --release -t lib/main.dart
- name: "EXAMPLE DEPLOY to GitHub Pages repository, published on commit."
uses: dmnemec/copy_file_to_another_repo_action@v1.0.4
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
with:
source_file: '/build/web/.'
destination_folder: 'squircle/latest'
destination_repo: 'rydmike/rydmike.github.io'
user_email: 'm.rydstrom@gmail.com'
user_name: 'rydmike'
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This GitHub action is configured to run "on" push to "master".
# Currently, using the "validate" workflow instead, this is an older test CI/CD.
# This workflow:
# - Installs dart and flutter
# - Uses flutter stable channel.
# - Enables flutter web
# - Gets package dependencies
# - Runs dart analyze.
# - Show outdated packages, just added for info.
# - Verify that dart format is used by all committed code, fails if not.
name: Test
on:
pull_request:
branches: [master]
paths-ignore:
- "**.md"
push:
branches: [none]
paths-ignore:
- "**.md"
jobs:
flutter_test:
name: "Analyze and test package"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Install Flutter and Dart SDK"
uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: "Show Dart SDK version"
run: dart --version
- name: "Show Flutter SDK version"
run: flutter --version
- name: "Get Flutter package dependencies"
run: flutter pub get
- name: "Analyze Dart source"
run: dart analyze
- name: "Show outdated packages"
run: flutter pub outdated
- name: "Verify that Dart formatting is used, fail if not"
run: dart format --output=none --set-exit-if-changed .

4 changes: 2 additions & 2 deletions lib/app/constants/app_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class AppData {
// Version of the WEB build, usually same as package, but it also has a
// build numbers.
static const String versionMajor = '1';
static const String versionMinor = '2';
static const String versionPatch = '1';
static const String versionMinor = '3';
static const String versionPatch = '0';
static const String versionBuild = '01';
static const String version = '$versionMajor.$versionMinor.$versionPatch '
'Build-$versionBuild';
Expand Down

0 comments on commit 9b70cdc

Please sign in to comment.