-
Notifications
You must be signed in to change notification settings - Fork 87
145 lines (125 loc) · 4.61 KB
/
build.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
name: Build & Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- platform: android
os: ubuntu-latest
- platform: windows
os: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: 'main'
- name: Get version from pubspec.yaml
id: get_version
shell: bash
run: echo "VERSION=$( grep '^version:' pubspec.yaml | cut -d ' ' -f 2 | cut -d '+' -f 1 )" >> $GITHUB_ENV
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: '3.24.3'
- name: Get Dependencies
run: |
flutter --version
flutter pub get
- name: Setup Java
if: matrix.platform == 'android'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
check-latest: true
# - name: Setup for Windows
# if: matrix.platform == 'windows'
# uses: msys2/setup-msys2@v2
# with:
# msystem: mingw64
# install: mingw-w64-x86_64-gcc
# update: true
# - name: Set Mingw64 Env
# if: matrix.platform == 'windows'
# shell: bash
# run: |
# echo "${{ runner.temp }}\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# gcc -v
- name: Setup Android signing
if: matrix.platform == 'android'
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
echo "storeFile=keystore.jks" >> android/key.properties
- name: Prepare for platform
if: matrix.platform == 'windows'
shell: bash
run: |
flutter config --enable-windows-desktop
sed -i "1i #define MyAppVersion \"${{ env.VERSION }}\"" scripts/compile_windows_setup-inno.iss
- name: Build for Android
if: matrix.platform == 'android'
run: |
flutter gen-l10n
flutter build apk --release
flutter build apk --split-per-abi
shell: bash
- name: Install winget
if: matrix.platform == 'windows'
uses: Cyberboss/install-winget@v1
- name: Build for Windows
if: matrix.platform == 'windows'
shell: pwsh
run: ./scripts/build_windows.ps1
- name: Rename builds
run: |
cd build
if [ "${{ matrix.platform }}" == "android" ]; then
cd app/outputs/flutter-apk
mv app-armeabi-v7a-release.apk Anx-Reader-${{ matrix.platform }}-${{ env.VERSION }}-armeabi-v7a.apk
mv app-arm64-v8a-release.apk Anx-Reader-${{ matrix.platform }}-${{ env.VERSION }}-arm64-v8a.apk
mv app-x86_64-release.apk Anx-Reader-${{ matrix.platform }}-${{ env.VERSION }}-x86_64.apk
mv app-release.apk Anx-Reader-${{ matrix.platform }}-${{ env.VERSION }}-universal.apk
elif [ "${{ matrix.platform }}" == "windows" ]; then
mv windows/app.zip windows/Anx-Reader-${{ matrix.platform }}-${{ env.VERSION }}.zip
mv windows/app.exe windows/Anx-Reader-${{ matrix.platform }}-${{ env.VERSION }}.exe
fi
shell: bash
- name: Extract release notes
id: extract_release_notes
run: |
VERSION=${{ env.VERSION }}
CHANGELOG_CONTENT=$(sed -n "/## $VERSION/,/## /p" CHANGELOG.md | sed '$d')
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash
# - name: Upload artifacts
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.platform }}-artifacts
# path: |
# build/app/outputs/flutter-apk/*.apk
# build/windows/*.zip
# build/windows/*.exe
# if-no-files-found: warn
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
build/app/outputs/flutter-apk/*.apk
build/windows/*.zip
build/windows/*.exe
body: ${{ env.RELEASE_NOTES }}
generate_release_notes: false