intermodal/bin/package
Casey Rodarmor 28114c3d64
Don't commit shell completion scripts
Committing the completion scripts bloats diffs, so stop committing them.

Before copying release files, generate the scripts in `bin/package`.

type: development
2020-04-21 00:29:26 -07:00

66 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euxo pipefail
version=${1#"refs/tags/"}
os=$2
target=$3
src=`pwd`
dist=$src/dist
bin=imdl
echo "Packaging $bin $version for $target..."
test -f Cargo.lock || cargo generate-lockfile
echo "Building $bin..."
if [ "$os" = "ubuntu-latest" ]; then
sudo apt-get install musl-tools
fi
case $os in
ubuntu-latest | macos-latest)
cargo rustc --bin $bin --target $target --release -- -C lto
executable=target/$target/release/$bin
;;
windows-latest)
cargo rustc --bin $bin --target $target --release -- -C lto -C target-feature="+crt-static"
executable=target/$target/release/$bin.exe
;;
esac
echo "Building completions..."
rm -rf completions
mkdir completions
$executable completions --dir completions
echo "Copying release files..."
mkdir dist
cp -r \
$executable \
CHANGELOG.md \
CONTRIBUTING \
Cargo.lock \
Cargo.toml \
LICENSE \
README.md \
completions \
man \
$dist
cd $dist
echo "Creating release archive..."
case $os in
ubuntu-latest | macos-latest)
archive=$dist/$bin-$version-$target.tar.gz
tar czf $archive *
echo "::set-output name=archive::$archive"
;;
windows-latest)
archive=$dist/$bin-$version-$target.zip
7z a $archive *
echo "::set-output name=archive::`pwd -W`/$bin-$version-$target.zip"
;;
esac