Skip to content

Commit

Permalink
chore: update Glue
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed Jun 6, 2021
1 parent 32a8aa0 commit e60dac4
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 255 deletions.
10 changes: 7 additions & 3 deletions .glue/actions/auto/util-Bash-version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ main() {
local newVersion="$1"
ensure.nonZero 'newVersion' "$newVersion"

# TODO: show which files changed
# TODO: better output
exec 8> >(xargs -r0 -- grep -l "PROGRAM_VERSION")
find . -ignore_readdir_race -regex '\./pkg/.*\.\(sh\|bash\)' -print0 2>/dev/null \
| xargs -r0 \
sed -i -e "s|\(PROGRAM_VERSION=\"\).*\(\"\)|\1$newVersion\2|g"
| tee /dev/fd/8 \
| xargs -r0 -- sed -i -e "s|\(PROGRAM_VERSION=\"\).*\(\"\)|\1$newVersion\2|g"
exec 8>&-

wait
log.info "util-Bash-version-bump: Bump done"
}

Expand Down
26 changes: 0 additions & 26 deletions .glue/actions/auto/util-get-version.sh

This file was deleted.

70 changes: 0 additions & 70 deletions .glue/actions/auto/util-release-post.sh

This file was deleted.

84 changes: 0 additions & 84 deletions .glue/actions/auto/util-release-pre.sh

This file was deleted.

28 changes: 20 additions & 8 deletions .glue/commands/auto/Bash.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@
eval "$GLUE_BOOTSTRAP"
bootstrap || exit

# glue useAction(util-get-version.sh)
util.get_action 'util-get-version.sh'
source "$REPLY"
declare newVersion="$REPLY"

# glue useAction(util-Bash-version-bump.sh)
util.get_action 'util-Bash-version-bump.sh'
source "$REPLY" "$newVersion"
unset task
task() {
ensure.file 'glue-auto.toml'
toml.get_key 'version' 'glue-auto.toml'
local newVersion="$REPLY"

if [ -z "$newVersion" ]; then
util.git_generate_version
newVersion="$REPLY"
fi

util.general_version_bump "$newVersion"

# glue useAction(util-Bash-version-bump.sh)
util.get_action 'util-Bash-version-bump.sh'
source "$REPLY" "$newVersion"
}

task "$@"
unset task

unbootstrap
110 changes: 88 additions & 22 deletions .glue/commands/auto/Bash.release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,92 @@
eval "$GLUE_BOOTSTRAP"
bootstrap || exit

#
# glue useAction(util-release-pre.sh)
util.get_action 'util-release-pre.sh'
source "$REPLY" 'notDry'
newVersion="$REPLY"

# Bash version bump
(
find . -ignore_readdir_race -regex '\./pkg/.*\.\(sh\|bash\)' -print0 \
| xargs -r0 \
sed -i -e "s|\(PROGRAM_VERSION=\"\).*\(\"\)|\1${newVersion}\2|g" || :
) || exit

# glue useAction(util-release-post.sh)
util.get_action 'util-release-post.sh'
source "$REPLY" 'notDry' "$newVersion"

# glue useAction(result-pacman-package.sh)
util.get_action 'result-pacman-package.sh'
source "$REPLY"

unset newVersion
unset task
task() {
declare -g RELEASE_STATUS=dry
for arg; do
case "$arg" in
--wet)
# shellcheck disable=SC2034
RELEASE_STATUS=wet
esac
done

ensure.cmd 'git'
ensure.cmd 'gh'
ensure.file 'glue-auto.toml'

if is.dry_release; then
log.info "Running pre-release process in dry mode"
else
ensure.confirm_wet_release
fi

# Perform build
# TODO: perform build on commit hook etc.
util.get_command 'Bash.build.sh'
source "$REPLY"

# Ensure tests pass
util.get_command 'Bash.test.sh'
source "$REPLY"

# Build docs
util.get_command 'Bash.docs.sh'
source "$REPLY"

ensure.git_working_tree_clean
ensure.git_common_history

local newVersion=
if is.dry_release; then
toml.get_key 'version' 'glue-auto.toml'
newVersion="$REPLY"

ensure.nonZero 'newVersion' "$newVersion"
else
toml.get_key 'version' 'glue-auto.toml'
util.prompt_new_version "$REPLY"
newVersion="$REPLY"

ensure.nonZero 'newVersion' "$newVersion"
ensure.version_is_only_major_minor_patch "$newVersion"
ensure.git_version_tag_validity "$newVersion"
fi

util.general_version_bump "$newVersion"

ensure.git_working_tree_dirty

if is.dry_release; then
log.info "Skipping Git taging and artifact release"
else
git add -A
git commit -m "chore(release): v$newVersion"
git tag -a "v$newVersion" -m "Release $newVersion" HEAD
git push --follow-tags origin HEAD

local -a args=()
if [ -f CHANGELOG.md ]; then
args+=("-F" "CHANGELOG.md")
elif [ -f changelog.md ]; then
args+=("-F" "changelog.md")
else
# '-F' is required for non-interactivity
args+=("-F" "")
log.warn 'CHANGELOG.md file not found. Creating empty notes file for release'
fi

# Remote Release
gh release create "v$newVersion" --target main --title "v$newVersion" "${args[@]}"
fi

# glue useAction(result-pacman-package.sh)
util.get_action 'result-pacman-package.sh'
source "$REPLY"
}

task "$@"
unset task

unbootstrap
27 changes: 0 additions & 27 deletions .glue/commands/auto/Bash.releaseDry.sh

This file was deleted.

Loading

0 comments on commit e60dac4

Please sign in to comment.