Improve release and benchmark tooling
This commit is contained in:
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
repo_root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
out="${DOSH_BENCH_REPORT:-target/dosh-bench/report.md}"
|
||||
iters="${DOSH_BENCH_ITERS:-10}"
|
||||
server="${DOSH_BENCH_SERVER:-${1:-local}}"
|
||||
label="${DOSH_BENCH_LABEL:-$(uname -s) $(uname -m)}"
|
||||
|
||||
cargo build --release >/dev/null
|
||||
mkdir -p "$(dirname "$out")"
|
||||
|
||||
exec target/release/dosh-bench \
|
||||
--server "$server" \
|
||||
--iterations "$iters" \
|
||||
--label "$label" \
|
||||
--markdown \
|
||||
--output "$out" \
|
||||
${DOSH_BENCH_ARGS:-}
|
||||
@@ -12,6 +12,7 @@ normalize_os() {
|
||||
Darwin) printf '%s\n' macos ;;
|
||||
Linux) printf '%s\n' linux ;;
|
||||
FreeBSD) printf '%s\n' freebsd ;;
|
||||
MINGW*|MSYS*|CYGWIN*) printf '%s\n' windows ;;
|
||||
*) uname -s | tr '[:upper:]' '[:lower:]' ;;
|
||||
esac
|
||||
}
|
||||
@@ -27,8 +28,13 @@ normalize_arch() {
|
||||
|
||||
os="$(normalize_os)"
|
||||
arch="$(normalize_arch)"
|
||||
artifact="dosh-$os-$arch.tar.gz"
|
||||
versioned_artifact="dosh-$version-$os-$arch.tar.gz"
|
||||
if [ "$os" = "windows" ]; then
|
||||
artifact="dosh-$os-$arch.zip"
|
||||
versioned_artifact="dosh-$version-$os-$arch.zip"
|
||||
else
|
||||
artifact="dosh-$os-$arch.tar.gz"
|
||||
versioned_artifact="dosh-$version-$os-$arch.tar.gz"
|
||||
fi
|
||||
stage="$out_dir/stage/dosh"
|
||||
|
||||
cargo build --release
|
||||
@@ -42,11 +48,38 @@ for bin in dosh-client dosh-server dosh-auth dosh-bench; do
|
||||
done
|
||||
printf '%s\n' "$version" >"$stage/VERSION"
|
||||
|
||||
tar -C "$out_dir/stage" -czf "$out_dir/$artifact" dosh
|
||||
if [ "$os" = "windows" ]; then
|
||||
if command -v powershell.exe >/dev/null 2>&1; then
|
||||
powershell.exe -NoProfile -Command "Compress-Archive -Force -Path '$stage' -DestinationPath '$out_dir/$artifact'"
|
||||
elif command -v zip >/dev/null 2>&1; then
|
||||
(cd "$out_dir/stage" && zip -qr "../$artifact" dosh)
|
||||
else
|
||||
echo "windows packaging requires powershell.exe or zip" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
tar -C "$out_dir/stage" -czf "$out_dir/$artifact" dosh
|
||||
fi
|
||||
cp "$out_dir/$artifact" "$out_dir/$versioned_artifact"
|
||||
|
||||
write_sha256() {
|
||||
file="$1"
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum "$file" >"$file.sha256"
|
||||
elif command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$file" >"$file.sha256"
|
||||
else
|
||||
echo "warning: sha256sum/shasum not found; skipping checksum for $file" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
write_sha256 "$out_dir/$artifact"
|
||||
write_sha256 "$out_dir/$versioned_artifact"
|
||||
|
||||
cat <<EOF
|
||||
Wrote:
|
||||
$out_dir/$artifact
|
||||
$out_dir/$artifact.sha256
|
||||
$out_dir/$versioned_artifact
|
||||
$out_dir/$versioned_artifact.sha256
|
||||
EOF
|
||||
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
GITEA_TOKEN=... scripts/upload-gitea-release.sh TAG [artifact...]
|
||||
|
||||
Environment:
|
||||
GITEA_URL Base URL, default https://git.palav.dev
|
||||
GITEA_REPO owner/repo, default Palav/dosh
|
||||
GITEA_TOKEN Token with release write permission
|
||||
GITEA_TITLE Release title, default TAG
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tag="${1:-}"
|
||||
if [ -z "$tag" ]; then
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
shift
|
||||
|
||||
base="${GITEA_URL:-https://git.palav.dev}"
|
||||
repo="${GITEA_REPO:-Palav/dosh}"
|
||||
token="${GITEA_TOKEN:-}"
|
||||
title="${GITEA_TITLE:-$tag}"
|
||||
|
||||
if [ -z "$token" ]; then
|
||||
echo "GITEA_TOKEN is required" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
set -- target/dosh-release/dosh-*
|
||||
fi
|
||||
|
||||
api="$base/api/v1/repos/$repo"
|
||||
auth_header="Authorization: token $token"
|
||||
|
||||
release_json="$(curl -fsS -H "$auth_header" "$api/releases/tags/$tag" || true)"
|
||||
release_id="$(printf '%s\n' "$release_json" | sed -n 's/.*"id":[[:space:]]*\([0-9][0-9]*\).*/\1/p' | sed -n '1p')"
|
||||
|
||||
if [ -z "$release_id" ]; then
|
||||
payload="$(printf '{"tag_name":"%s","target_commitish":"main","name":"%s","body":"Dosh release %s","draft":false,"prerelease":false}\n' "$tag" "$title" "$tag")"
|
||||
release_json="$(curl -fsS -H "$auth_header" -H 'Content-Type: application/json' -X POST "$api/releases" -d "$payload")"
|
||||
release_id="$(printf '%s\n' "$release_json" | sed -n 's/.*"id":[[:space:]]*\([0-9][0-9]*\).*/\1/p' | sed -n '1p')"
|
||||
fi
|
||||
|
||||
if [ -z "$release_id" ]; then
|
||||
echo "could not determine Gitea release id for $tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for artifact in "$@"; do
|
||||
if [ ! -f "$artifact" ]; then
|
||||
continue
|
||||
fi
|
||||
name="$(basename "$artifact")"
|
||||
echo "uploading $name"
|
||||
curl -fsS \
|
||||
-H "$auth_header" \
|
||||
-X POST \
|
||||
-F "attachment=@$artifact" \
|
||||
"$api/releases/$release_id/assets?name=$name" >/dev/null
|
||||
done
|
||||
Reference in New Issue
Block a user