release 0.0.0
This commit is contained in:
parent
24256b767d
commit
778f7fbd7c
8 changed files with 513 additions and 57 deletions
25
scripts/generate_install_script.py
Executable file
25
scripts/generate_install_script.py
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env -S uv run --quiet --script
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# ///
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def generate_install_script(version):
|
||||
with open("scripts/install.sh.template", "r") as f:
|
||||
template = f.read()
|
||||
|
||||
script = template.replace("{{VERSION}}", version)
|
||||
|
||||
with open("dist/install.sh", "w") as f:
|
||||
f.write(script)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: generate_install_script.py VERSION", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
version = sys.argv[1]
|
||||
generate_install_script(version)
|
||||
89
scripts/get_release_notes.py
Executable file
89
scripts/get_release_notes.py
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env -S uv run --quiet --script
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# ///
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def get_release_notes(version):
|
||||
with open("CHANGELOG.md", "r") as f:
|
||||
content = f.read()
|
||||
|
||||
sections = content.split("\n## ")
|
||||
# First section won't start with ## since it's split on that
|
||||
sections = ["## " + s if i > 0 else s for i, s in enumerate(sections)]
|
||||
|
||||
for section in sections:
|
||||
if section.startswith(f"## {version}"):
|
||||
install_instructions = f"""## Installation
|
||||
|
||||
You can install krayt using one of these methods:
|
||||
|
||||
> !krayt requires [uv](https://docs.astral.sh/uv/getting-started/installation/) to be installed
|
||||
|
||||
### Using i.jpillora.com (recommended)
|
||||
|
||||
``` bash
|
||||
curl https://i.jpillora.com/waylonwalker/krayt | bash
|
||||
```
|
||||
|
||||
### Direct install script
|
||||
|
||||
``` bash
|
||||
curl -fsSL https://github.com/waylonwalker/krayt/releases/download/v{version}/install.sh | bash
|
||||
```
|
||||
|
||||
### Manual download
|
||||
You can also manually download the archive for your platform from the releases page:
|
||||
- [x86_64-unknown-linux-gnu](https://github.com/waylonwalker/krayt/releases/download/v{version}/krayt-{version}-x86_64-unknown-linux-gnu.tar.gz)
|
||||
- [aarch64-unknown-linux-gnu](https://github.com/waylonwalker/krayt/releases/download/v{version}/krayt-{version}-aarch64-unknown-linux-gnu.tar.gz)"""
|
||||
|
||||
# Get help output for main command and all subcommands
|
||||
try:
|
||||
help_outputs = []
|
||||
|
||||
# Get main help output
|
||||
main_help = subprocess.check_output(
|
||||
["./krayt.py", "--help"],
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
)
|
||||
help_outputs.append(("Main Command", main_help))
|
||||
|
||||
# Get help for each subcommand
|
||||
subcommands = ["create", "exec", "clean", "version"]
|
||||
for cmd in subcommands:
|
||||
cmd_help = subprocess.check_output(
|
||||
["./krayt.py", cmd, "--help"],
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
)
|
||||
help_outputs.append((f"Subcommand: {cmd}", cmd_help))
|
||||
|
||||
# Format all help outputs
|
||||
help_text = "\n\n".join(
|
||||
f"### {title}\n\n``` bash\n{output}```"
|
||||
for title, output in help_outputs
|
||||
)
|
||||
|
||||
return f"{section.strip()}\n\n{install_instructions.format(version=version)}\n\n## Command Line Usage\n\n{help_text}"
|
||||
except subprocess.CalledProcessError as e:
|
||||
return f"{section.strip()}\n\n{install_instructions.format(version=version)}\n\n## Command Line Usage\n\nError getting help: {e.output}"
|
||||
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: get_release_notes.py VERSION", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
version = sys.argv[1]
|
||||
notes = get_release_notes(version)
|
||||
if notes:
|
||||
print(notes)
|
||||
else:
|
||||
print(f"Error: No release notes found for version {version}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
126
scripts/install.sh.template
Normal file
126
scripts/install.sh.template
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
#!/bin/bash
|
||||
if [ "$DEBUG" == "1" ]; then
|
||||
set -x
|
||||
fi
|
||||
TMP_DIR=$(mktemp -d -t krayt-installer-XXXXXXXXXX)
|
||||
function cleanup {
|
||||
rm -rf $TMP_DIR >/dev/null
|
||||
}
|
||||
function fail {
|
||||
cleanup
|
||||
msg=$1
|
||||
echo "============"
|
||||
echo "Error: $msg" 1>&2
|
||||
exit 1
|
||||
}
|
||||
function check_deps {
|
||||
if ! command -v uv &>/dev/null; then
|
||||
echo " Error: uv is not installed"
|
||||
echo "krayt requires uv to run. You can install it with:"
|
||||
echo " curl -LsSf https://astral.sh/uv/install.sh | sh"
|
||||
echo ""
|
||||
echo "Or visit: https://github.com/astral/uv for more installation options"
|
||||
echo ""
|
||||
fail "uv not found"
|
||||
fi
|
||||
}
|
||||
function install {
|
||||
#settings
|
||||
USER="waylonwalker"
|
||||
PROG="krayt"
|
||||
ASPROG="krayt"
|
||||
MOVE="true"
|
||||
RELEASE="{{VERSION}}"
|
||||
INSECURE="false"
|
||||
OUT_DIR="/usr/local/bin"
|
||||
GH="https://github.com"
|
||||
#bash check
|
||||
[ ! "$BASH_VERSION" ] && fail "Please use bash instead"
|
||||
[ ! -d $OUT_DIR ] && fail "output directory missing: $OUT_DIR"
|
||||
#dependency check, assume we are a standard POISX machine
|
||||
which find >/dev/null || fail "find not installed"
|
||||
which xargs >/dev/null || fail "xargs not installed"
|
||||
which sort >/dev/null || fail "sort not installed"
|
||||
which tail >/dev/null || fail "tail not installed"
|
||||
which cut >/dev/null || fail "cut not installed"
|
||||
which du >/dev/null || fail "du not installed"
|
||||
#choose an HTTP client
|
||||
GET=""
|
||||
if which curl >/dev/null; then
|
||||
GET="curl"
|
||||
if [[ $INSECURE = "true" ]]; then GET="$GET --insecure"; fi
|
||||
GET="$GET --fail -# -L"
|
||||
elif which wget >/dev/null; then
|
||||
GET="wget"
|
||||
if [[ $INSECURE = "true" ]]; then GET="$GET --no-check-certificate"; fi
|
||||
GET="$GET -qO-"
|
||||
else
|
||||
fail "neither wget/curl are installed"
|
||||
fi
|
||||
#find OS
|
||||
case $(uname -s) in
|
||||
Darwin) OS="darwin" ;;
|
||||
Linux) OS="linux" ;;
|
||||
*) fail "unknown os: $(uname -s)" ;;
|
||||
esac
|
||||
#find ARCH
|
||||
if uname -m | grep -E '(arm|aarch)64' >/dev/null; then
|
||||
ARCH="aarch64"
|
||||
elif uname -m | grep 64 >/dev/null; then
|
||||
ARCH="x86_64"
|
||||
else
|
||||
fail "unknown arch: $(uname -m)"
|
||||
fi
|
||||
#choose from asset list
|
||||
URL=""
|
||||
FTYPE=""
|
||||
VERSION=${RELEASE#v}
|
||||
if [[ $VERSION == "" ]]; then
|
||||
VERSION=$(curl -s https://api.github.com/repos/$USER/$PROG/releases/latest | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)
|
||||
fi
|
||||
if [[ $VERSION == "" ]]; then
|
||||
fail "cannot find latest version"
|
||||
fi
|
||||
VERSION=${VERSION#v}
|
||||
ASSET_URL="$GH/$USER/$PROG/releases/download/v$VERSION/${PROG}-${VERSION}-${ARCH}-unknown-${OS}-gnu.tar.gz"
|
||||
echo "Installing $PROG v$VERSION..."
|
||||
echo "Downloading binary from $ASSET_URL"
|
||||
#enter tempdir
|
||||
cd $TMP_DIR
|
||||
#download and unpack
|
||||
if [[ $ASSET_URL =~ \.gz$ ]]; then
|
||||
which tar >/dev/null || fail "tar not installed"
|
||||
if [[ $GET =~ ^curl ]]; then
|
||||
curl -s ${ASSET_URL} | tar zx || fail "download failed"
|
||||
else
|
||||
wget -qO- ${ASSET_URL} | tar zx || fail "download failed"
|
||||
fi
|
||||
else
|
||||
fail "unknown file type: $ASSET_URL"
|
||||
fi
|
||||
#check for error
|
||||
cd ${PROG}-${VERSION}-${ARCH}-unknown-${OS}-gnu
|
||||
#move binary
|
||||
if [[ -f "${PROG}.py" ]]; then
|
||||
chmod +x "${PROG}.py"
|
||||
if [[ $MOVE == "true" ]]; then
|
||||
echo "Moving binary to $OUT_DIR/$ASPROG"
|
||||
# Create a wrapper script to ensure uv is used
|
||||
cat > "$OUT_DIR/$ASPROG" << EOF
|
||||
#!/bin/bash
|
||||
exec uv run --quiet --script "$OUT_DIR/${ASPROG}.py" "\$@"
|
||||
EOF
|
||||
chmod +x "$OUT_DIR/$ASPROG"
|
||||
mv "${PROG}.py" "$OUT_DIR/${ASPROG}.py" || fail "Cannot move binary to $OUT_DIR"
|
||||
else
|
||||
echo "Moving binary to $OUT_DIR/${ASPROG}.py"
|
||||
mv "${PROG}.py" "$OUT_DIR/${ASPROG}.py" || fail "Cannot move binary to $OUT_DIR"
|
||||
fi
|
||||
else
|
||||
fail "cannot find binary"
|
||||
fi
|
||||
echo "Installation complete!"
|
||||
cleanup
|
||||
}
|
||||
check_deps
|
||||
install
|
||||
Loading…
Add table
Add a link
Reference in a new issue