Skip to content

Commit 7a2db83

Browse files
committed
chore: add linux build script
1 parent 971592e commit 7a2db83

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed

frontend/appflowy_flutter/distribute_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ releases:
1414
package:
1515
platform: linux
1616
target: appimage
17+
- name: release-prod-linux-zip
18+
package:
19+
platform: linux
20+
target: zip
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# This Script is used to build the AppFlowy Linux zip, deb, rpm and AppImage.
2+
#
3+
# Usage: sudo ./build_linux.sh [-h] <build_type> <version>
4+
#
5+
# Options:
6+
# -h Show this help message and exit
7+
#
8+
# Usage: sudo ./scripts/flutter_release_build/build_linux.sh <build_type> <version>
9+
#
10+
# Arguments:
11+
# build_type The type of package to build. Must be one of:
12+
# - all: Build all package types
13+
# - zip: Build only zip package
14+
# - deb: Build only deb package
15+
# - rpm: Build only rpm package
16+
# - appimage: Build only AppImage package
17+
# version The version number (e.g. 0.8.2)
18+
19+
show_help() {
20+
echo "Usage: sudo ./scripts/flutter_release_build/build_linux.sh [-h] <build_type> <version>"
21+
echo ""
22+
echo "Options:"
23+
echo " -h Show this help message and exit"
24+
echo ""
25+
echo "Arguments:"
26+
echo " build_type The type of package to build. Must be one of:"
27+
echo " - all: Build all package types"
28+
echo " - zip: Build only zip package"
29+
echo " - deb: Build only deb package"
30+
echo " - rpm: Build only rpm package"
31+
echo " - appimage: Build only AppImage package"
32+
echo " version The version number (e.g. 0.8.2)"
33+
exit 0
34+
}
35+
36+
# Check for help flag
37+
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
38+
show_help
39+
fi
40+
41+
# Check if the script is run with sudo
42+
if [ "$EUID" -ne 0 ]; then
43+
echo "Please run the script with sudo"
44+
exit 1
45+
fi
46+
47+
# Get the build type and version from command line arguments
48+
BUILD_TYPE=$1
49+
VERSION=$2
50+
51+
# Validate build type argument
52+
if [ -z "$BUILD_TYPE" ]; then
53+
echo "Please specify build type: all, zip, deb, rpm or appimage"
54+
exit 1
55+
fi
56+
57+
# Validate version argument
58+
if [ -z "$VERSION" ]; then
59+
echo "Please specify version number (e.g. 0.8.2)"
60+
exit 1
61+
fi
62+
63+
if [ "$BUILD_TYPE" != "all" ] && [ "$BUILD_TYPE" != "zip" ] && [ "$BUILD_TYPE" != "deb" ] && [ "$BUILD_TYPE" != "rpm" ] && [ "$BUILD_TYPE" != "appimage" ]; then
64+
echo "Invalid build type. Must be one of: all, zip, deb, rpm or appimage"
65+
exit 1
66+
fi
67+
68+
prepare_build() {
69+
echo "Preparing build..."
70+
71+
# Build the rust-lib with version
72+
cargo make --env APP_VERSION=$VERSION --profile production-linux-x86_64 appflowy-core-release
73+
cargo make --env APP_VERSION=$VERSION --profile production-linux-x86_64 code_generation
74+
}
75+
76+
build_zip() {
77+
echo "Building zip package version $VERSION..."
78+
79+
prepare_build
80+
81+
cd appflowy_flutter
82+
flutter_distributor release --name=prod --jobs=release-prod-linux-zip --skip-clean
83+
cd ..
84+
mv appflowy_flutter/build/$VERSION/appflowy-$VERSION+$VERSION-linux.zip appflowy_flutter/build/$VERSION/appflowy-$VERSION-linux-x86_64.zip
85+
86+
echo "Zip package built successfully"
87+
}
88+
89+
build_deb() {
90+
echo "Building deb package version $VERSION..."
91+
92+
prepare_build
93+
94+
cd appflowy_flutter
95+
flutter_distributor release --name=prod --jobs=release-prod-linux-deb --skip-clean
96+
cd ..
97+
mv appflowy_flutter/build/$VERSION/appflowy-$VERSION+$VERSION-linux.deb appflowy_flutter/build/$VERSION/appflowy-$VERSION-linux-x86_64.deb
98+
99+
echo "Deb package built successfully"
100+
}
101+
102+
build_rpm() {
103+
echo "Building rpm package version $VERSION..."
104+
105+
prepare_build
106+
107+
cd appflowy_flutter
108+
flutter_distributor release --name=prod --jobs=release-prod-linux-rpm --skip-clean
109+
cd ..
110+
mv appflowy_flutter/build/$VERSION/appflowy-$VERSION+$VERSION-linux.rpm appflowy_flutter/build/$VERSION/appflowy-$VERSION-linux-x86_64.rpm
111+
112+
echo "RPM package built successfully"
113+
}
114+
115+
# Function to build AppImage package
116+
build_appimage() {
117+
echo "Building AppImage package version $VERSION..."
118+
119+
prepare_build
120+
121+
cd appflowy_flutter
122+
flutter_distributor release --name=prod --jobs=release-prod-linux-appimage --skip-clean
123+
cd ..
124+
mv appflowy_flutter/build/$VERSION/appflowy-$VERSION+$VERSION-linux.AppImage appflowy_flutter/build/$VERSION/appflowy-$VERSION-linux-x86_64.AppImage
125+
126+
echo "AppImage package built successfully"
127+
}
128+
129+
# Build packages based on build type
130+
case $BUILD_TYPE in
131+
"all")
132+
build_zip
133+
build_deb
134+
build_rpm
135+
build_appimage
136+
;;
137+
"zip")
138+
build_zip
139+
;;
140+
"deb")
141+
build_deb
142+
;;
143+
"rpm")
144+
build_rpm
145+
;;
146+
"appimage")
147+
build_appimage
148+
;;
149+
esac

0 commit comments

Comments
 (0)