Skip to content

Commit

Permalink
feat: add version subcommand and bump command
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Jan 15, 2023
1 parent 731b5ff commit eef5ded
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
40 changes: 40 additions & 0 deletions bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
set -e
set -u

my_version="${1-}"
if [ -z "${my_version}" ]; then
echo "Usage: bump.sh v1.2.3"
exit 1
fi

if ! git diff --quiet; then
echo "Error: git status is dirty"
fi

if ! command -v sd > /dev/null; then
echo "Install 'sd' first."
echo " curl https://webi.sh/sd | sh"
exit 1
fi

my_commit_hash="$(
git rev-parse --short HEAD
)"
my_commit_date="$(
git show -s --format=%ci "${my_commit_hash}" |
grep -E '20[0-9]{2}-[01][0-9]-[0123][0-9]'
)"
my_year="$(
date '+%Y'
)"

sd 'my_version=.*' "my_version='${my_version}'" duckdns.sh
sd 'my_year=.*' "my_year='${my_year}'" duckdns.sh
sd 'my_date=.*' "my_date='${my_commit_date}'" duckdns.sh

git add ./duckdns.sh
git commit -m "chore(release): bump to ${my_version}"
git tag "${my_version}"

git describe --tags
11 changes: 11 additions & 0 deletions duckdns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ cmd_update() { (
fn_update_ips
); }

cmd_version() { (
my_year='0000'
my_version='v0.0.0'
my_date='0000-00-00'

echo "DuckDNS.sh ${my_version} (${my_date})"
echo "Copyright ${my_year} AJ ONeal"
); }

fn_check_env() { (
if ! [ -e ~/.config/duckdns.sh/"${DUCKDNS_SH_SUBDOMAIN}.env" ]; then
exit 1
Expand Down Expand Up @@ -447,6 +456,7 @@ main() { (
update) cmd_update ;;
__noop__) ;;
help | --help | -h) fn_help ;;
version | --version | -V) cmd_version ;;
*)
fn_help
exit 1
Expand All @@ -473,6 +483,7 @@ fn_help() { (
echo " disable <subdomain> - disable on boot or login"
echo ""
echo " help - show this menu"
echo " version - show version and exit"
echo ""
); }

Expand Down

0 comments on commit eef5ded

Please sign in to comment.