#!/usr/bin/env bash # SPDX-FileCopyrightText: 2021 - 2023 Robin Vobruba # # SPDX-License-Identifier: Unlicense # Exit immediately on each error and unset variable; # see: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -Eeuo pipefail #set -Eeu script_dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") #shellcheck source=./env source "$script_dir/env" mkdir -p "$TARGET_DIR/$STAGING" # mkdir -p "$STAGING"/{complete,doc} find . -maxdepth 1 \ \( \ -name "*LICENSE*" -o \ -name "*README*" -o \ -name "*COPYING*" -o \ -name "*AUTHORS*" -o \ -name "*FAQ*" -o \ -name "*CHANGELOG*" \ \) \ -exec cp -r {} "$TARGET_DIR/$STAGING/" \; # If this is a library-only crate, we skip all the BINARY related stuff if [ -n "$BINARY" ] then if [ ! -e "$BINARY_PATH_MUSL" ] && [ ! -e "$BINARY_PATH" ] then if [ -f "src/main.rs" ] || [ -f "bin/src/main.rs" ] then { echo "ERROR: Binary ('$BINARY_PATH_MUSL' or '$BINARY_PATH') does not exist!" echo " Maybe you forgot to build it (using '$script_dir/build' or 'cargo build --release')?" } >&2 else { echo "ERROR: Rust libraries should not be packaged, but rather released with cargo," echo " or referenced in 'Cargo.toml' through a local path or their git repo URL." } >&2 fi exit 1 fi if [ -e "$BINARY_PATH_MUSL" ] then cp "$BINARY_PATH_MUSL" "$TARGET_DIR/$STAGING/" else cp "$BINARY_PATH" "$TARGET_DIR/$STAGING/" fi fi OLD_DIR="$(pwd)" cd "$TARGET_DIR" if $IS_WIN then 7z a "$PACKAGE_ARCHIVE" "$STAGING" else # The man page is only generated on Unix systems. ¯\_(ツ)_/¯ # if [ -e "$outdir/$binary.1" ] # then # cp "$outdir/$binary.1" "$staging/doc/" # fi tar czf "$PACKAGE_ARCHIVE" "$STAGING" fi echo "Archive created: '$TARGET_DIR/$PACKAGE_ARCHIVE'" cd "$OLD_DIR"