summaryrefslogtreecommitdiff
path: root/mise.toml
diff options
context:
space:
mode:
Diffstat (limited to 'mise.toml')
-rw-r--r--mise.toml46
1 files changed, 46 insertions, 0 deletions
diff --git a/mise.toml b/mise.toml
index 1de7ca9..989809a 100644
--- a/mise.toml
+++ b/mise.toml
@@ -30,3 +30,49 @@ mv "$TMP" "$NEWSPEC"
[ "$SPEC" = "$NEWSPEC" ] || rm -f "$SPEC"
luarocks lint "$NEWSPEC"
'''
+
+[tasks.release]
+description = "Tag the committed version, push the tag, upload to luarocks.org"
+depends = ["check"]
+dir = "{{config_root}}"
+run = """
+set -eu
+SPEC="$(ls -1 ./*.rockspec)"
+case "$SPEC" in *"
+"*) echo "expected exactly one rockspec, found:" >&2; echo "$SPEC" >&2; exit 1;; esac
+
+VER="$(sed -n 's/^version = "\\(.*\\)-[0-9]*"/\\1/p' "$SPEC")"
+[ -n "$VER" ] || { echo "could not read version from $SPEC" >&2; exit 1; }
+TAG="v$VER"
+
+# jj's working copy is itself a commit, so @ is normally the empty commit a
+# `jj new` just made and the release content sits in @-. Override with
+# REV=@ (or any revset) when that is not the case.
+REV="${REV:-@-}"
+
+# The tag is what `luarocks upload` clones to build the .src.rock, so the
+# rockspec being published has to already be in the revision being tagged.
+# Uncommitted, they diverge silently: the upload would ship a rockspec that
+# says $VER over sources from a commit that never had it.
+if ! jj file show -r "$REV" "$SPEC" 2>/dev/null | diff -q - "$SPEC" >/dev/null 2>&1; then
+ echo "$SPEC at $REV differs from the working copy -- commit it first" >&2
+ exit 1
+fi
+
+if jj tag list | grep -q "^$TAG:"; then
+ echo "tag $TAG already exists -- bump the version first" >&2
+ exit 1
+fi
+
+# jj 0.42 creates tags natively and exports them to git in a colocated repo,
+# but `jj git push` only pushes bookmarks -- tags still need git.
+jj tag set "$TAG" -r "$REV"
+jj tag list | grep "^$TAG:"
+for remote in $(git remote); do
+ git push "$remote" "$TAG"
+done
+
+# Reads the API key from ~/.luarocks/upload_config.lua. Packs a .src.rock by
+# cloning source.url at the tag just pushed, so the push has to come first.
+luarocks upload "$SPEC"
+"""