-
Notifications
You must be signed in to change notification settings - Fork 90
228 lines (218 loc) · 8.56 KB
/
build_publish.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
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
name: Build & Release
# Trigger on push to master branch or with a tag
on:
push:
branches:
- '**'
tags:
- v*
# If previous workflow is still running, we push again, we will cancel the previous workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
Build:
strategy:
fail-fast: false
matrix:
include:
- target: Android
os: ubuntu-latest
artifact_name: release-Android
artifact_path: build/app/outputs/apk/release/*.apk
- target: Windows
os: windows-latest
artifact_name: release-Windows
artifact_path: build/windows/*.zip
- target: Linux
os: ubuntu-22.04
artifact_name: release-Linux
artifact_path: |
build/linux/*.AppImage
build/linux/*.deb
- target: iOS
os: macos-latest
cache_pod_key: ios-pods
cache_pod_path: ios/Pods
cache_pod_restore_keys_hash_file: ios/Podfile.lock
artifact_name: release-iOS
artifact_path: build/**/*.ipa
- target: macOS
os: macos-latest
cache_pod_key: macos-pods
cache_pod_path: macos/Pods
cache_pod_restore_keys_hash_file: macos/Podfile.lock
artifact_name: release-macOS
artifact_path: /Users/runner/work/JHenTai/JHenTai/*.dmg
outputs:
version: ${{ steps.get_version.outputs.version }}
runs-on: ${{ matrix.os }}
env:
FLUTTER_VERSION: 3.24.3
steps:
# Checkout branch
- name: Checkout
uses: actions/checkout@v3
# Add Android keystore
- name: Setup Android keystore
if: matrix.target == 'Android'
run: |
echo "${{ secrets.ENCODED_KEYSTORE }}" | base64 -di > android/app/upload-keystore.jks
echo "${{ secrets.KEY_PROPERTIES }}" > android/key.properties
# Setup Flutter
- name: Setup Flutter
uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
# Cache Pod
- name: Cache Pod
if: matrix.cache_pod_key != null
uses: actions/cache@v3
with:
key: ${{ matrix.cache_pod_key }}
path: ${{ matrix.cache_pod_path }}
restore-keys: ${{ matrix.cache_key }}-${{ hashFiles(matrix.cache_pod_restore_keys_hash_file)}}
# Setup JDK
- name: Setup JDK 17 (Android)
if: matrix.target == 'Android'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
cache: gradle
# Xcodebuild
- name: Build Xcode
if: matrix.os == 'macos-latest'
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release
# Flutter Pub Get
- name: Flutter Pub Get
run: |
git config --global core.longpaths true
flutter pub get
# Get app version
- name: Get app version
id: get_version
shell: bash
run: |
echo "::set-output name=version::$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2)"
# Build Android .apk
- name: Build Android
if: matrix.target == 'Android'
run: |
flutter build apk -t lib/src/main.dart --release --split-per-abi
cd build/app/outputs/apk/release
mv app-arm64-v8a-release.apk JHenTai-${{ steps.get_version.outputs.version }}-arm64-v8a.apk
mv app-armeabi-v7a-release.apk JHenTai-${{ steps.get_version.outputs.version }}-armeabi-v7a.apk
mv app-x86_64-release.apk JHenTai-${{ steps.get_version.outputs.version }}-x86_64.apk
# Build iOS .ipa
- name: Build iOS
if: matrix.target == 'ios'
run: |
cd ios
pod update
cd ..
flutter build ios -t lib/src/main.dart --release --no-codesign
sh thin-payload.sh build/ios/iphoneos/*.app
cd build
mkdir -p Payload
mv ios/iphoneos/*.app Payload
zip -9 JHenTai_${{ steps.get_version.outputs.version }}.ipa -r Payload
# Build macOS .dmg
- name: Build macOS
if: matrix.target == 'macOS'
run: |
cd macos
pod update
cd ..
sh dmg.sh
# Build Windows .zip
- name: Build Windows
if: matrix.target == 'Windows'
run: |
flutter build windows -t lib/src/main.dart --release
$DestDir = "build\windows\JHenTai_${{ steps.get_version.outputs.version }}"
$SrcDir = "build\windows\x64\runner\Release"
New-Item -Path $DestDir -ItemType Directory
Copy-Item $SrcDir\* -Recurse $DestDir
Copy-Item -Filter *.dll -Path windows\* -Destination $DestDir -Force
Compress-Archive $DestDir build\windows\JHenTai_${{ steps.get_version.outputs.version }}_Windows.zip
# Build Linux .deb and .AppImage
- name: Build Linux
if: matrix.target == 'Linux'
run: |
# Prepare build depends
sudo apt-get update -y
sudo apt-get install -y ninja-build libfuse2 webkit2gtk-4.1
# Compile
flutter config --enable-linux-desktop
flutter build linux --release -t lib/src/main.dart
# Build debian package
mkdir -p build/linux/JHenTai-${{ steps.get_version.outputs.version }}-Linux-amd64
cd build/linux/JHenTai-${{ steps.get_version.outputs.version }}-Linux-amd64
mkdir -p opt/jhentai
mkdir -p usr/share/applications
mkdir -p usr/share/icons/hicolor/512x512/apps
cp -r ../x64/release/bundle/* opt/jhentai
cp -r ../../../linux/assets/DEBIAN .
chmod 0755 DEBIAN/postinst
chmod 0755 DEBIAN/postrm
cat>DEBIAN/control<<EOF
Maintainer: madoka773 <[email protected]>
Package: jhentai
Version: ${{ steps.get_version.outputs.version }}
Section: x11
Priority: optional
Architecture: amd64
Essential: no
Installed-Size: 34648
Description: A cross-platform app made for e-hentai & exhentai by Flutter.
Homepage: https://github.com/jiangtian616/JHenTai
EOF
cp ../../../linux/assets/top.jtmonster.jhentai.desktop usr/share/applications
cp ../../../assets/icon_512.png usr/share/icons/hicolor/512x512/apps/top.jtmonster.jhentai.png
cd ..
dpkg-deb --build --root-owner-group JHenTai-${{ steps.get_version.outputs.version }}-Linux-amd64
# Build AppImage
wget -O appimage-builder https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage
chmod +x appimage-builder
mkdir AppDir
cp -r x64/release/bundle/* AppDir
mkdir -p AppDir/usr/share/icons/hicolor/512x512/apps/
mkdir -p AppDir/usr/share/applications
cp ../../linux/assets/top.jtmonster.jhentai.desktop AppDir/usr/share/applications
cp ../../assets/icon_512.png AppDir/usr/share/icons/hicolor/512x512/apps/top.jtmonster.jhentai.png
./appimage-builder --skip-tests --recipe ../../linux/assets/AppImageBuilder.yml
mv JHenTai-latest-x86_64.AppImage JHenTai-${{ steps.get_version.outputs.version }}-Linux-x86_64.AppImage
# Upload Artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
Publish:
if: startsWith(github.ref, 'refs/tags/')
name: Publish
needs: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Make tmp dir
run: mkdir /tmp/artifacts
- name: Download all Artifacts
uses: actions/download-artifact@v3
with:
path: /tmp/artifacts
- name: List all Artifacts
run: ls -R /tmp/artifacts
- name: Upload to release
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
allowUpdates: true
bodyFile: changelog/${{ github.ref_name }}.md
artifacts: /tmp/artifacts/release-Android/*.apk,/tmp/artifacts/release-iOS/*.ipa,/tmp/artifacts/release-macOS/*.dmg,/tmp/artifacts/release-Windows/*.zip,/tmp/artifacts/release-Linux/*.AppImage,/tmp/artifacts/release-Linux/*.deb
artifactErrorsFailBuild: true
replacesArtifacts: true