-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (169 loc) · 6.23 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
191
192
193
194
195
196
197
198
name: Windows & Android release
on:
workflow_dispatch:
inputs:
android:
type: boolean
description: 'Билд для Android.'
required: false
default: true
windows:
type: boolean
description: 'Билд для Windows.'
required: false
default: true
telegram:
type: boolean
description: 'Указывает, будет ли создаваться публикация в Telegram-канале.'
required: false
default: true
create-release:
type: boolean
description: 'Указывает, что будет создаваться Github Release.'
required: false
default: true
pre-release:
type: boolean
description: 'Указывает, что создаваемый Github Release будет иметь плашку pre-release.'
required: false
default: true
debug:
type: boolean
description: 'Запуск данного Action с SSH-подключением в случае, если билд оказался неудачным (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
build_android:
if: ${{ inputs.android }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Java and Flutter for Android
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
cache: gradle
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- name: Get dependencies
run: flutter pub get
- name: Sign Android release
run: |
echo '${{ secrets.ANDROID_KEYSTORE_FILE_BASE64 }}' | base64 --decode > android/app/upload-keystore.jks
echo '${{ secrets.ANDROID_KEY_PROPERTIES }}' > android/key.properties
- name: Build Android release
run: |
flutter build apk --release
cp ./build/app/outputs/flutter-apk/app-release.apk "./build/Flutter VK Android.apk"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Flutter VK Android.apk
path: ./build/Flutter VK Android.apk
retention-days: 3
- name: Debug with SSH on fail
if: ${{ failure() && inputs.debug }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
build_windows:
if: ${{ inputs.windows }}
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- name: Get dependencies
run: flutter pub get
- name: Build Windows release
run: flutter build windows --release
- name: Build installer and portable .7z archive
shell: bash
run: |
echo "Creating portable 7z archive"
"/c/Program Files/7-Zip/7z.exe" a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on "./build/Flutter VK portable.7z" "./build/Windows/x64/runner/Release/"
echo "Downloading and installing Inno installer"
make innoinstall
echo "Creating Windows installer"
make inno
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: |
./build/Flutter VK installer.exe
./build/Flutter VK portable.7z
retention-days: 3
- name: Debug with SSH on fail
if: ${{ failure() && inputs.debug }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
publish:
runs-on: ubuntu-latest
if: ${{ inputs.create-release || inputs.telegram }}
needs: [build_android, build_windows]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: build/
merge-multiple: true
- name: Publish in Telegram
if: ${{ inputs.telegram }}
shell: pwsh
run: |
$telegramToken = $env:TELEGRAM_TOKEN
$telegramTo = $env:TELEGRAM_TO
# Android
Invoke-RestMethod -Uri "https://api.telegram.org/bot$telegramToken/sendDocument" -Method Post -Form @{
chat_id = $telegramTo
caption = "<b>🚧 Новый билд для Android</b>.`n`n#Android"
parse_mode = 'HTML'
document = Get-Item -Path './build/Flutter VK Android.apk'
}
# Windows installer
Invoke-RestMethod -Uri "https://api.telegram.org/bot$telegramToken/sendDocument" -Method Post -Form @{
chat_id = $telegramTo
caption = "<b>🚧 Новый билд для Windows</b>.`n`n#Windows #installer"
parse_mode = 'HTML'
document = Get-Item -Path './build/Flutter VK installer.exe'
}
# Windows portable
Invoke-RestMethod -Uri "https://api.telegram.org/bot$telegramToken/sendDocument" -Method Post -Form @{
chat_id = $telegramTo
caption = "<b>🚧 Новый билд для Windows</b>.`n`n#Windows #portable"
parse_mode = 'HTML'
document = Get-Item -Path './build/Flutter VK portable.7z'
}
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }}
- name: Create release
if: ${{ inputs.create-release }}
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
if: ${{ inputs.create-release }}
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Flutter VK v${{ steps.tag_version.outputs.new_tag }}
prerelease: ${{ inputs.pre-release }}
bodyFile: CHANGELOG.md
artifacts: "build/*.*"
- name: Debug with SSH on fail
if: ${{ failure() && inputs.debug }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true