diff --git a/.gitignore b/.gitignore index 3504e3e..bd4df79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,19 @@ # .gitignore -## ------------------------------------ -## Project build rubbish +## Build artifacts ## ------------------------------------ -/node_modules -/deps /.tmp -/*.tgz -/npm-debug.log +## Distrib ## ------------------------------------ + +/distrib/*/* +!/distrib/npm/package.json +!/distrib/python/setup.py + + ## Normally ignored rubbish ## ------------------------------------ diff --git a/VERSION b/VERSION index b19b521..a3df0a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.8.0 +0.8.0 diff --git a/package.json b/distrib/npm/package.json similarity index 100% rename from package.json rename to distrib/npm/package.json diff --git a/setup.py b/distrib/python/setup.py similarity index 100% rename from setup.py rename to distrib/python/setup.py diff --git a/runnerfile.sh b/runnerfile.sh index cef33b3..9839a89 100644 --- a/runnerfile.sh +++ b/runnerfile.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash source_files=(bin/runner src/*.sh runnerfile.sh) +publish_files=(bin completion src LICENSE.md README.md VERSION) + +task_default() { + runner_parallel shellcheck test +} task_shellcheck() { runner_run shellcheck --exclude=SC2155,SC2016 "${source_files[@]}" @@ -14,28 +19,67 @@ task_readme() { doctoc README.md } -task_default() { - runner_parallel shellcheck test +task_clean() { + git clean -dxf } -task_update_version() { +task_update-version() { # $1 should be "--major", "--minor", or "--patch" local level="patch" case "${1}" in - --major) level="major" ;; - --minor) level="minor" ;; - --patch) level="patch" ;; + --major) level="major" ;; + --minor) level="minor" ;; + --patch) level="patch" ;; esac local awk_prog='{ - fields["major"]=$1; - fields["minor"]=$2; - fields["patch"]=$3; - fields["'${level}'"]++; + fields["major"]=$1; + fields["minor"]=$2; + fields["patch"]=$3; + fields["'${level}'"]++; } END { - print "v" fields["major"] + 0 "." fields["minor"] "." fields["patch"]; + print fields["major"] + 0 "." fields["minor"] "." fields["patch"]; }' local next_tag next_tag="$(awk -F '.' "${awk_prog}" < VERSION)" - runner_log "Updating to: ${next_tag}" + runner_log "Next version: ${next_tag}" + ## Write VERSION file + runner_log "Updating VERSION" echo "${next_tag}" > VERSION; + ## Update package.json + if runner_is_defined npm; then + runner_log "Updating package.json" + enter-dir distrib/npm + runner_run npm version "${next_tag}" + leave-dir + else + runner_log_warning "Missing 'npm', skipping..." + fi +} + +task_publish-npm() { + runner_sequence clean + rsync -a --relative "${publish_files[@]}" distrib/npm + enter-dir distrib/npm + npm publish + leave-dir +} + + +## Utility functions +## -------------------------------------------------------- + +dir_stack=() + +enter-dir() { + local path="${1}" + dir_stack+=("${path}") + runner_log "Entering '${path}'" + pushd "${path}" >/dev/null +} + +leave-dir() { + local path="${dir_stack[-1]}" + unset 'dir_stack[-1]' + runner_log "Leaving '${path}'" + popd >/dev/null } diff --git a/src/cli.sh b/src/cli.sh index 57d7012..b4b77d9 100644 --- a/src/cli.sh +++ b/src/cli.sh @@ -48,10 +48,10 @@ runner_cli_list_tasks() { } ## Outputs the current version number -runner_cli_version(){ - trap - EXIT - cat "${runner_src_dir}/../VERSION" - exit 0 +runner_cli_version() { + trap - EXIT + cat "${runner_src_dir}/../VERSION" + exit 0 } ## Outputs code to activate task completions @@ -156,6 +156,6 @@ fi # shellcheck source=/dev/null source "${runner_file}" -if [ -n "${runner_list_tasks}" ]; then +if [[ -n "${runner_list_tasks}" ]]; then runner_cli_list_tasks fi