File prepare_webassets.sh of Package kubectl-argo-rollouts
#!/bin/bash
# do not use set -e, as the make step will abort the build due to warnings/errors
set -o pipefail
cd /data
[[ "$#" == "2" ]] || {
echo "Please use the package name and the nodejs version as the only arguments"
exit 1
}
package_name="${1}"
nodejs_package="${2}"
zypper -n install \
cpio \
gawk \
make \
git-core \
yarn \
"${nodejs_package}"
version="$( awk '/^Version:/ {print $2;exit;}' "${package_name}.spec" )"
echo "##########"
echo "Package version is ${version}"
basename="${package_name}-${version}"
obscpio="${basename}.obscpio"
working_directory="$(pwd)"
tmpdir="$(mktemp -d -p /tmp)"
cd "${tmpdir}"
echo "##########"
echo "Extracting obscpio archive"
cpio -id < "${working_directory}/${obscpio}"
ls -lah
cd "${basename}" || exit 13
ls -lah
echo "##########"
yarn --cwd ui install
tar -czf "${working_directory}/ui-${version}.tar.gz" ui
echo "##########"
echo "DONE preparing the webassets"
rm -rf "${tmpdir}"