Skip to content
Snippets Groups Projects

ci: Build workhorse binaries and upload/download as generic package

Compare and Show latest version
1 file
+ 31
26
Compare changes
  • Side-by-side
  • Inline
@@ -13,51 +13,56 @@ function gitlab_workhorse_archive_doesnt_exist() {
}
function create_gitlab_workhorse_archive() {
compress_gitlab_workhorse_archive
compress_or_decompress "compress"
tar -czvf ${GITLAB_WORKHORSE_ARCHIVE} -C ${TMP_TEST_FOLDER} ${GITLAB_WORKHORSE_FOLDER}
}
function compress_gitlab_workhorse_archive() {
cd $TMP_TEST_FOLDER
function compress_or_decompress() {
local action="${1}"
read -ra binaries <<< $(echo $GITLAB_WORKHORSE_BINARIES_LIST)
if [ -d "${TMP_TEST_GITLAB_WORKHOSE_FOLDER}" ]; then
cd $TMP_TEST_GITLAB_WORKHOSE_FOLDER
for binary in ${binaries[@]}; do
echoinfo "Size before compression: $(du -h ${binary})"
upx ${binary}
echoinfo "Size after compression: $(du -h ${binary})"
done
ls -l
cd -
}
function decompress_gitlab_workhorse_archive() {
cd $TMP_TEST_FOLDER
read -ra binaries <<< $(echo $GITLAB_WORKHORSE_BINARIES_LIST)
read -ra binaries <<< $(echo $GITLAB_WORKHORSE_BINARIES_LIST)
for binary in ${binaries[@]}; do
echoinfo "Size before decompression: $(du -h ${binary})"
upx -d ${binary}
echoinfo "Size after decompression: $(du -h ${binary})"
done
for binary in ${binaries[@]}; do
echoinfo "[BEFORE] Size of ${binary}: $(du -h ${binary})"
if [ "${action}" -eq "decompress" ]; then
upx -d ${binary}
else
upx ${binary}
fi
echoinfo "[AFTER] Size of ${binary}: $(du -h ${binary})"
done
cd -
cd -
else
exit 1
fi
}
function upload_gitlab_workhorse_package() {
echoinfo "Uploading to ${package_url} ..."
curl --fail --retry 3 --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ${GITLAB_WORKHORSE_ARCHIVE} ${GITLAB_WORKHORSE_PACKAGE_URL}
echoinfo "Uploading ${GITLAB_WORKHORSE_ARCHIVE} to ${GITLAB_WORKHORSE_PACKAGE_URL} ..."
curl --fail --silent --retry 3 --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${GITLAB_WORKHORSE_ARCHIVE}" "${GITLAB_WORKHORSE_PACKAGE_URL}"
}
function download_gitlab_workhorse_package() {
local output_file="${1}"
local extra_curl_args=""
if [ -n "${output_file}" ]; then
extra_curl_args=" -o \"${output_file}\""
fi
echoinfo "Downloading from ${GITLAB_WORKHORSE_PACKAGE_URL} ..."
mkdir -p ${TMP_TEST_GITLAB_WORKHOSE_FOLDER}
curl --fail --silent --retry 3 --header "JOB-TOKEN: $CI_JOB_TOKEN" ${GITLAB_WORKHORSE_PACKAGE_URL} -o ${GITLAB_WORKHORSE_ARCHIVE}
eval "curl --fail --silent --retry 3 --header \"JOB-TOKEN: ${CI_JOB_TOKEN}\" \"${GITLAB_WORKHORSE_PACKAGE_URL}\"${extra_curl_args}"
}
function download_and_extract_gitlab_workhorse_package() {
download_gitlab_workhorse_package | tar -xzv -C ${TMP_TEST_FOLDER} - | decompress_gitlab_workhorse_archive
download_gitlab_workhorse_package | tar -xzv -C ${TMP_TEST_FOLDER} - | compress_or_decompress "decompress"
}
function filter_gitlab_workhorse_binaries() {
Loading