Skip to content

Commit d0ffafd

Browse files
committed
chore: Update Glue
Glue bug parsing `glue.toml` improperly caused all files to cease to exist. That has been fixed, so directories now sync over properly
1 parent 6dd0d14 commit d0ffafd

File tree

14 files changed

+284
-4
lines changed

14 files changed

+284
-4
lines changed

.glue/actions/auto/tool-bats.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
ensure.cmd 'bats'
6+
7+
for dir in test tests; do
8+
[[ -d $dir ]] || continue
9+
10+
bats --recursive --output "." "$dir"
11+
done
12+
13+
unbootstrap

.glue/actions/auto/tool-shdoc.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
ensure.cmd 'shdoc'
6+
7+
util.shopt -s dotglob
8+
util.shopt -s globstar
9+
util.shopt -s nullglob
10+
11+
declare outDir=".glue/generated/tool-shdoc"
12+
rm -rf "$outDir"
13+
for file in ./**/*.{sh,bash}; do
14+
if [[ $file == *'/.glue/'* ]]; then
15+
continue
16+
fi
17+
18+
declare output="$outDir/$file"
19+
mkdir -p "${output%/*}"
20+
output="${output%.*}"
21+
output="$output.md"
22+
shdoc < "$file" > "$output"
23+
done
24+
25+
unbootstrap

.glue/actions/auto/tool-shellcheck.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
ensure.cmd 'shellcheck'
6+
7+
# https://github.com/koalaman/shellcheck/issues/143
8+
# find . -ignore_readdir_race -regex '.*\.\(sh\|ksh\|bash\)' -print0 \
9+
# | xargs -r0 \
10+
# shellcheck --check-sourced --
11+
12+
13+
util.shopt -u dotglob
14+
util.shopt -s globstar
15+
util.shopt -s nullglob
16+
17+
shellcheck --check-sourced -- ./**/*.{sh,ksh,bash}
18+
19+
unbootstrap
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
ensure.cmd 'shellharden'
6+
7+
util.shopt -s globstar
8+
util.shopt -s nullglob
9+
10+
# shellharden --suggest -- ./**/*.{sh,bash}
11+
# shellharden --check -- ./**/*.{sh,bash}
12+
13+
unbootstrap
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
# eval "$GLUE_BOOTSTRAP"
3+
# bootstrap || exit
4+
5+
# @file util-release-post.sh
6+
# @brief Steps to perform after specialized version bumping
7+
8+
unset main
9+
main() {
10+
local newVersion="$1"
11+
ensure.nonZero 'newVersion' "$newVersion"
12+
13+
ensure.cmd 'git'
14+
ensure.cmd 'gh'
15+
16+
# Ensure working tree is dirty
17+
if [ -z "$(git status --porcelain)" ]; then
18+
die 'Working tree is not dirty. Cannot make a release if versions have not been bumped in their respective files'
19+
fi
20+
21+
# Local Release
22+
git add -A
23+
git commit -m "chore(release): v$newVersion"
24+
git tag -a "v$newVersion" -m "Release $newVersion" HEAD
25+
git push --follow-tags origin HEAD
26+
27+
local -a args=()
28+
if [ -f CHANGELOG.md ]; then
29+
args+=("--notes-file" "CHANGELOG.md")
30+
elif [ -f changelog.md ]; then
31+
args+=("--notes-file" "changelog.md")
32+
else
33+
log.warn 'CHANGELOG.md file not found. Not creating a notes file for release'
34+
fi
35+
36+
# Remote Release
37+
toml.get_key name glue.toml
38+
local projectName="${REPLY:-Release}"
39+
gh release create "v$newVersion" --target main --title "$projectName v$newVersion" "${args[@]}"
40+
}
41+
42+
main "$@"
43+
44+
# unbootstrap
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
# eval "$GLUE_BOOTSTRAP"
3+
# bootstrap || exit
4+
5+
# @file util-release-pre.sh
6+
# @brief Steps to perform before specialized version bumping
7+
# @description Before the release is made, this ensures there
8+
# are no changes in the working directory, and from the version
9+
# in 'glue-auto.toml', increments the version. This does not handle
10+
# anything language specific, so this is usually called along with
11+
# 'util-release-post.sh', and any other files that need version bumping
12+
# is performed in the interum
13+
14+
unset main
15+
main() {
16+
ensure.cmd 'git'
17+
ensure.file 'glue-auto.toml'
18+
19+
# Ensure working tree not dirty
20+
if [ -n "$(git status --porcelain)" ]; then
21+
die 'Working tree still dirty. Please commit all changes before making a release'
22+
fi
23+
24+
# Ensure we can push new version and its tags changes without --force-lease
25+
if ! git merge-base --is-ancestor origin/main main; then
26+
# main NOT is the same or has new additional commits on top of origin/main"
27+
die "Detected that your 'main' branch and it's remote have diverged. Won't initiate release process until histories are shared"
28+
fi
29+
30+
# Get current version
31+
toml.get_key version glue-auto.toml
32+
local currentVersion="$REPLY"
33+
34+
# Get new version number
35+
# TODO: make incremenet better
36+
echo "Current Version: $currentVersion"
37+
read -rp 'New Version? ' -ei "$currentVersion"
38+
local newVersion="$REPLY"
39+
declare -g REPLY="$newVersion" # explicit
40+
41+
# Ensure new version is valid (does not already exist)
42+
if [ -n "$(git tag -l "v$newVersion")" ]; then
43+
# TODO: ensure there are no tag sthat exists that are greater than it
44+
die 'Version already exists in a Git tag'
45+
fi
46+
47+
sed -i -e "s|\(version[ \t]*=[ \t]*\"\).*\(\"\)|\1${newVersion}\2|g" glue-auto.toml
48+
}
49+
50+
main "$@"
51+
52+
# unbootstrap

.glue/commands/auto/Bash.ci.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
unbootstrap

.glue/commands/auto/Bash.docs.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
# glue useAction(tool-shdoc.sh)
6+
util.get_action 'tool-shdoc.sh'
7+
source "$REPLY"
8+
9+
unbootstrap

.glue/commands/auto/Bash.lint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
# glue useAction(tool-shellcheck.sh)
6+
util.get_action 'tool-shellcheck.sh'
7+
source "$REPLY"
8+
9+
# glue useAction(tool-shellharden.sh)
10+
# util.get_action 'tool-shellharden.sh'
11+
# source "$REPLY"
12+
13+
unbootstrap

.glue/commands/auto/Bash.release.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
# glue useAction(util-release-pre.sh)
6+
util.get_action 'util-release-pre.sh'
7+
source "$REPLY"
8+
newVersion="$REPLY"
9+
10+
# TODO: generalize
11+
sed -i -e "s|\(PROGRAM_VERSION=\"\).*\(\"\)|\1${newVersion}\2|g" glue.sh || :
12+
13+
# glue useAction(util-release-post.sh)
14+
util.get_action 'util-release-post.sh'
15+
source "$REPLY" "$newVersion"
16+
17+
unset newVersion
18+
unbootstrap

0 commit comments

Comments
 (0)