From ebc0a8c77261312b281f9ac56c6f1eb0d59d99ca Mon Sep 17 00:00:00 2001 From: Dmitry Salakhov Date: Mon, 4 Jul 2022 10:43:11 +1200 Subject: [PATCH] fix: update build scripts for mac (#7104) --- build/download_helm_binary.sh | 11 ++++------- build/download_kompose_binary.sh | 4 ++++ gruntfile.js | 16 +++++++++++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/build/download_helm_binary.sh b/build/download_helm_binary.sh index 1b21bc5d1..b464918c8 100755 --- a/build/download_helm_binary.sh +++ b/build/download_helm_binary.sh @@ -11,14 +11,11 @@ ARCH=$2 HELM_VERSION=$3 HELM_DIST="helm-$HELM_VERSION-$PLATFORM-$ARCH" -if [[ ${PLATFORM} == "linux" ]]; then + +if [[ ${PLATFORM} == "windows" ]]; then + wget -O tmp.zip "https://get.helm.sh/${HELM_DIST}.zip" && unzip -o -j tmp.zip "${PLATFORM}-${ARCH}/helm.exe" -d dist && rm -f tmp.zip +else wget -qO- "https://get.helm.sh/${HELM_DIST}.tar.gz" | tar -x -z --strip-components 1 "${PLATFORM}-${ARCH}/helm" mv "helm" "dist/helm" chmod +x "dist/helm" -elif [[ ${PLATFORM} == "darwin" ]]; then - wget -qO- "https://get.helm.sh/helm-canary-darwin-amd64.tar.gz" | tar -x -z --strip-components 1 "darwin-amd64/helm" - mv "helm" "dist/helm" - chmod +x "dist/helm" -elif [[ ${PLATFORM} == "windows" ]]; then - wget -O tmp.zip "https://get.helm.sh/${HELM_DIST}.zip" && unzip -o -j tmp.zip "${PLATFORM}-${ARCH}/helm.exe" -d dist && rm -f tmp.zip fi diff --git a/build/download_kompose_binary.sh b/build/download_kompose_binary.sh index 84bb74faa..6369bfec1 100755 --- a/build/download_kompose_binary.sh +++ b/build/download_kompose_binary.sh @@ -14,6 +14,10 @@ KOMPOSE_VERSION=$3 if [[ ${PLATFORM} == "windows" ]]; then wget -O "dist/kompose.exe" "https://github.com/kubernetes/kompose/releases/download/${KOMPOSE_VERSION}/kompose-windows-amd64.exe" chmod +x "dist/kompose.exe" +elif [[ ${PLATFORM} == "darwin" ]]; then + # kompose 1.22 doesn't have arm support yet, we could merge darwin and linux scripts after upgrading kompose to >= 1.26.0 + wget -O "dist/kompose" "https://github.com/kubernetes/kompose/releases/download/${KOMPOSE_VERSION}/kompose-${PLATFORM}-amd64" + chmod +x "dist/kompose" else wget -O "dist/kompose" "https://github.com/kubernetes/kompose/releases/download/${KOMPOSE_VERSION}/kompose-${PLATFORM}-${ARCH}" chmod +x "dist/kompose" diff --git a/gruntfile.js b/gruntfile.js index 2b14f19d5..de2d2a73b 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -8,6 +8,14 @@ let arch = os.arch(); if (arch === 'x64') { arch = 'amd64'; } +let platform = os.platform(); +switch (platform) { + case 'windows': + case 'darwin': + break; + default: + platform = 'linux'; +} module.exports = function (grunt) { loadGruntTasks(grunt, { @@ -32,15 +40,17 @@ module.exports = function (grunt) { grunt.registerTask('lint', ['eslint']); - grunt.registerTask('build:server', [`shell:build_binary:linux:${arch}`, `download_binaries:linux:${arch}`]); + grunt.task.registerTask('build:server', 'build:server::', function (p = platform, a = arch) { + grunt.task.run([`shell:build_binary:${p}:${a}`, `download_binaries:${p}:${a}`]); + }); grunt.registerTask('build:client', ['webpack:dev']); grunt.registerTask('build', ['build:server', 'build:client']); - grunt.registerTask('start:server', ['build:server', 'shell:run_container']); + grunt.registerTask('start:server', ['build:server:linux', 'shell:run_container']); - grunt.registerTask('start:localserver', [`shell:build_binary:linux:${arch}`, 'shell:run_localserver']); + grunt.registerTask('start:localserver', [`shell:build_binary:${platform}:${arch}`, 'shell:run_localserver']); grunt.registerTask('start:client', ['shell:install_yarndeps', 'webpack:devWatch']);