diff --git a/package.sh b/package.sh index 4d3ba5f..2d4dce5 100644 --- a/package.sh +++ b/package.sh @@ -1,55 +1,59 @@ #!/bin/bash - APP_NAME=$(git remote -v | tail -1 | sed 's|.*/\([^/]*\)\.git.*|\1|') -VERSION="$1" +VERSION="${1}" RELEASE_DIR_RELATIVE="bin/Release" PUBLISH_DIR_RELATIVE="${RELEASE_DIR_RELATIVE}/publish-script-output" -RELEASE_DIR="$(pwd)/$RELEASE_DIR_RELATIVE" -PUBLISH_DIR="$(pwd)/$PUBLISH_DIR_RELATIVE" +RELEASE_DIR="$(pwd)/${RELEASE_DIR_RELATIVE}" +PUBLISH_DIR="$(pwd)/${PUBLISH_DIR_RELATIVE}" -if [ -z "$VERSION" ]; then +if [ -z "${VERSION}" ]; then echo "ERROR: Please specify a version" exit 1 fi function package { - ARCH="$1" - - OUTPUT_DIR="$PUBLISH_DIR/$ARCH" - OUTPUT_FILE="$RELEASE_DIR/${APP_NAME}_${VERSION}_${ARCH}.zip" + local ARCH="${1}" + local OUTPUT_DIR="${PUBLISH_DIR}/${ARCH}" + local OUTPUT_FILE="${RELEASE_DIR}/${APP_NAME}_${VERSION}_${ARCH}.zip" - echo "Packaging \"$OUTPUT_DIR\" to \"$OUTPUT_FILE\"" + echo "Packaging \"${OUTPUT_DIR}\" to \"${OUTPUT_FILE}\"" - if [ -f "$OUTPUT_FILE" ]; then - rm "$OUTPUT_FILE" - fi + [ -f "${OUTPUT_FILE}" ] && rm "${OUTPUT_FILE}" - cd "$OUTPUT_DIR" - zip -q -9 -r "$OUTPUT_FILE" . - cd - + cd "${OUTPUT_DIR}" || exit + zip -q -9 -r "${OUTPUT_FILE}" . + cd - || exit } function dotnet-pub { - ARCH="$1" - OUTPUT_DIR="$PUBLISH_DIR_RELATIVE/$ARCH" - - dotnet publish -c Release -r "$ARCH" -o "$OUTPUT_DIR" --self-contained=true /p:TrimUnusedDependencies=true /p:LinkDuringPublish=true + local ARCH="${1}" + local OUTPUT_DIR="${PUBLISH_DIR_RELATIVE}/${ARCH}" + + dotnet publish \ + --configuration Release \ + --runtime "${ARCH}" \ + --output "${OUTPUT_DIR}" \ + --self-contained true \ + /p:TrimUnusedDependencies=true \ + /p:LinkDuringPublish=true } function cleanup { echo "Cleaning build output" - rm -rf "$PUBLISH_DIR" + rm -rf "${PUBLISH_DIR}" } function build-release { - dotnet-pub $1 - package $1 + local ARCH="${1}" + + dotnet-pub "${ARCH}" + package "${ARCH}" } build-release linux-arm build-release linux-arm64 build-release linux-x64 -build-release win-x64 build-release osx-x64 +build-release win-x64 cleanup