-
Notifications
You must be signed in to change notification settings - Fork 1
169 lines (159 loc) · 6.15 KB
/
release.yaml
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
name: Draft Release
on:
workflow_dispatch:
# Enable manual workflow run
push:
# Sequence of patterns matched against refs/tags
tags:
- "*" # Push events that match "*". For example: "1.0", "20.15.10"
jobs:
build:
name: Create ${{ matrix.target }} build
runs-on: ${{ matrix.os }}
strategy:
matrix:
target: [Android, Web] # [Android, iOS, Linux, macOS, Windows, Web]
include:
# - os: ubuntu-20.04
# target: Android
# build_target: appbundle
# build_path: build/app/outputs/bundle/release
# asset_extension: .aab
# channel: stable
- os: ubuntu-20.04
target: Android
build_target: apk
build_path: build/app/outputs/apk/release
asset_extension: .apk
channel: stable
# - os: ubuntu-20.04
# target: Linux
# build_target: linux
# build_path: build/linux/release/bundle
# asset_extension: .tar.gz
# channel: stable
# - os: macos-10.15
# target: macOS
# build_target: macos
# build_path: build/macos/Build/Products/Release
# asset_extension: .zip
# channel: stable
# - os: windows-2019
# target: windows
# build_target: windows
# build_path: build/windows/runner/Release
# asset_extension: .zip
# channel: stable
- os: ubuntu-20.04
target: Web
build_target: web
build_path: build/web
asset_extension: .tar.gz
channel: stable
# Disable fail-fast as we want results from all even if one fails.
fail-fast: false
steps:
# Set environment variables.
- name: Get release tag version
run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Create build asset name
env:
REPOSITORY_NAME: ${{ github.event.repository.name }}
MATRIX_TARGET: ${{ matrix.target }}
run: |
export RELEASE_TARGET=$(echo "${MATRIX_TARGET,,}")
echo "BUILD_ASSET_NAME=${{ env.REPOSITORY_NAME }}_${RELEASE_TARGET}_${{ env.RELEASE_TAG }}${{ matrix.asset_extension }}" >> $GITHUB_ENV
# Set up Flutter.
- name: Clone Flutter repository with ${{ matrix.channel }} channel
uses: subosito/flutter-action@v1.5.3
with:
channel: ${{ matrix.channel }}
# Set up required dependencies.
- name: Install Linux dependencies
if: matrix.target == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev
- name: Install Android dependencies
if: matrix.target == 'android'
uses: actions/setup-java@v1
with:
java-version: '12.x'
- name: Enable web support
if: matrix.target == 'web'
run: flutter config --enable-web
- name: Enable desktop support
if: matrix.target == 'linux' || matrix.target == 'windows' || matrix.target == 'macos'
run: flutter config --enable-${{ matrix.build_target }}-desktop
- name: Run Flutter doctor
run: flutter doctor -v
# Clone the repository and get required packages.
- name: Clone the repository
uses: actions/checkout@v2
# Cache required files.
- name: Cache Gradle packages
if: matrix.target == 'android'
uses: actions/cache@v2
env:
CACHE_NAME: gradle
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ env.CACHE_NAME }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-${{ env.CACHE_NAME }}-
- name: Cache pubspec dependencies
uses: actions/cache@v2
env:
CACHE_NAME: pubspec
with:
path: |
${{ env.PUB_CACHE }}
${{ env.FLUTTER_ROOT }}/bin
**/.dart_tool
**/.packages
**/.flutter-plugins
**/.flutter-plugin-dependencies
key: ${{ runner.os }}-${{ env.CACHE_NAME }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.CACHE_NAME }}-
- name: Get packages for the Flutter project
run: flutter pub get
# Build the application.
- name: Build project
run: flutter build -v ${{ matrix.build_target }}
# Prepare release build package.
- name: Copy VC redistributables to release directory for Windows
if: matrix.target == 'windows'
run: |
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\msvcp140.dll') .
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140.dll') .
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140_1.dll') .
# Compress build.
- name: Compress build for Windows
if: matrix.target == 'windows'
run: compress-archive -Path * -DestinationPath ./${{ env.BUILD_ASSET_NAME }}
working-directory: ${{ matrix.build_path }}
- name: Compress build for Linux
if: matrix.target == 'linux' || matrix.target == 'web'
run: tar czf ./${{ env.BUILD_ASSET_NAME }} *
working-directory: ${{ matrix.build_path }}
- name: Compress build for macOS
if: matrix.target == 'macos'
run: ditto -c -k --sequesterRsrc --keepParent '*.app' ./${{ env.BUILD_ASSET_NAME }}
working-directory: ${{ matrix.build_path }}
- name: Rename build for Android
if: matrix.target == 'android'
run: mv app-release${{ matrix.asset_extension }} ./${{ env.BUILD_ASSET_NAME }}
working-directory: ${{ matrix.build_path }}
# Upload the build.
- name: Upload release asset
id: upload_release_asset
uses: softprops/action-gh-release@v1
with:
name: Flutter Notes v${{ env.RELEASE_TAG }}
draft: true
prerelease: false
files: |
./${{ matrix.build_path }}/${{ env.BUILD_ASSET_NAME }}