-
Notifications
You must be signed in to change notification settings - Fork 1
190 lines (186 loc) · 7.29 KB
/
build.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: build
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
types: [ opened, reopened, closed ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
FLUTTER_VERSION: '2.10.5'
jobs:
analyze-test:
if: github.event_name != 'pull_request' || github.event.action == 'opened' || github.event.action == 'reopened' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
channel: 'stable'
cache: true
architecture: x64
- run: flutter pub get
- run: flutter pub run build_runner build
- run: flutter analyze
# - run: flutter test // TODO: create tests
build-macos:
needs: [ analyze-test ]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
channel: 'stable'
cache: true
architecture: x64
- run: flutter pub get
- run: flutter pub run build_runner build
- run: flutter config --enable-macos-desktop
- name: Install app dmg
run: npm install -g appdmg
- name: Create assets
run: flutter pub run flutter_distributor:main package --platform macos --targets dmg
- name: Upload MacOS artifact
uses: actions/upload-artifact@v3
with:
name: ac_companion-macos
path: dist/**/*.dmg
build-linux:
needs: [ analyze-test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
channel: 'stable'
cache: true
architecture: x64
- run: flutter pub get
- run: flutter pub run build_runner build
- run: flutter config --enable-linux-desktop
- name: Install linux flutter sdk requirements
run: sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
- name: Install flutter secure storage requirements
run: sudo apt-get install libsecret-1-dev libjsoncpp-dev libsecret-1-0
- name: Create assets
run: flutter pub run flutter_distributor:main package --platform linux --targets deb,zip
- name: Upload Linux artifact
uses: actions/upload-artifact@v3
with:
name: ac_companion-linux
path: |
dist/**/*.deb
dist/**/*.zip
build-windows:
needs: [ analyze-test ]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
channel: 'stable'
cache: true
architecture: x64
- run: flutter pub get
- run: flutter pub run build_runner build
- run: flutter config --enable-windows-desktop
- name: Create assets
run: flutter pub run flutter_distributor:main package --platform windows --targets msix,exe
- name: Upload windows artifact
uses: actions/upload-artifact@v3
with:
name: ac_companion-windows
path: |
dist/**/*.msix
dist/**/*.exe
deploy:
if: startsWith(github.head_ref, 'release/') && github.event.pull_request.merged == true
needs: [ build-macos, build-windows, build-linux ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Retrieve Version Number
id: versions
run: |
APP_VERSION=$(more pubspec.yaml | grep version: | cut -d ' ' -f2)
echo $APP_VERSION
echo "::set-output name=version::$(echo $APP_VERSION)"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.versions.outputs.version }}
release_name: Release ${{ steps.versions.outputs.version }}
body: |
Release Notes
draft: false
prerelease: false
- name: Download MacOS assets
uses: actions/download-artifact@v3
with:
name: ac_companion-macos
- name: Upload MacOS dmg
id: upload-release-macos-dmg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "./${{ steps.versions.outputs.version }}/appcenter_companion-${{ steps.versions.outputs.version }}-macos.dmg"
asset_name: "appcenter_companion-${{ steps.versions.outputs.version }}-macos.dmg"
asset_content_type: application/octet-stream
- name: Download Linux assets
uses: actions/download-artifact@v3
with:
name: ac_companion-linux
- name: Upload Linux deb
id: upload-asset-linux-deb
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "./${{ steps.versions.outputs.version }}/appcenter_companion-${{ steps.versions.outputs.version }}-linux_deb.deb"
asset_name: "appcenter_companion-${{ steps.versions.outputs.version }}-linux.deb"
asset_content_type: application/octet-stream
- name: Upload Linux zip
id: upload-release-linux-zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "./${{ steps.versions.outputs.version }}/appcenter_companion-${{ steps.versions.outputs.version }}-linux.zip"
asset_name: "appcenter_companion-${{ steps.versions.outputs.version }}-linux.zip"
asset_content_type: application/octet-stream
- name: Download Windows assets
uses: actions/download-artifact@v3
with:
name: ac_companion-windows
- name: Upload Windows msix
id: upload-release-windows-msix
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "./${{ steps.versions.outputs.version }}/appcenter_companion-${{ steps.versions.outputs.version }}-windows.msix"
asset_name: "appcenter_companion-${{ steps.versions.outputs.version }}-windows.msix"
asset_content_type: application/octet-stream
- name: Upload Windows exe
id: upload-release-windows-exe
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "./${{ steps.versions.outputs.version }}/appcenter_companion-${{ steps.versions.outputs.version }}-windows-setup.exe"
asset_name: "appcenter_companion-${{ steps.versions.outputs.version }}-windows-setup.exe"
asset_content_type: application/octet-stream