diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2022-04-23 12:05:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-23 11:05:13 +0000 |
commit | 1c35622c66309984cecddd6892fe2060ef21a447 (patch) | |
tree | 27651692f01cbdd4e2b2b6be8a057524035e5a97 /scripts/build-unix.sh | |
parent | 6.0.0-nightly.9 [skip ci] (diff) | |
download | ferdium-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-x | scripts/build-unix.sh | 52 |
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 | ||
10 | set -e | 10 | set -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 |
34 | command_exists node || fail_with_docs "Node is not installed" | 34 | command_exists node || fail_with_docs "Node is not installed" |
35 | command_exists jq || fail_with_docs "jq is not installed" | 35 | command_exists jq || fail_with_docs "jq is not installed" |
36 | command_exists python || fail_with_docs "python is not installed" | ||
36 | 37 | ||
38 | # Check node version | ||
37 | EXPECTED_NODE_VERSION=$(cat .nvmrc) | 39 | EXPECTED_NODE_VERSION=$(cat .nvmrc) |
38 | ACTUAL_NODE_VERSION=$(node -v) | 40 | ACTUAL_NODE_VERSION=$(node -v) |
39 | if [ "v$EXPECTED_NODE_VERSION" != "$ACTUAL_NODE_VERSION" ]; then | 41 | if [ "v$EXPECTED_NODE_VERSION" != "$ACTUAL_NODE_VERSION" ]; then |
@@ -73,23 +75,40 @@ else | |||
73 | fi | 75 | fi |
74 | 76 | ||
75 | # ----------------------------------------------------------------------------- | 77 | # ----------------------------------------------------------------------------- |
76 | printf "\n*************** Installing node dependencies ***************\n" | 78 | # Ensure that the system dependencies are at the correct version - fail if not |
79 | # Check python version | ||
80 | EXPECTED_PYTHON_VERSION="3.10.4" | ||
81 | ACTUAL_PYTHON_VERSION=$(python --version | sed -e "s/Python //") | ||
82 | if [[ "$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]" | ||
86 | fi | ||
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 |
78 | command_exists asdf && asdf reshim nodejs | 91 | command_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 |
81 | EXPECTED_NPM_VERSION=$(jq --raw-output .engines.npm <"package.json") | 94 | # Check npm version |
82 | EXPECTED_PNPM_VERSION=$(jq --raw-output .engines.pnpm <"./recipes/package.json") | 95 | EXPECTED_NPM_VERSION=$(jq --raw-output .engines.npm ./package.json) |
83 | if [[ "$(npm --version)" != "$EXPECTED_NPM_VERSION" ]]; then | 96 | ACTUAL_NPM_VERSION=$(npm --version) |
84 | npm i -gf "npm@$EXPECTED_NPM_VERSION" | 97 | if [[ "$ACTUAL_NPM_VERSION" != "$EXPECTED_NPM_VERSION" ]]; then |
98 | npm i -gf npm@$EXPECTED_NPM_VERSION | ||
85 | fi | 99 | fi |
86 | if [[ "$(pnpm --version)" != "$EXPECTED_PNPM_VERSION" ]]; then | 100 | |
87 | npm i -gf "pnpm@$EXPECTED_PNPM_VERSION" | 101 | # Check pnpm version |
102 | EXPECTED_PNPM_VERSION=$(jq --raw-output .engines.pnpm ./recipes/package.json) | ||
103 | ACTUAL_PNPM_VERSION=$(pnpm --version) | ||
104 | if [[ "$ACTUAL_PNPM_VERSION" != "$EXPECTED_PNPM_VERSION" ]]; then | ||
105 | npm i -gf pnpm@$EXPECTED_PNPM_VERSION | ||
88 | fi | 106 | fi |
89 | 107 | ||
90 | # If 'asdf' is installed, reshim for new nodejs if necessary | 108 | # If 'asdf' is installed, reshim for new nodejs if necessary |
91 | command_exists asdf && asdf reshim nodejs | 109 | command_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 |
94 | if [[ -s 'pnpm-lock.yaml' ]]; then | 113 | if [[ -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" |
124 | fi | 143 | fi |
125 | 144 | ||
126 | $BASE_CMD run build -- "--$TARGET_ARCH" --"$TARGET_OS" --dir | 145 | $BASE_CMD run build -- --$TARGET_ARCH --$TARGET_OS --dir |
127 | 146 | ||
128 | printf "\n*************** App successfully built! ***************\n" | 147 | printf "\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 |
130 | cat build/buildInfo.json | 150 | VERSION_BUILT_HASH=$(jq --raw-output .gitHashShort ./build/buildInfo.json) |
131 | git --no-pager log -1 | 151 | GIT_BUILT_HASH=$(git rev-parse --short HEAD) |
132 | if [[ $(git rev-parse --short HEAD) != $(jq --raw-output .gitHashShort <"build/buildInfo.json") ]]; then | 152 | if [[ $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 |
135 | fi | 157 | fi |