forked from eludris-community/eludris_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (119 loc) · 4.1 KB
/
build-lint-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Build, Lint, and Deploy
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
cache:
# This job caches the pub cache and flutter dependencies to speed up the build process
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
- name: Cache Flutter Dependencies
id: cache-flutter-dependencies
uses: actions/cache@v2
with:
path: ${{ env.PUB_CACHE }}
key: ${{ runner.os }}-${{ hashFiles('**/pubspec.lock') }}-pub-cache
- name: Install Packages
if: steps.cache-flutter-dependencies.outputs.cache-hit != 'true'
run: flutter pub get
build:
needs: cache
runs-on: ${{ matrix.os }}
strategy:
matrix:
command: [apk, web, windows, linux]
include:
- command: apk
os: ubuntu-latest
upload: ./build/app/outputs/flutter-apk/app-release.apk
- command: web
os: ubuntu-latest
upload: ./build/web
- command: linux
os: ubuntu-latest
upload: ./build/linux/x64/release/bundle
- command: windows
os: windows-latest
upload: ./build/windows/runner/Release/
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
if: matrix.command == 'apk' # Only needed for Android
with:
distribution: 'zulu'
java-version: '11'
- name: Install dependencies
if: matrix.command == 'linux' # Only needed for Linux
run: |
sudo apt-get install \
cmake \
clang \
ninja-build \
libgtk-3-dev \
liblzma-dev
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
- name: Load Cache
uses: actions/cache@v2
with:
path: ${{ env.PUB_CACHE }}
key: ${{ runner.os }}-${{ hashFiles('**/pubspec.lock') }}-pub-cache
- name: Build ${{ matrix.command }}
run: flutter build ${{ matrix.command }} --release
- name: Upload ${{ matrix.command }}
uses: actions/upload-artifact@v2
with:
name: eludris-${{ matrix.command }}
path: ${{ matrix.upload }}
lint:
runs-on: ubuntu-latest
needs: cache
steps:
- uses: actions/checkout@v2
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
- name: Load Cache
uses: actions/cache@v2
with:
path: ${{ env.PUB_CACHE }}
key: ${{ runner.os }}-${{ hashFiles('**/pubspec.lock') }}-pub-cache
- name: Lint
run: flutter analyze
deploy-web:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
runs-on: ubuntu-latest
needs: [build, lint]
steps:
- name: Download Web Build
uses: actions/download-artifact@v2
with:
name: eludris-web
path: ./build/web
- name: Deploy to Cloudflare Pages
if: ${{ env.CF_API_TOKEN != '' }}
uses: cloudflare/wrangler-action@2.0.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: pages publish --skip-caching --project-name=eludris-flutter-web --branch=main ./build/web