Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
Signed-off-by: danCrespo <117232080+danCrespo@users.noreply.github.com>
  • Loading branch information
danCrespo committed Sep 14, 2023
1 parent fc22f8e commit 8f86ffb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/go_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,7 @@ jobs:
create_relase
fi
apt-get install -y zip
cd ${{ steps.download.outputs.download-path }}
recurse_dir
27 changes: 22 additions & 5 deletions build-package
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,29 @@ build_binary() {

export GOOS="${platform_split[0]}"
export GOARCH="${platform_split[1]}"
compressed_filename="${programName}-${GOOS}-${GOARCH}"

if ! go build -o "${output_path}/${programName}" -buildmode=exe "${dir}"; then
if [[ "${GOOS}" == windows ]]; then
programName+=".exe"
compressed_filename+=".zip"

else
compressed_filename=+".tar.gz"
fi

if ! go build -o "${output_path}/${programName}" "${dir}"; then
echo -e "An error has occurred!. Aborting programm"
exit 1

else
cd "${output_path}" \
&& tar -czvf "${programName}-${GOOS}-${GOARCH}.tar.gz" "${programName}"
cd "${output_path}" || exit 0

if [[ "${GOOS}" == windows ]]; then
zip -rq "${compressed_filename}".zip "${programName}"

else
tar -czvf "${compressed_filename}" "${programName}"
fi

rm -f "${programName}"
cd "${OLDPWD}" || true
Expand Down Expand Up @@ -86,12 +101,14 @@ get_last_release() {
}

upload_release_asset() {
mime=$1

curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/gzip" \
-H "Content-Type: ${mime:='application/gzip'}" \
"https://uploads.github.com/repos/${REPOSITORY}/releases/${release_id}/assets?name=${BINARY}" \
--data-binary "@${BINARY}" 2>/dev/null >&1
}
Expand All @@ -105,7 +122,7 @@ recurse_dir() {
if [[ "${mime_type}" == *"${zip}"* ]]; then
echo "${document}"
export BINARY="${document}"
upload_release_asset
upload_release_asset "${mime_type}"
fi

fi
Expand Down

0 comments on commit 8f86ffb

Please sign in to comment.