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

14 files changed

+284
-4
lines changed

Diff for: .glue/actions/auto/tool-bats.sh

+13
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

Diff for: .glue/actions/auto/tool-shdoc.sh

+25
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

Diff for: .glue/actions/auto/tool-shellcheck.sh

+19
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

Diff for: .glue/actions/auto/tool-shellharden.sh

+13
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

Diff for: .glue/actions/auto/util-release-post.sh

+44
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

Diff for: .glue/actions/auto/util-release-pre.sh

+52
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

Diff for: .glue/commands/auto/Bash.ci.sh

+5
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

Diff for: .glue/commands/auto/Bash.docs.sh

+9
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

Diff for: .glue/commands/auto/Bash.lint.sh

+13
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

Diff for: .glue/commands/auto/Bash.release.sh

+18
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

Diff for: .glue/commands/auto/Bash.run.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
eval "$GLUE_BOOTSTRAP"
3+
bootstrap || exit
4+
5+
dirty=
6+
if [ -n "$(git status --porcelain)" ]; then
7+
dirty=yes
8+
fi
9+
10+
if version="$(git describe --match 'v*' --abbrev=0 2>/dev/null)"; then
11+
version="${version/#v/}"
12+
else
13+
version="0.0.0"
14+
fi
15+
16+
id="$(git rev-parse --short HEAD)"
17+
version+="+$id${dirty:+-DIRTY}"
18+
19+
sed -i -e "s|\(version=\"\).*\(\"\)|\1${version}\2|g" glue.toml
20+
21+
# TODO: exec project
22+
23+
# if [ -f Taskfile.yml ]; then
24+
# if command -v go-task &>/dev/null; then
25+
# go-task run "$@"
26+
# elif command -v task &>/dev/null; then
27+
# if ! task help | grep -q Taskwarrior; then
28+
# task run "$@"
29+
# else
30+
# ensure.cmd 'go-task'
31+
# fi
32+
# else
33+
# ensure.cmd 'go-task'
34+
# fi
35+
# elif [ -f Justfile ]; then
36+
# ensure.cmd 'just'
37+
38+
# just run "$@"
39+
# fi
40+
41+
unbootstrap

Diff for: .glue/commands/auto/Bash.test.sh

+9
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-bats.sh)
6+
util.get_action 'tool-bats.sh'
7+
source "$REPLY"
8+
9+
unbootstrap

Diff for: .glue/common/auto/ensure.sh

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env bash
22

33
ensure.cmd() {
4-
if ! command -v "$1" &>/dev/null; then
5-
die "Command '$1' not found"
4+
local cmd="$1"
5+
6+
if ! command -v "$cmd" &>/dev/null; then
7+
die "Command '$cmd' not found"
68
fi
79
}
810

@@ -24,10 +26,26 @@ ensure.args() {
2426
}
2527

2628
ensure.nonZero() {
27-
varName="$1"
28-
varValue="$2"
29+
local varName="$1"
30+
local varValue="$2"
2931

3032
if [ -z "$varValue" ]; then
3133
die "ensure.nonZero: Variable '$varName' must be non zero"
3234
fi
3335
}
36+
37+
ensure.file() {
38+
local fileName="$1"
39+
40+
if [ ! -f "$fileName" ]; then
41+
die "ensure.file: File '$fileName' does not exist"
42+
fi
43+
}
44+
45+
ensure.dir() {
46+
local dirName="$1"
47+
48+
if [ ! -f "$dirName" ]; then
49+
die "ensure.file: File '$dirName' does not exist"
50+
fi
51+
}

Diff for: glue-auto.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "0.5.0"

0 commit comments

Comments
 (0)