Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ jobs:
run: cargo test --locked
- name: Web API types are current
run: cargo test --locked --features ts --test ts_bindings
# install.sh (POSIX sh): shellcheck, then an install of the debug
# binary from a local release fixture under dash (no network).
- name: Install script
run: |
shellcheck install.sh scripts/test_install.sh
cargo build --locked -p axe-os
scripts/test_install.sh target/debug/axe
# Release gate only (full): the feature variants.
- name: Clippy (no default features)
if: inputs.full
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ run-name: release ${{ github.ref_name }}${{ !startsWith(github.ref, 'refs/tags/v
# - axe-<tag>-macos-aarch64.tar.gz: a macOS arm64 `axe` (default features),
# built by the `macos` job on a GitHub-hosted runner
# - axe-skills-<tag>.tar.gz: skills/axe
# - install.sh, the one-line installer (releases/latest/download/install.sh)
# - a .sha256 file per asset and SHA256SUMS
# The `gate` job first runs ci.yml in full on GitHub-hosted runners (feature
# variants, embed-ui, web); nothing is built or published unless it passes,
Expand Down Expand Up @@ -177,9 +178,10 @@ jobs:
tar --sort=name --owner=0 --group=0 --numeric-owner -czf "$dist/$bin" -C "$stage/bin" axe LICENSE-MIT LICENSE-APACHE README.md
tar --sort=name --owner=0 --group=0 --numeric-owner -czf "$dist/$mac" -C "$stage/macos" axe LICENSE-MIT LICENSE-APACHE README.md
tar --sort=name --owner=0 --group=0 --numeric-owner -czf "$dist/$skills" -C skills axe
install -m 755 install.sh "$dist/install.sh"
cd "$dist"
for f in "$bin" "$mac" "$skills"; do sha256sum "$f" > "$f.sha256"; done
sha256sum "$bin" "$mac" "$skills" > SHA256SUMS
for f in "$bin" "$mac" "$skills" install.sh; do sha256sum "$f" > "$f.sha256"; done
sha256sum "$bin" "$mac" "$skills" install.sh > SHA256SUMS
sha256sum -c SHA256SUMS
{
echo "axe $VERSION, commit $GITHUB_SHA."
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ server.

## Install

```sh
curl -fsSL https://axe-os.io/install.sh | sh
```

Then ask your coding agent to set up axe: the installer also installs the
agent skill it follows. [`install.sh`](install.sh) (the
release asset `https://github.com/popodidi/axe/releases/latest/download/install.sh`,
which that URL redirects to) installs the Linux x86_64 or macOS arm64 release
binary to `~/.local/bin` after checking it against the release's
`SHA256SUMS`, then runs `axe skill install`; its header lists the settings
(`AXE_VERSION`, `AXE_INSTALL_DIR`). Other platforms, or a build from source:

```sh
cargo install --locked --git https://github.com/popodidi/axe axe-os # binary `axe`
```
Expand Down
12 changes: 12 additions & 0 deletions docs/user/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ title: "Install"
description: "Install axe, verify a release, and keep the binary and its agent skill current."
---

```sh
curl -fsSL https://axe-os.io/install.sh | sh
```

Then ask your coding agent to set up axe: the installer also installs the
agent skill it follows. [`install.sh`](../../../install.sh) (the
release asset `https://github.com/popodidi/axe/releases/latest/download/install.sh`,
which that URL redirects to) installs the Linux x86_64 or macOS arm64 release
binary to `~/.local/bin` after checking it against the release's
`SHA256SUMS`, then runs `axe skill install`; its header lists the settings
(`AXE_VERSION`, `AXE_INSTALL_DIR`). Other platforms, or a build from source:

```sh
cargo install --locked --git https://github.com/popodidi/axe axe-os # binary `axe`
```
Expand Down
94 changes: 94 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/sh
# Install the axe binary and its agent skill.
#
# curl -fsSL https://axe-os.io/install.sh | sh
#
# Downloads the release tarball for this platform (Linux x86_64, macOS arm64),
# checks it against the release's SHA256SUMS, installs `axe` to ~/.local/bin
# and runs `axe skill install`. No sudo; shell rc files are left alone.
#
# AXE_VERSION=vX.Y.Z a specific release (default: the latest)
# AXE_INSTALL_DIR=DIR where `axe` goes (default: ~/.local/bin)
# AXE_RELEASES_URL=URL release download base (default: GitHub releases;
# scripts/test_install.sh points it at a fixture)
set -eu

repo=popodidi/axe
releases=${AXE_RELEASES_URL:-https://github.com/$repo/releases}
version=${AXE_VERSION:-}
install_dir=${AXE_INSTALL_DIR:-$HOME/.local/bin}

say() { printf 'axe: %s\n' "$*" >&2; }
die() { say "error: $*"; exit 1; }

command -v curl >/dev/null 2>&1 || die "curl is required"
fetch() { curl -fsSL --retry 2 -o "$2" "$1"; }

if [ -n "$version" ]; then
case $version in v*) ;; *) version=v$version ;; esac
sums_url=$releases/download/$version/SHA256SUMS
else
sums_url=$releases/latest/download/SHA256SUMS
fi

tmp=$(mktemp -d 2>/dev/null || mktemp -d -t axe-install)
trap 'rm -rf "$tmp"' EXIT
trap 'exit 1' HUP INT TERM

# The release's SHA256SUMS names every asset with its tag, so it also
# resolves the latest tag without the GitHub API.
fetch "$sums_url" "$tmp/SHA256SUMS" || die "could not download $sums_url"
tag=$(sed -n 's/.*[ *]axe-skills-\(v[^ ]*\)\.tar\.gz$/\1/p' "$tmp/SHA256SUMS" | head -n 1)
[ -n "$tag" ] || die "no release tag in $sums_url"

os=$(uname -s)
arch=$(uname -m)
# A Rosetta shell on Apple silicon reports x86_64.
if [ "$os" = Darwin ] && [ "$arch" = x86_64 ] \
&& [ "$(sysctl -n hw.optional.arm64 2>/dev/null || true)" = 1 ]; then
arch=arm64
fi
case $os/$arch in
Linux/x86_64 | Linux/amd64) platform=linux-x86_64 ;;
Darwin/arm64 | Darwin/aarch64) platform=macos-aarch64 ;;
*)
say "no release binary for $os $arch; install from source with Rust:"
printf '\n cargo install --locked --git https://github.com/%s --tag %s axe-os\n\n' "$repo" "$tag" >&2
exit 1
;;
esac

asset=axe-$tag-$platform.tar.gz
expected=$(awk -v f="$asset" '$2 == f || $2 == "*" f { print $1; exit }' "$tmp/SHA256SUMS")
[ -n "$expected" ] || die "$asset is not in $sums_url"

say "downloading axe $tag ($platform)"
fetch "$releases/download/$tag/$asset" "$tmp/$asset" || die "could not download $asset"

if command -v sha256sum >/dev/null 2>&1; then
actual=$(sha256sum "$tmp/$asset" | awk '{ print $1 }')
elif command -v shasum >/dev/null 2>&1; then
actual=$(shasum -a 256 "$tmp/$asset" | awk '{ print $1 }')
else
die "sha256sum or shasum is required to check the download"
fi
[ "$actual" = "$expected" ] || die "checksum mismatch for $asset (expected $expected, got $actual); nothing installed"

mkdir -p "$tmp/x"
tar -xzf "$tmp/$asset" -C "$tmp/x" axe || die "$asset has no axe binary"
mkdir -p "$install_dir"
# Replace through a rename so a running axe is not overwritten in place.
cp "$tmp/x/axe" "$install_dir/.axe.new"
chmod 755 "$install_dir/.axe.new"
mv -f "$install_dir/.axe.new" "$install_dir/axe"
say "installed $("$install_dir/axe" --version) to $install_dir/axe"

"$install_dir/axe" skill install

case ":$PATH:" in
*":$install_dir:"*) ;;
*) say "$install_dir is not on your PATH; add it in your shell profile: export PATH=\"$install_dir:\$PATH\"" ;;
esac

echo
echo "Done. Now ask your coding agent to set up axe."
76 changes: 76 additions & 0 deletions scripts/test_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/sh
# Smoke test for install.sh against a local release fixture (no network):
# a tarball of the given axe binary plus SHA256SUMS, served as file:// URLs.
#
# Usage: scripts/test_install.sh <axe-binary> (Linux x86_64)
set -eu

bin=${1:?usage: scripts/test_install.sh <axe-binary>}
root=$(cd "$(dirname "$0")/.." && pwd)
script=$root/install.sh
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT

tag=v9.9.9
rel=$work/releases
stage=$work/stage
mkdir -p "$rel/download/$tag" "$rel/latest/download" "$stage"
cp "$bin" "$stage/axe"
tar -czf "$rel/download/$tag/axe-$tag-linux-x86_64.tar.gz" -C "$stage" axe
printf 'skills\n' > "$rel/download/$tag/axe-skills-$tag.tar.gz"
(cd "$rel/download/$tag" && sha256sum axe-*.tar.gz > SHA256SUMS)
cp "$rel/download/$tag/SHA256SUMS" "$rel/latest/download/SHA256SUMS"

fail() { echo "FAIL: $*" >&2; exit 1; }

# run <home> <path> [VAR=value...]: install.sh under sh with a clean environment.
run() {
home=$1 path=$2
shift 2
mkdir -p "$home"
env -i HOME="$home" PATH="$path" AXE_RELEASES_URL="file://$rel" "$@" sh "$script" > "$work/out" 2>&1
}

base_path=/usr/local/bin:/usr/bin:/bin

# 1. The latest release into a scratch HOME's ~/.local/bin, with the skill.
h=$work/home1
run "$h" "$base_path" || { cat "$work/out"; fail "latest install exited non-zero"; }
"$h/.local/bin/axe" --version > /dev/null || fail "installed axe --version"
test -f "$h/.agents/skills/axe/SKILL.md" || fail "skill not installed"
grep -q 'is not on your PATH' "$work/out" || fail "no PATH hint"
tail -n 1 "$work/out" | grep -q 'ask your coding agent to set up axe' || fail "no closing line"
echo "ok: latest install"

# 2. A pinned version (without the v) into AXE_INSTALL_DIR, already on PATH.
h=$work/home2
run "$h" "$h/bin:$base_path" AXE_VERSION=9.9.9 AXE_INSTALL_DIR="$h/bin" \
|| { cat "$work/out"; fail "pinned install exited non-zero"; }
"$h/bin/axe" --version > /dev/null || fail "pinned axe --version"
! grep -q 'is not on your PATH' "$work/out" || fail "PATH hint with the dir on PATH"
echo "ok: AXE_VERSION and AXE_INSTALL_DIR"

# 3. A checksum mismatch aborts before installing anything.
h=$work/home3
awk '/linux/ { $1 = sprintf("%064d", 0) } { print $1 " " $2 }' \
"$rel/download/$tag/SHA256SUMS" > "$rel/latest/download/SHA256SUMS"
if run "$h" "$base_path"; then cat "$work/out"; fail "bad checksum did not fail"; fi
grep -q 'checksum mismatch' "$work/out" || { cat "$work/out"; fail "no checksum message"; }
test ! -e "$h/.local/bin/axe" || fail "installed despite a bad checksum"
cp "$rel/download/$tag/SHA256SUMS" "$rel/latest/download/SHA256SUMS"
echo "ok: bad checksum aborts"

# 4. An unsupported platform gets the cargo fallback and a non-zero exit.
h=$work/home4
fake=$work/fake-uname
mkdir -p "$fake"
cat > "$fake/uname" <<'EOF'
#!/bin/sh
case "$1" in -s) echo Linux ;; -m) echo aarch64 ;; esac
EOF
chmod 755 "$fake/uname"
if run "$h" "$fake:$base_path"; then cat "$work/out"; fail "unsupported platform did not fail"; fi
grep -q "cargo install --locked --git https://github.com/popodidi/axe --tag $tag axe-os" "$work/out" \
|| { cat "$work/out"; fail "no cargo fallback"; }
test ! -e "$h/.local/bin/axe" || fail "installed on an unsupported platform"
echo "ok: unsupported platform"
Loading