list

scripts

Repo containing scripts to be used with dovel, and git hooks that powers our web interface.

curl https://dovel.email/scripts.tar tar

e1227f7

Author: brian (git@myr.sh)

Date: Sun Oct 1 17:42:09 2023 -0300

Parent: 2eae6eb

Added branch check

- Only creating go mod for new tags

Diff

diff --git a/create-go-mod b/create-go-mod
new file mode 100755
index 0000000..a7ea6a9
--- /dev/null
+++ b/create-go-mod
@@ -0,0 +1,14 @@
+#!/bin/sh
+# First argument should be the version, e.g. v0.1.0
+# for debugging
+# set -ex
+echo "updating go module"
+
+OUT="$HOME/www/dovel.email/$REPO"
+
+# go mod
+[ -d "$OUT/@latest" ] || mkdir -p "$OUT/@latest"
+[ -d "$OUT/@v/$1" ] || mkdir -p "$OUT/@v/$1"
+
+find tree/* -print | sed "s:tree/:dovel.email/$REPO@v$1/" | zip -@ > "$OUT/@v/$1.zip"
+cp "$OUT/$1.zip" "$OUT/@latest/"
diff --git a/post-receive b/post-receive
index 04f73be..7f64949 100755
--- a/post-receive
+++ b/post-receive
@@ -9,17 +9,29 @@ OUT="$HOME/www/dovel.email"
[ -d "$OUT/$REPO/tree" ] && rm -rf "$OUT/$REPO/tree"
git clone . "$OUT/$REPO/tree"

-# update git's index page
-. ./hooks/update-git-index
-
-# update repo's index page
-. ./hooks/update-repo-index
-
-# update repo's refs page
-. ./hooks/update-repo-refs
-
-# update repo's tree page
-. ./hooks/update-repo-tree
-
-# update repo's log page
-. ./hooks/update-repo-log
+while read oldrev newrev ref
+do
+        # only checking out the master (or whatever branch you would like to deploy)
+	case "$ref" in
+	"refs/heads/$BRANCH")
+		# update git's index page
+		. ./hooks/update-git-index
+
+		# update repo's index page
+		. ./hooks/update-repo-index
+
+		# update repo's refs page
+		. ./hooks/update-repo-refs
+
+		# update repo's tree page
+		. ./hooks/update-repo-tree
+
+		# update repo's log page
+		. ./hooks/update-repo-log
+	"refs/tags/"*)
+		# check repo for go mod
+		find -name go.mod tree/ && .hooks/create-go-mod "$tag"
+		;;
+	*) echo "Ref $ref received. Doing nothing." ;;
+	esac
+done
diff --git a/post-receive-scripts b/post-receive-scripts
index 7ddf746..cff619d 100755
--- a/post-receive-scripts
+++ b/post-receive-scripts
@@ -7,14 +7,11 @@ BRANCH="main"
REPO="$(basename $PWD)"
OUT="$HOME/www/dovel.email"

-[ -d "$OUT/$REPO/tree" ] && rm -rf "$OUT/$REPO/tree"
-git clone . "$OUT/$REPO/tree"
-
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
-        if [ "$ref" = "refs/heads/$BRANCH" ]
-        then
+	case "$ref" in
+	"refs/heads/$BRANCH")
echo "Ref $ref received. Updating git pages"
TMP="$(mktemp -d)"
git --work-tree="$TMP" checkout -f ${BRANCH}
@@ -28,22 +25,31 @@ do
cp "$TMP/update-repo-refs" "$dir/hooks/"
cp "$TMP/update-repo-tree" "$dir/hooks/"
cp "$TMP/update-repo-log" "$dir/hooks/"
+			cp "$TMP/create-go-mod" "$dir/hooks/"
cp "$TMP/aux.sh" "$dir/hooks/"
done

# for this repo copy scripts
rm ./hooks/post-receive
cp "$TMP/post-receive-scripts" ./hooks/post-receive
-        else
-                echo "Ref $ref received. Doing nothing."
-        fi
+		echo "cleaning up TMP"
+		rm -fr "$TMP"
+
+		# the common part
+		[ -d "$OUT/$REPO/tree" ] && rm -rf "$OUT/$REPO/tree"
+		git clone . "$OUT/$REPO/tree"
+
+		. ./hooks/update-git-index
+		. ./hooks/update-repo-index
+		. ./hooks/update-repo-refs
+		. ./hooks/update-repo-tree
+		. ./hooks/update-repo-log
+		;;
+	"refs/tags/"*)
+		# check repo for go mod
+		find -name go.mod tree/ && .hooks/create-go-mod "$tag"
+		;;
+	*) echo "Ref $ref received. Doing nothing." ;;
+	esac
done

-. ./hooks/update-git-index
-. ./hooks/update-repo-index
-. ./hooks/update-repo-refs
-. ./hooks/update-repo-tree
-. ./hooks/update-repo-log
-
-echo "cleaning up TMP"
-rm -fr "$TMP"
diff --git a/update-repo-index b/update-repo-index
index 1ab3ac9..5eb5c3d 100755
--- a/update-repo-index
+++ b/update-repo-index
@@ -11,7 +11,6 @@ OUT="$HOME/www/dovel.email/$REPO"
# archives
echo "creating archives"
tar -C "$OUT" -cz tree/ --xform="s/tree/$REPO/" > "$OUT.tar.gz"
-
echo "creating index.html"
cat << EOF > "$OUT/index.html"
$(pagehead "$REPO")