Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix strip on non-x86 targets #9

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ error() {
echo "::error::$*"
}

warn() {
echo "::warning::$*"
}

if [[ "${GITHUB_REF:?}" != "refs/tags/"* ]]; then
error "GITHUB_REF should start with 'refs/tags/'"
exit 1
Expand Down Expand Up @@ -46,11 +50,9 @@ fi
case "${OSTYPE}" in
linux*)
platform="unix"
strip="strip"
;;
darwin*)
platform="unix"
strip="strip"
# Work around https://github.com/actions/cache/issues/403 by using GNU tar
# instead of BSD tar.
brew install gnu-tar &>/dev/null
Expand All @@ -65,6 +67,35 @@ case "${OSTYPE}" in
exit 1
;;
esac

strip=""
case "${target}" in
*-pc-windows-msvc) ;;
x86_64-* | i686-*)
strip="strip"
;;
arm*-linux-*eabi)
strip="arm-linux-gnueabi-strip"
;;
arm*-linux-*eabihf | thumb*-linux-*eabihf)
strip="arm-linux-gnueabihf-strip"
;;
arm*-none-eabi | thumb*-none-eabi)
strip="arm-none-eabi-strip"
;;
aarch64*-linux-*)
strip="aarch64-linux-gnu-strip"
;;
*) ;;
esac
if [[ -n "${strip:-}" ]]; then
# shellcheck disable=SC2230 # https://github.com/koalaman/shellcheck/issues/1162
if ! which "$strip" &>/dev/null; then
warn "$strip not found, skip stripping"
strip=""
fi
fi

bin="${package}${exe:-}"

build_options=("--bin" "${package}" "--release" "--target" "${target}")
Expand All @@ -80,7 +111,7 @@ archive="${archive/\$target/${target}}"
archive="${archive/\$tag/${tag}}"
assets=()
if [[ -n "${strip:-}" ]]; then
strip "${bin}"
$strip "${bin}"
fi
if [[ "${INPUT_TAR/all/${platform}}" == "${platform}" ]]; then
assets+=("${archive}.tar.gz")
Expand Down