88# --build_type The type of package to build. Must be one of:
99# - all: Build all package types
1010# - zip: Build only zip package
11+ # - tar.xz: Build only tar.xz package
1112# - deb: Build only deb package
1213# - rpm: Build only rpm package
1314# - appimage: Build only appimage package
@@ -28,6 +29,7 @@ show_help() {
2829 echo " --build_type The type of package to build. Must be one of:"
2930 echo " - all: Build all package types"
3031 echo " - zip: Build only zip package"
32+ echo " - tar.xz: Build only tar.xz package"
3133 echo " - deb: Build only deb package"
3234 echo " - rpm: Build only rpm package"
3335 echo " Please install the \033[33mrpm-build\033[0m and \033[33mpatchelf\033[0m before building the rpm and appimage package."
@@ -80,34 +82,47 @@ while [ $# -gt 0 ]; do
8082 esac
8183done
8284
85+ clear_cache () {
86+ echo " Clearing the cache..."
87+ rm -rf appflowy_flutter/build/$VERSION /
88+ }
89+
90+ info () {
91+ echo " 🚀 \033[32m$1 \033[0m"
92+ }
93+
94+ error () {
95+ echo " 🚨 \033[31m$1 \033[0m"
96+ }
97+
8398# Validate build type argument
8499if [ -z " $BUILD_TYPE " ]; then
85- echo " Please specify build type with --build_type: zip, deb, rpm, appimage"
100+ error " Please specify build type with --build_type: all, zip, tar.xz , deb, rpm, appimage"
86101 exit 1
87102fi
88103
89104# Validate version argument
90105if [ -z " $VERSION " ]; then
91- echo " Please specify version number with --version (e.g. 0.8.2)"
106+ error " Please specify version number with --version (e.g. 0.8.2)"
92107 exit 1
93108fi
94109
95110# Validate build arch argument
96111if [ -z " $BUILD_ARCH " ]; then
97- echo " Please specify build arch with --build_arch: x86_64, arm64 or universal"
112+ error " Please specify build arch with --build_arch: x86_64, arm64 or universal"
98113 exit 1
99114fi
100115
101- if [ " $BUILD_TYPE " != " all" ] && [ " $BUILD_TYPE " != " zip" ] && [ " $BUILD_TYPE " != " deb" ] && [ " $BUILD_TYPE " != " rpm" ] && [ " $BUILD_TYPE " != " appimage" ]; then
102- echo " Invalid build type. Must be one of: zip, deb, rpm, appimage"
116+ if [ " $BUILD_TYPE " != " all" ] && [ " $BUILD_TYPE " != " zip" ] && [ " $BUILD_TYPE " != " tar.xz " ] && [ " $BUILD_TYPE " != " deb" ] && [ " $BUILD_TYPE " != " rpm" ] && [ " $BUILD_TYPE " != " appimage" ]; then
117+ error " Invalid build type. Must be one of: all, zip, tar.xz , deb, rpm, appimage"
103118 exit 1
104119fi
105120
106121has_built_core=false
107122has_generated_code=false
108123
109124prepare_build () {
110- echo " Preparing build..."
125+ info " Preparing build..."
111126
112127 # Build the rust-lib with version
113128 if [ " $SKIP_REBUILD_CORE " != " true" ] && [ " $has_built_core " != " true" ]; then
@@ -122,7 +137,7 @@ prepare_build() {
122137}
123138
124139build_zip () {
125- echo " Building zip package version $VERSION ..."
140+ info " Building zip package version $VERSION ..."
126141
127142 prepare_build
128143
@@ -131,11 +146,11 @@ build_zip() {
131146 cd ..
132147 mv appflowy_flutter/build/$VERSION /appflowy-$VERSION +$VERSION -linux.zip appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.zip
133148
134- echo " Zip package built successfully"
149+ info " Zip package built successfully. The zip package is located at appflowy_flutter/build/ $VERSION /AppFlowy- $VERSION -linux-x86_64.zip "
135150}
136151
137152build_deb () {
138- echo " Building deb package version $VERSION ..."
153+ info " Building deb package version $VERSION ..."
139154
140155 prepare_build
141156
@@ -144,11 +159,11 @@ build_deb() {
144159 cd ..
145160 mv appflowy_flutter/build/$VERSION /appflowy-$VERSION +$VERSION -linux.deb appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.deb
146161
147- echo " Deb package built successfully"
162+ info " Deb package built successfully. The deb package is located at appflowy_flutter/build/ $VERSION /AppFlowy- $VERSION -linux-x86_64.deb "
148163}
149164
150165build_rpm () {
151- echo " Building rpm package version $VERSION ..."
166+ info " Building rpm package version $VERSION ..."
152167
153168 prepare_build
154169
@@ -157,12 +172,12 @@ build_rpm() {
157172 cd ..
158173 mv appflowy_flutter/build/$VERSION /appflowy-$VERSION +$VERSION -linux.rpm appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.rpm
159174
160- echo " RPM package built successfully"
175+ info " RPM package built successfully. The RPM package is located at appflowy_flutter/build/ $VERSION /AppFlowy- $VERSION -linux-x86_64.rpm "
161176}
162177
163178# Function to build AppImage package
164179build_appimage () {
165- echo " Building AppImage package version $VERSION ..."
180+ info " Building AppImage package version $VERSION ..."
166181
167182 prepare_build
168183
@@ -171,15 +186,47 @@ build_appimage() {
171186 cd ..
172187 mv appflowy_flutter/build/$VERSION /appflowy-$VERSION +$VERSION -linux.AppImage appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.AppImage
173188
174- echo " AppImage package built successfully"
189+ info " AppImage package built successfully. The AppImage package is located at appflowy_flutter/build/ $VERSION /AppFlowy- $VERSION -linux-x86_64.AppImage "
175190}
176191
192+ build_tar_xz () {
193+ info " Building tar.xz package version $VERSION ..."
194+
195+ prepare_build
196+
197+ # step 1: check if the linux zip package is built, if not, build the zip package
198+ if [ ! -f " appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.zip" ]; then
199+ info " Linux zip package is not built. Building the zip package..."
200+ build_zip
201+ fi
202+
203+ # step 2: unzip the zip package
204+ unzip appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.zip -d appflowy_flutter/build/$VERSION /
205+
206+ # check if the AppFlowy directory exists
207+ if [ ! -d " appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64" ]; then
208+ error " AppFlowy directory doesn't exist. Please check the zip package."
209+ exit 1
210+ fi
211+
212+ # step 3: build the tar.xz package
213+ tar -cJvf appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.tar.xz -C appflowy_flutter/build/$VERSION / AppFlowy-$VERSION -linux-x86_64
214+
215+ # step 4: clean up the extracted directory
216+ rm -rf appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64
217+
218+ info " Tar.xz package built successfully. The tar.xz package is located at appflowy_flutter/build/$VERSION /AppFlowy-$VERSION -linux-x86_64.tar.xz"
219+ }
220+
221+ clear_cache
222+
177223# Build packages based on build type
178224case $BUILD_TYPE in
179225" all" )
180226 build_zip
181227 build_deb
182228 build_rpm
229+ build_tar_xz
183230 build_appimage
184231 ;;
185232" zip" )
@@ -194,4 +241,7 @@ case $BUILD_TYPE in
194241" appimage" )
195242 build_appimage
196243 ;;
244+ " tar.xz" )
245+ build_tar_xz
246+ ;;
197247esac
0 commit comments