#!/usr/bin/env ion

# set path to include sn
let PATH=$HOME/.cargo/bin:$PATH

git add *
git commit -am "for release"

cargo release --no-dev-version -l @args[1]

# run the builds
#mkdir -p target/completions
#export BASH_COMPLETIONS_DIR="target/completions"
#export FISH_COMPLETIONS_DIR="target/completions"
#cargo build --features "bash, fish" &&
export PATH=/home/vanessa/arm-bins/cross-compilation/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:$PATH
export PATH=$HOME/.cargo/bin:$PATH
cargo build --release &&
cross build --target=x86_64-pc-windows-gnu --release &&
cross build --target=aarch64-unknown-linux-gnu --release &&
cross build --target=armv7-unknown-linux-gnueabihf --release &&
cross build --target=x86_64-unknown-linux-musl --release &&
cross build --target=arm-unknown-linux-musleabi --release &&
cross build --target=x86_64-unknown-freebsd --release &&
cross build --target=x86_64-unknown-netbsd --release &&
cross build --target=sparc64-unknown-linux-gnu --release

# set path to include go binaries
let PATH=$HOME/.go/bin:$PATH

export GITHUB_TOKEN=$(cat .git-token)

let tag = $(git describe --tags)

github-release release -u vmchale -r tin-summer --tag $tag --name @args[2]

github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-x86_64-linux-gnu" --file target/release/sn
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-aarch-linux-gnu" --file target/aarch64-unknown-linux-gnu/release/sn
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-armv7-linux-gnueabihf" --file target/armv7-unknown-linux-gnueabihf/release/sn
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-armv7-linux-musleabi" --file target/armv7-unknown-linux-musleabi/release/sn
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-x86_64-pc-windows.exe" --file target/x86_64-pc-windows-gnu/release/sn.exe
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-x86_64-freebsd" --file target/x86_64-unknown-freebsd/release/sn
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-x86_64-linux-musl" --file target/x86_64-unknown-linux-musl/release/sn
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-x86_64-netbsd" --file target/x86_64-unknown-netbsd/release/sn
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-sparc64-linux-gnu" --file target/sparc64-unknown-linux-gnu/release/sn
