Skip to content
Open
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
16 changes: 14 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
target: aarch64-apple-darwin
asset_os: darwin
asset_arch: aarch64
- runner: windows-latest
target: x86_64-pc-windows-msvc
asset_os: windows
asset_arch: x86_64

steps:
- uses: actions/checkout@v6
Expand All @@ -43,11 +47,19 @@ jobs:
- name: Package
shell: bash
run: |
# GITHUB_REF_NAME is the branch on workflow_dispatch, and a branch
# name containing "/" turned the archive into a nested path that does
# not exist, failing Package on every target. Tags are unaffected.
version="${GITHUB_REF_NAME#v}"
version="${version//\//-}"
archive="gnit-${version}-${{ matrix.asset_os }}-${{ matrix.asset_arch }}.tar.gz"
mkdir -p dist package
cp "target/${{ matrix.target }}/release/gnit" package/gnit
tar -C package -czf "dist/${archive}" gnit
bin="gnit"
if [ "${{ matrix.asset_os }}" = "windows" ]; then
bin="gnit.exe"
fi
cp "target/${{ matrix.target }}/release/${bin}" "package/${bin}"
tar -C package -czf "dist/${archive}" "${bin}"
- uses: actions/upload-artifact@v7
with:
name: gnit-${{ matrix.asset_os }}-${{ matrix.asset_arch }}
Expand Down
23 changes: 18 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -eu

REPO="mostlydev/gnit"
INSTALL_DIR="${GNIT_INSTALL_DIR:-$HOME/.local/bin}"
BIN_NAME="gnit"

info() { printf ' %s\n' "$@"; }
err() { printf 'Error: %s\n' "$@" >&2; exit 1; }
Expand All @@ -12,6 +13,10 @@ OS="$(uname -s)"
case "$OS" in
Linux*) OS="linux" ;;
Darwin*) OS="darwin" ;;
# Git Bash, MSYS2, and Cygwin all report a decorated name here. They are the
# only shells present on a stock Windows dev box, so this is how gnit gets
# installed on Windows at all.
MINGW*|MSYS*|CYGWIN*|Windows_NT) OS="windows" ;;
*) err "Unsupported OS: $OS" ;;
esac

Expand All @@ -22,12 +27,16 @@ case "$ARCH" in
if [ "$OS" = "darwin" ]; then
ARCH="aarch64"
else
err "Unsupported architecture until a linux/aarch64 release is published: $ARCH"
err "Unsupported architecture until a ${OS}/aarch64 release is published: $ARCH"
fi
;;
*) err "Unsupported architecture: $ARCH" ;;
esac

if [ "$OS" = "windows" ]; then
BIN_NAME="gnit.exe"
fi

info "Detected platform: ${OS}/${ARCH}"
info "Fetching latest release..."

Expand Down Expand Up @@ -71,17 +80,17 @@ fi

mkdir -p "$INSTALL_DIR"
tar -xzf "${TMPDIR}/${TARBALL}" -C "$TMPDIR"
mv "${TMPDIR}/gnit" "${INSTALL_DIR}/gnit"
chmod +x "${INSTALL_DIR}/gnit"
mv "${TMPDIR}/${BIN_NAME}" "${INSTALL_DIR}/${BIN_NAME}"
chmod +x "${INSTALL_DIR}/${BIN_NAME}"

info "Installed gnit to ${INSTALL_DIR}/gnit"
info "Installed gnit to ${INSTALL_DIR}/${BIN_NAME}"

# Clean up a pre-rename install (this tool shipped as "nit" through v0.8.2).
# Other projects also ship a binary named "nit", so only remove artifacts we
# can verify are ours: the binary by its exact version-line format, skill
# links by resolving into our legacy data directory.
LEGACY_BIN="${INSTALL_DIR}/nit"
if [ -x "$LEGACY_BIN" ] && [ ! -d "$LEGACY_BIN" ]; then
if [ "$OS" != "windows" ] && [ -x "$LEGACY_BIN" ] && [ ! -d "$LEGACY_BIN" ]; then
LEGACY_VERSION="$("$LEGACY_BIN" --version 2>/dev/null || true)"
if printf '%s' "$LEGACY_VERSION" | grep -qE '^nit 0\.[0-9]+\.[0-9]+$'; then
rm -f "$LEGACY_BIN"
Expand Down Expand Up @@ -114,6 +123,10 @@ case ":$PATH:" in
info "${INSTALL_DIR} is not in your PATH."
info "Add it with:"
info " export PATH=\"${INSTALL_DIR}:\$PATH\""
if [ "$OS" = "windows" ]; then
info "For cmd.exe and PowerShell as well, add it persistently:"
info " setx PATH \"%PATH%;$(cd "$INSTALL_DIR" && pwd -W 2>/dev/null || echo "$INSTALL_DIR")\""
fi
;;
esac

Expand Down