Skip to content

Commit

Permalink
Streamline package publishing process
Browse files Browse the repository at this point in the history
Uses 'distrib' folder for separating platform specific files, see Issue #30
  • Loading branch information
stylemistake committed Dec 5, 2018
1 parent 778f908 commit 182c839
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 24 deletions.
14 changes: 8 additions & 6 deletions .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
## ------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
v0.8.0
0.8.0
File renamed without changes.
File renamed without changes.
68 changes: 56 additions & 12 deletions 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[@]}"
Expand All @@ -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
}
10 changes: 5 additions & 5 deletions src/cli.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 182c839

Please sign in to comment.