aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/build-unix.sh
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2022-04-23 12:05:13 +0100
committerLibravatar GitHub <noreply@github.com>2022-04-23 11:05:13 +0000
commit1c35622c66309984cecddd6892fe2060ef21a447 (patch)
tree27651692f01cbdd4e2b2b6be8a057524035e5a97 /scripts/build-unix.sh
parent6.0.0-nightly.9 [skip ci] (diff)
downloadferdium-app-1c35622c66309984cecddd6892fe2060ef21a447.tar.gz
ferdium-app-1c35622c66309984cecddd6892fe2060ef21a447.tar.zst
ferdium-app-1c35622c66309984cecddd6892fe2060ef21a447.zip
Update the build script for Windows (Powershell) and normalized with the unix equivalent [skip ci]
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'scripts/build-unix.sh')
-rwxr-xr-xscripts/build-unix.sh52
1 files changed, 37 insertions, 15 deletions
diff --git a/scripts/build-unix.sh b/scripts/build-unix.sh
index e80c38059..872219a8f 100755
--- a/scripts/build-unix.sh
+++ b/scripts/build-unix.sh
@@ -3,8 +3,8 @@
3# INTRO: 3# INTRO:
4# This file is used to build ferdium on both x64 and arm-based for macos and linux (not tested on arm for linux). 4# This file is used to build ferdium on both x64 and arm-based for macos and linux (not tested on arm for linux).
5# It also handles any corrupted node modules with the 'CLEAN' env var (set it to 'true' for cleaning) 5# It also handles any corrupted node modules with the 'CLEAN' env var (set it to 'true' for cleaning)
6# It will install the system dependencies except for node (which is still verified) 6# It will install the system dependencies except for node and python (which are still verified)
7# I sometimes symlink my 'recipes' folder so that any changes that I need to do in it can also be committed and pushed 7# I sometimes symlink my 'recipes' folder so that any changes that I need to do in it can also be committed and pushed independently
8# This file can live anywhere in your PATH 8# This file can live anywhere in your PATH
9 9
10set -e 10set -e
@@ -30,10 +30,12 @@ command_exists() {
30 30
31# ----------------------------------------------------------------------------- 31# -----------------------------------------------------------------------------
32# Checking the developer environment 32# Checking the developer environment
33# checking for installed programmes 33# Check for installed programmes
34command_exists node || fail_with_docs "Node is not installed" 34command_exists node || fail_with_docs "Node is not installed"
35command_exists jq || fail_with_docs "jq is not installed" 35command_exists jq || fail_with_docs "jq is not installed"
36command_exists python || fail_with_docs "python is not installed"
36 37
38# Check node version
37EXPECTED_NODE_VERSION=$(cat .nvmrc) 39EXPECTED_NODE_VERSION=$(cat .nvmrc)
38ACTUAL_NODE_VERSION=$(node -v) 40ACTUAL_NODE_VERSION=$(node -v)
39if [ "v$EXPECTED_NODE_VERSION" != "$ACTUAL_NODE_VERSION" ]; then 41if [ "v$EXPECTED_NODE_VERSION" != "$ACTUAL_NODE_VERSION" ]; then
@@ -73,23 +75,40 @@ else
73fi 75fi
74 76
75# ----------------------------------------------------------------------------- 77# -----------------------------------------------------------------------------
76printf "\n*************** Installing node dependencies ***************\n" 78# Ensure that the system dependencies are at the correct version - fail if not
79# Check python version
80EXPECTED_PYTHON_VERSION="3.10.4"
81ACTUAL_PYTHON_VERSION=$(python --version | sed -e "s/Python //")
82if [[ "$ACTUAL_PYTHON_VERSION" != "$EXPECTED_PYTHON_VERSION" ]]; then
83 fail_with_docs "You are not running the expected version of Python!
84 expected: [$EXPECTED_PYTHON_VERSION]
85 actual : [$ACTUAL_PYTHON_VERSION]"
86fi
87
88# -----------------------------------------------------------------------------
89# Ensure that the system dependencies are at the correct version - recover if not
77# If 'asdf' is installed, reshim for new nodejs if necessary 90# If 'asdf' is installed, reshim for new nodejs if necessary
78command_exists asdf && asdf reshim nodejs 91command_exists asdf && asdf reshim nodejs
79 92
80# Ensure that the system dependencies are at the correct version 93# Ensure that the system dependencies are at the correct version
81EXPECTED_NPM_VERSION=$(jq --raw-output .engines.npm <"package.json") 94# Check npm version
82EXPECTED_PNPM_VERSION=$(jq --raw-output .engines.pnpm <"./recipes/package.json") 95EXPECTED_NPM_VERSION=$(jq --raw-output .engines.npm ./package.json)
83if [[ "$(npm --version)" != "$EXPECTED_NPM_VERSION" ]]; then 96ACTUAL_NPM_VERSION=$(npm --version)
84 npm i -gf "npm@$EXPECTED_NPM_VERSION" 97if [[ "$ACTUAL_NPM_VERSION" != "$EXPECTED_NPM_VERSION" ]]; then
98 npm i -gf npm@$EXPECTED_NPM_VERSION
85fi 99fi
86if [[ "$(pnpm --version)" != "$EXPECTED_PNPM_VERSION" ]]; then 100
87 npm i -gf "pnpm@$EXPECTED_PNPM_VERSION" 101# Check pnpm version
102EXPECTED_PNPM_VERSION=$(jq --raw-output .engines.pnpm ./recipes/package.json)
103ACTUAL_PNPM_VERSION=$(pnpm --version)
104if [[ "$ACTUAL_PNPM_VERSION" != "$EXPECTED_PNPM_VERSION" ]]; then
105 npm i -gf pnpm@$EXPECTED_PNPM_VERSION
88fi 106fi
89 107
90# If 'asdf' is installed, reshim for new nodejs if necessary 108# If 'asdf' is installed, reshim for new nodejs if necessary
91command_exists asdf && asdf reshim nodejs 109command_exists asdf && asdf reshim nodejs
92 110
111# -----------------------------------------------------------------------------
93# This is useful if we move from 'npm' to 'pnpm' for the main repo as well 112# This is useful if we move from 'npm' to 'pnpm' for the main repo as well
94if [[ -s 'pnpm-lock.yaml' ]]; then 113if [[ -s 'pnpm-lock.yaml' ]]; then
95 BASE_CMD=pnpm 114 BASE_CMD=pnpm
@@ -123,13 +142,16 @@ else
123 TARGET_OS="linux" 142 TARGET_OS="linux"
124fi 143fi
125 144
126$BASE_CMD run build -- "--$TARGET_ARCH" --"$TARGET_OS" --dir 145$BASE_CMD run build -- --$TARGET_ARCH --$TARGET_OS --dir
127 146
128printf "\n*************** App successfully built! ***************\n" 147printf "\n*************** App successfully built! ***************\n"
148
129# Final check to ensure that the version built is the same as the latest commit 149# Final check to ensure that the version built is the same as the latest commit
130cat build/buildInfo.json 150VERSION_BUILT_HASH=$(jq --raw-output .gitHashShort ./build/buildInfo.json)
131git --no-pager log -1 151GIT_BUILT_HASH=$(git rev-parse --short HEAD)
132if [[ $(git rev-parse --short HEAD) != $(jq --raw-output .gitHashShort <"build/buildInfo.json") ]]; then 152if [[ $GIT_BUILT_HASH != $VERSION_BUILT_HASH ]]; then
133 echo "The built version is not on the latest commit" 153 echo "The built version is not on the latest commit
154 latest commit : [$GIT_BUILT_HASH]
155 actual build : [$VERSION_BUILT_HASH]"
134 exit 1 156 exit 1
135fi 157fi