#!/bin/bash set -euf -o pipefail # ---------- setup project="wbs-backup" name="wbs-backup-daemon" version="$1" full_name="$name-$version" archive="$full_name.tar.xz" release="target/release" local_dist="dist/$full_name" wbs_dist="ubuntu@dist.vpn.wellbehavedsoftware.com:dist/$name" release_date="$(date +'%A, %-d %B %Y')" echo echo "========== update version numbers ==========" echo echo " Cargo.toml" sed --in-place --regexp-extended \ --expression "s/^version = \".*\"\$/version = \"$version\"/" \ "Cargo.toml" echo " README.md" sed --in-place --regexp-extended \ --expression "s/^Version: .*\$/Version: $version/" \ --expression "s/^Release date: .*\$/Release date: $release_date/" \ "README.md" echo echo "========== perform clean build ==========" echo cargo clean cargo build --release echo echo "========== create tar release ==========" echo mkdir -p "$local_dist" mkdir -p "$local_dist/bin" mkdir -p "$local_dist/share/doc/$full_name" cp "$release/backup-daemon" "$local_dist/bin/" cp "LICENSE" "$local_dist/share/doc/$full_name/" cp "README.md" "$local_dist/share/doc/$full_name/" tar --create --xz \ --directory "dist" \ --file "dist/$archive" \ "$full_name" echo echo "========== git commit and push ==========" echo git add Cargo.toml Cargo.lock README.md git commit -m "release $full_name" git tag "$full_name" git push origin "$full_name" echo echo "========== upload to general dist ==========" echo scp "dist/$archive" "$wbs_dist/$archive" echo echo "========== upload to cargo ==========" echo cargo publish echo echo "========== complete ==========" echo # ex: noet ts=4 filetype=bash