#!/usr/bin/env bash # # Publishes the crate # set -eu cleanup() { [ -z "$temp_dir" ] || rm -rf "$temp_dir" } main() { temp_dir="" trap cleanup EXIT trap "exit 1" SIGINT SIGTERM SIGQUIT temp_dir="$(mktemp -d "/var/tmp/investments.XXXXXX")" git archive HEAD | ( cd "$temp_dir" tar -x rmdir testdata cd "$package" cargo publish ) } case $# in 0) package=. ;; 1) package="$1" ;; *) echo "Usage: $0 [package]" >&2 && exit 1 ;; esac main