-
-
Notifications
You must be signed in to change notification settings - Fork 47
256 lines (229 loc) · 9.26 KB
/
deploy-github-release.yml
File metadata and controls
256 lines (229 loc) · 9.26 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Release
on:
push:
branches:
- main
- dev
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
jobs:
create-build:
name: Create ${{ matrix.target }} build
runs-on: ${{ matrix.os }}
strategy:
matrix:
target: [windows, linux, android]
include:
# - os: macos-10.15 # Catalina
# target: macOS
# build_target: macos
# build_path: build/macos/Build/Products/Release
# asset_extension: .zip
# asset_content_type: application/zip
# build_options:
- os: windows-latest
target: windows
build_target: windows
build_path: build\windows\x64\runner\Release
asset_extension: .zip
asset_content_type: application/zip
build_options:
- os: ubuntu-latest
target: linux
build_target: linux
build_path: build/linux/x64/release/bundle
asset_extension: .tar.gz
asset_content_type: application/gzip
build_options:
- os: ubuntu-latest
target: android
build_target: apk
build_path: build/app/outputs
asset_extension: .apk
asset_content_type: application/vnd.android.package-archive
build_options: --flavor=play
fail-fast: false
steps:
- name: Checkout chaldea code
uses: actions/checkout@v6
- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version-file: "pubspec.yaml"
cache: true
- name: Get Version
shell: bash
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/v') }}" = "true" ]; then
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
else
echo "VERSION=beta" >> $GITHUB_ENV
fi
- run: echo "VERSION = $VERSION"
shell: bash
- 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
sudo apt-get install -y libayatana-appindicator3-dev
- name: Install Android dependencies
if: matrix.target == 'android'
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: Enable desktop support
if: matrix.target != 'android'
run: |
flutter config --no-cli-animations
flutter config --enable-linux-desktop
flutter config --enable-macos-desktop
flutter config --enable-windows-desktop
- name: flutter doctor
if: matrix.target != 'windows'
run: flutter doctor -v
- name: Configure Keystore for Android
if: matrix.target == 'android'
run: |
echo "$PLAY_STORE_UPLOAD_KEY" | base64 --decode > app/upload-keystore.jks
echo "storeFile=upload-keystore.jks" >> key.properties
echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> key.properties
echo "storePassword=$KEYSTORE_STORE_PASSWORD" >> key.properties
echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> key.properties
env:
PLAY_STORE_UPLOAD_KEY: ${{ secrets.PLAY_STORE_UPLOAD_KEY }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
working-directory: android
- name: Enable long path on Windows
if: matrix.target == 'windows'
run: git config --system core.longpaths true
- name: Generate git info
run: dart ./scripts/gen_git_info.dart
- run: flutter pub get
- run: dart ./scripts/patch_before_build.dart ${{ matrix.target }} ${{ github.ref }}
- run: flutter pub get
- run: flutter build ${{ matrix.build_target }} -v --release ${{ matrix.build_options }}
- name: Build AAB
if: matrix.target == 'android'
run: flutter build appbundle -v --release --flavor=play
# Package the build.
- 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') .
working-directory: ${{ matrix.build_path }}
- name: Rename build for Android
if: matrix.target == 'android'
run: |
mv flutter-apk/app-play-release.apk $GITHUB_WORKSPACE/chaldea-$VERSION-${{ matrix.target }}.apk
mv bundle/playRelease/app-play-release.aab $GITHUB_WORKSPACE/chaldea-$VERSION-appbundle.aab
working-directory: ${{ matrix.build_path }}
- name: Compress build for Linux
if: matrix.target == 'linux'
run: |
cp $GITHUB_WORKSPACE/linux/README.md ./README.txt
mv ../plugins/flutter_js/bundle/lib/libquickjs_c_bridge_plugin.so ./lib/libquickjs_c_bridge_plugin.so
tar czf $GITHUB_WORKSPACE/chaldea-$VERSION-${{ matrix.target }}.tar.gz *
working-directory: ${{ matrix.build_path }}
- name: Compress build for macOS
if: matrix.target == 'macOS'
run: ditto -c -k --sequesterRsrc --keepParent Chaldea.app $GITHUB_WORKSPACE/chaldea-$VERSION-${{ matrix.target }}.zip
working-directory: ${{ matrix.build_path }}
- name: Compress build for Windows
if: matrix.target == 'windows'
run: |
cp ${env:GITHUB_WORKSPACE}/windows/README.md ./README.txt
compress-archive -Path * -DestinationPath ${env:GITHUB_WORKSPACE}\chaldea-${env:VERSION}-${{ matrix.target }}.zip
working-directory: ${{ matrix.build_path }}
- name: Generate Release Note
if: matrix.target == 'android'
run: dart ./scripts/release_note.dart ${{ env.VERSION }} release-note.md
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: chaldea-${{ env.VERSION }}-${{ matrix.target }}
if-no-files-found: error
path: |
./chaldea-${{ env.VERSION }}-*
release-note.md
publish-release:
name: Publish Release
needs: create-build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Get Date
id: get-date
run: echo "date=$(/bin/date -u +"%Y/%m/%d %H:%M:%S %Z")" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v8
- name: Move to dist & create checksums
run: |
ls -l -R
mkdir dist
mv chaldea-*/chaldea-* dist/
pushd dist
shasum -a 1 chaldea-*.{apk,aab,zip,gz} >checksums.txt
cat checksums.txt
ls -l
popd
- name: Get Version
shell: bash
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/v') }}" = "true" ]; then
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
else
echo "VERSION=beta" >> $GITHUB_ENV
fi
- name: Delete previous beta build
if: github.ref == 'refs/heads/main'
run: gh release delete beta -R ${{ github.repository }} -y --cleanup-tag || echo "delete beta failed"
env:
GH_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}
- name: Publish Beta
id: release-beta
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v3
with:
name: beta
tag_name: beta
draft: false
prerelease: true
fail_on_unmatched_files: true
body: Built at ${{ steps.get-date.outputs.date }}
body_path: chaldea-${{ env.VERSION }}-android/release-note.md
files: "dist/*"
- name: Publish Stable
id: release-stable
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v3
with:
fail_on_unmatched_files: true
body: Built at ${{ steps.get-date.outputs.date }}
body_path: chaldea-${{ env.VERSION }}-android/release-note.md
files: "dist/*"
- name: Check draft status
env:
GITHUB_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}
RELEASE_ID: ${{ steps.release-beta.outputs.id || steps.release-stable.outputs.id }}
run: |
OWNER="chaldea-center"
REPO="chaldea"
TOKEN=$GITHUB_TOKEN
sleep 15
response=$(curl -Ls -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID")
echo "$response"
is_draft=$(echo "$response" | jq '.draft')
if [ "$is_draft" = true ]; then
response2=$(curl -L -X PATCH -H "Authorization: Bearer $TOKEN" --data '{"draft":false}' "https://api.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID")
echo "Publish draft: $(echo "$response2" | jq '.draft')"
else
echo "Already published"
fi