Skip to content

Commit

Permalink
chore(workflows): customizable workflows (#1356)
Browse files Browse the repository at this point in the history
* ability to trigger each job individually via workflow_dispatch
* categorize reusable workflows / jobs into `build` and `test`
* split trigger into `pull-request` and `release`
  • Loading branch information
Gustl22 authored Dec 24, 2022
1 parent 06be429 commit 3a3d174
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 71 deletions.
167 changes: 167 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: build
on:
workflow_dispatch:
inputs:
enable_android:
description: 'Build Android'
required: false
default: true
type: boolean
enable_web:
description: 'Build Web'
required: false
default: true
type: boolean
enable_ios:
description: 'Build IOS'
required: false
default: true
type: boolean
enable_windows:
description: 'Build Windows'
required: false
default: true
type: boolean
enable_linux:
description: 'Build Linux'
required: false
default: true
type: boolean
enable_macos:
description: 'Build MacOS'
required: false
default: true
type: boolean
workflow_call:
inputs:
enable_android:
required: false
default: true
type: boolean
enable_web:
required: false
default: true
type: boolean
enable_ios:
required: false
default: true
type: boolean
enable_windows:
required: false
default: true
type: boolean
enable_linux:
required: false
default: true
type: boolean
enable_macos:
required: false
default: true
type: boolean

jobs:
web:
runs-on: ubuntu-latest
timeout-minutes: 30
if: inputs.enable_web
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@main

- name: Example app - Build Web app
working-directory: ./packages/audioplayers/example
run: flutter build web

android:
runs-on: ubuntu-latest
timeout-minutes: 60
if: inputs.enable_android
steps:
- uses: actions/checkout@v3

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

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@main

- name: Example App - Build Android APK
working-directory: ./packages/audioplayers/example
run: flutter build apk --release

- name: Run Android unit tests
working-directory: ./packages/audioplayers/example/android
run: ./gradlew test

ios:
runs-on: macOS-latest
timeout-minutes: 30
if: inputs.enable_ios
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@main

- name: Example app - Build iOS
working-directory: ./packages/audioplayers/example
run: flutter build ios --release --no-codesign

macos:
runs-on: macOS-latest
timeout-minutes: 30
if: inputs.enable_macos
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@main

- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
podfile-path: ./packages/audioplayers/example/macos/Podfile.lock
- name: Example app - Build macOS
working-directory: ./packages/audioplayers/example
run: flutter build macos --release

windows:
runs-on: windows-latest
timeout-minutes: 30
if: inputs.enable_windows
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@main

- name: Example app - Build Windows app
working-directory: ./packages/audioplayers/example
run: flutter build windows --release

linux:
runs-on: ubuntu-latest
timeout-minutes: 30
if: inputs.enable_linux
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@main

- name: Install Flutter requirements for Linux
run: |
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
- name: Install GStreamer
# Install libunwind-dev, see https://github.com/actions/runner-images/issues/6399#issuecomment-1285011525
run: |
sudo apt install -y libunwind-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
- name: Example app - Build Linux app
working-directory: ./packages/audioplayers/example
run: flutter build linux --release
15 changes: 15 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pull-request
on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
call-test:
uses: ./.github/workflows/test.yml
if: github.event.pull_request.draft == false
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: release
on:
push:
branches:
- main

jobs:
call-build:
uses: ./.github/workflows/build.yml

call-test:
needs: call-build
uses: ./.github/workflows/test.yml
Loading

0 comments on commit 3a3d174

Please sign in to comment.