From ff3a30ae21388988076e4c892565b0e679076152 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 28 Jan 2020 03:41:43 -0800 Subject: [PATCH] Add package script type: distribution --- bin/package | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 bin/package diff --git a/bin/package b/bin/package new file mode 100755 index 00000000..217dac3f --- /dev/null +++ b/bin/package @@ -0,0 +1,52 @@ +#!/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..." + +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 "Copying release files..." +mkdir dist +cp \ + $executable \ + Cargo.lock \ + Cargo.toml \ + LICENSE \ + README.md \ + $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