1+ name : release
2+
3+ on :
4+ release :
5+ types : [published]
6+ paths :
7+ - " app/**"
8+ - " proto/**"
9+ - " server/**"
10+ - " .github/workflows/*.yml"
11+
12+ env :
13+ GO_VERSION : " 1.23"
14+ NODE_VERSION : " 20"
15+ FLUTTER_VERSION : " 3.24.5"
16+
17+ jobs :
18+ get-version :
19+ runs-on : ubuntu-22.04
20+ outputs :
21+ version : ${{ steps.get-version.outputs.version }}
22+
23+ steps :
24+ - name : Checkout
25+ uses : actions/checkout@v4
26+
27+ - name : Get version from pubspec.yaml
28+ id : get_version
29+ run : |
30+ VERSION=$(sed -n 's/^version: \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' app/pubspec.yaml)
31+ echo "version=$VERSION" >> $GITHUB_OUTPUT
32+
33+ build-macos-arm64-lib :
34+ needs :
35+ - get-version
36+ runs-on : macos-latest
37+ steps :
38+ - name : Checkout
39+ uses : actions/checkout@v4
40+
41+ - name : Setup Go
42+ uses : actions/setup-go@v4
43+ with :
44+ go-version : ${{ env.GO_VERSION }}
45+
46+ - name : Build dylib
47+ env :
48+ VERSION : ${{ needs.get-version.outputs.version }}
49+ run : |
50+ cd server
51+ go build -ldflags="-w -s -X github.com/honmaple/maple-file/server/internal/app.VERSION=$env:VERSION" -buildmode=c-shared -o libserver.dylib github.com/honmaple/maple-file/server/cmd/desktop
52+
53+ - name : Upload dylib
54+ uses : actions/upload-artifact@v4
55+ with :
56+ name : macos-arm64-lib
57+ path : server/libserver.dylib
58+
59+ build-macos :
60+ needs :
61+ - get-version
62+ - build-macos-arm64-lib
63+ runs-on : macos-13
64+ steps :
65+ - name : Checkout
66+ uses : actions/checkout@v4
67+
68+ - name : Setup Go
69+ uses : actions/setup-go@v4
70+ with :
71+ go-version : ${{ env.GO_VERSION }}
72+
73+ - name : Setup Flutter
74+ uses : subosito/flutter-action@v2
75+ with :
76+ flutter-version : ${{ env.FLUTTER_VERSION }}
77+
78+ - name : Setup NPM
79+ uses : actions/setup-node@v4
80+ with :
81+ node-version : ${{ env.NODE_VERSION }}
82+
83+ - name : Install appdmg
84+ run : |
85+ python3 -m pip install setuptools --break-system-packages
86+ npm install -g appdmg
87+
88+ - name : Download arm64 dylib
89+ uses : actions/download-artifact@v4
90+ with :
91+ name : macos-arm64-lib
92+ path : server/arm64
93+
94+ - name : Build amd64 dylib
95+ env :
96+ VERSION : ${{ needs.get-version.outputs.version }}
97+ run : |
98+ cd server
99+
100+ go build -ldflags="-w -s -X github.com/honmaple/maple-file/server/internal/app.VERSION=$env:VERSION" -buildmode=c-shared -o libserver.dylib github.com/honmaple/maple-file/server/cmd/desktop
101+
102+ - name : Create dylib
103+ run : |
104+ mkdir -p app/macos/Frameworks
105+ cp server/libserver.dylib $PROJECT_DIR/app/macos/Frameworks/amd64-lib
106+ cp server/arm64/libserver.dylib $PROJECT_DIR/app/macos/Frameworks/arm64-lib
107+
108+ cd app/macos/Frameworks
109+ lipo -create -output libserver.dylib amd64-lib arm64-lib
110+
111+ - name : Build dmg
112+ env :
113+ VERSION : ${{ needs.get-version.outputs.version }}
114+ run : |
115+ cd app
116+ flutter pub get
117+ dart run build_runner build
118+ flutter build macos
119+
120+ cd $PROJECT_DIR/app/build/macos/Build/Products/Release
121+ cat>appdmg.json<<EOF
122+ {
123+ "title": "maple_file",
124+ "icon": "maple_file.app/Contents/Resources/AppIcon.icns",
125+ "contents": [
126+ { "x": 448, "y": 344, "type": "link", "path": "/Applications" },
127+ { "x": 192, "y": 344, "type": "file", "path": "maple_file.app" }
128+ ]
129+ }
130+ EOF
131+
132+ mkdir dist
133+ appdmg appdmg.json dist/maple-file-$VERSION-macos.dmg
134+
135+ - name : Upload dmg file
136+ uses : actions/upload-artifact@v4
137+ with :
138+ name : macos-result
139+ path : app/build/macos/Build/Products/Release/dist/*.dmg
140+
141+ build-android :
142+ needs :
143+ - get-version
144+ runs-on : ubuntu-22.04
145+
146+ steps :
147+ - name : Checkout
148+ uses : actions/checkout@v4
149+
150+ - name : Setup Go
151+ uses : actions/setup-go@v4
152+ with :
153+ go-version : ${{ env.GO_VERSION }}
154+
155+ - name : Setup Java
156+ uses : actions/setup-java@v4
157+ with :
158+ distribution : ' temurin'
159+ java-version : ' 17'
160+
161+ - name : Setup Flutter
162+ uses : subosito/flutter-action@v2
163+ with :
164+ flutter-version : ${{ env.FLUTTER_VERSION }}
165+
166+ - name : Build Go aar
167+ env :
168+ VERSION : ${{ needs.get-version.outputs.version }}
169+ run : |
170+ mkdir app/android/app/libs
171+
172+ cd server
173+ go install golang.org/x/mobile/cmd/gomobile@latest
174+ go get golang.org/x/mobile/bind
175+ gomobile init
176+ gomobile bind -ldflags="-w -s -X github.com/honmaple/maple-file/server/internal/app.VERSION=$env:VERSION" -o ../app/android/app/libs/server.aar -target=android -androidapi 21 -javapkg="com.honmaple.maple_file" github.com/honmaple/maple-file/server/cmd/mobile
177+
178+ - name : Build APK
179+ env :
180+ VERSION : ${{ needs.get-version.outputs.version }}
181+ run : |
182+ cd app
183+ flutter pub get
184+ dart run build_runner build
185+ flutter build apk --no-tree-shake-icons --split-per-abi
186+
187+ cd build/app/outputs/flutter-apk
188+ mv app-x86_64-release.apk maple-file-$VERSION-android-x86_64.apk
189+ mv app-arm64-v8a-release.apk maple-file-$VERSION-android-arm64-v8a.apk
190+ mv app-armeabi-v7a-release.apk maple-file-$VERSION-android-armeabi-v7a.apk
191+
192+ - name : Upload APK
193+ uses : actions/upload-artifact@v4
194+ with :
195+ name : android-result
196+ path : |
197+ app/build/app/outputs/flutter-apk/maple-file-*.apk
198+
199+ release :
200+ needs :
201+ - build-macos
202+ - build_android
203+ runs-on : ubuntu-22.04
204+
205+ permissions :
206+ contents : write
207+
208+ steps :
209+ - name : Checkout
210+ uses : actions/checkout@v4
211+
212+ - name : Download dmg file
213+ uses : actions/download-artifact@v4
214+ with :
215+ name : macos-result
216+ path : macos-result
217+
218+ - name : Download apk file
219+ uses : actions/download-artifact@v4
220+ with :
221+ name : android-result
222+ path : android-result
223+
224+ - name : Release version
225+ uses : softprops/action-gh-release@v2
226+ if : github.event_name == 'release'
227+ with :
228+ files : |
229+ macos-result/*.dmg
230+ android-result/*.apk
231+ token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments