Skip to content

Commit

Permalink
Properly handle errors in linux and windows. Disable publish during p…
Browse files Browse the repository at this point in the history
…ackaging
  • Loading branch information
tangb committed Feb 5, 2022
1 parent 03fbea3 commit dde26fe
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cleep-desktop",
"version": "0.1.5",
"version": "0.1.6",
"description": "Desktop application to manage your Cleep devices",
"main": "main.js",
"scripts": {
Expand Down
24 changes: 23 additions & 1 deletion scripts/build-linux64.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/bin/bash

# Check command result
# $1: command result (usually $?)
# $2: awaited command result
# $3: error message
checkResult() {
if [ $1 -ne $2 ]
then
msg=$3
if [[ -z "$1" ]]; then
msg="see output log"
fi
echo -e "${RED}Error occured: $msg.${NOCOLOR}"
exit 1
fi
}

# env
CLEEPDESKTOPPATH=packaging/cleepdesktop_tree

Expand All @@ -16,8 +32,10 @@ echo
echo "Packaging cleepdesktopcore..."
echo "-----------------------------"
python3 -m pip install -r requirements.txt
checkResult $? 0 "Failed to install python dependencies"
cp config/cleepdesktopcore-linux64.spec cleepdesktopcore-linux64.spec
python3 -m PyInstaller --workpath packaging --clean --noconfirm --noupx --debug all --log-level INFO cleepdesktopcore-linux64.spec
checkResult $? 0 "Failed to build core application"
rm cleepdesktopcore-linux64.spec
echo "Generated files:"
ls -l dist/cleepdesktopcore
Expand All @@ -29,7 +47,9 @@ echo
echo "Building electron app..."
echo "------------------------"
npm ci
checkResult $? 0 "Failed to run npm"
node_modules/.bin/tsc --outDir "$CLEEPDESKTOPPATH"
checkResult $? 0 "Failed to build electron application"
echo "Done"

# copy files and dirs
Expand All @@ -52,10 +72,12 @@ then
echo "Publishing cleepdesktop..."
echo "--------------------------"
GH_TOKEN=$GH_TOKEN_CLEEPDESKTOP node_modules/.bin/electron-builder --linux --x64 --projectDir "$CLEEPDESKTOPPATH" --publish always
checkResult $? 0 "Failed to publish cleepdesktop"
else
echo "Packaging cleepdesktop..."
echo "-------------------------"
node_modules/.bin/electron-builder --linux --x64 --projectDir "$CLEEPDESKTOPPATH"
node_modules/.bin/electron-builder --linux --x64 --projectDir "$CLEEPDESKTOPPATH" --publish never
checkResult $? 0 "Failed to package cleepdesktop"
fi

# cleaning
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-mac64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ echo "Done"

# electron-builder
echo
echo "DEBUG cmd param \"$1\""
echo
if [ "$1" == "publish" ]
then
echo "Publishing cleepdesktop..."
Expand All @@ -74,7 +74,7 @@ then
else
echo "Packaging cleepdesktop..."
echo "-------------------------"
node_modules/.bin/electron-builder --mac --x64 --projectDir "$CLEEPDESKTOPPATH"
node_modules/.bin/electron-builder --mac --x64 --projectDir "$CLEEPDESKTOPPATH" --publish never
checkResult $? 0 "Failed to package cleepdesktop"
fi

Expand Down
13 changes: 11 additions & 2 deletions scripts/build-windows64.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ echo.
echo Packaging cleepdesktopcore...
echo -----------------------------
py -3 -m pip install -r ./requirements.txt
if %ERRORLEVEL% NEQ 0 goto :error
py -3 -m pip freeze
xcopy /q /y config\cleepdesktopcore-windows64.spec .
py -3 -m PyInstaller --workpath packaging --clean --noconfirm --noupx --windowed --debug all --log-level INFO cleepdesktopcore-windows64.spec
if %ERRORLEVEL% NEQ 0 goto :error
del /q cleepdesktopcore-windows64.spec
echo Generated files:
dir dist\cleepdesktopcore
Expand All @@ -40,7 +42,9 @@ echo.
echo Building electron app...
echo ------------------------
call npm ci
if %ERRORLEVEL% NEQ 0 goto :error
cmd /C "node_modules\.bin\tsc --outDir %CLEEPDESKTOPPATH%"
if %ERRORLEVEL% NEQ 0 goto :error
echo Done

:: copy files and dirs
Expand Down Expand Up @@ -68,10 +72,12 @@ if "%1" == "publish" (
echo --------------------------
set "GH_TOKEN=%GH_TOKEN_CLEEPDESKTOP%"
cmd /C "node_modules\.bin\electron-builder --windows --x64 --projectDir %CLEEPDESKTOPPATH% --publish always"
if %ERRORLEVEL% NEQ 0 goto :error
) else (
echo Packaging cleepdesktop...
echo -------------------------
cmd /C "node_modules\.bin\electron-builder --windows --x64 --projectDir %CLEEPDESKTOPPATH%"
cmd /C "node_modules\.bin\electron-builder --windows --x64 --projectDir %CLEEPDESKTOPPATH% --publish never"
if %ERRORLEVEL% NEQ 0 goto :error
)

:: finalizing moving generated stuff to dist directory and removing temp stuff
Expand All @@ -92,4 +98,7 @@ rmdir /Q /S core\modules\__pycache__
echo Done

echo.
echo Build result in dist/ folder
echo Build result in dist/ folder

:error
echo ===== Error occured see above =====

0 comments on commit dde26fe

Please sign in to comment.