Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: marwanhawari/stew
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.0
Choose a base ref
...
head repository: marwanhawari/stew
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Feb 9, 2022

  1. add tests

    marwanhawari committed Feb 9, 2022
    Copy the full SHA
    8497d44 View commit details
  2. update tests

    marwanhawari committed Feb 9, 2022
    Copy the full SHA
    e014911 View commit details
  3. Copy the full SHA
    9cecf5e View commit details

Commits on Feb 15, 2022

  1. Copy the full SHA
    cf68ef5 View commit details
  2. update README.md

    marwanhawari committed Feb 15, 2022
    Copy the full SHA
    2f6a9dd View commit details

Commits on Feb 24, 2022

  1. Copy the full SHA
    b807ce8 View commit details
  2. Copy the full SHA
    16d6fdb View commit details

Commits on Feb 25, 2022

  1. Updated: getGithubSearchJSON() to include forks

    typkrft committed Feb 25, 2022
    Copy the full SHA
    ab2531f View commit details
  2. Merge pull request #6 from typkrft/main

    Updated: getGithubSearchJSON() to include forks
    marwanhawari authored Feb 25, 2022
    Copy the full SHA
    26d3b35 View commit details

Commits on Mar 5, 2022

  1. Copy the full SHA
    60ed1d3 View commit details
  2. add 'rename' subcommand

    marwanhawari committed Mar 5, 2022
    Copy the full SHA
    1c86269 View commit details
  3. Copy the full SHA
    62e9c91 View commit details
  4. Copy the full SHA
    d91fd27 View commit details
  5. Merge pull request #7 from marwanhawari/allow_rename_3

    Allow renaming of binaries
    marwanhawari authored Mar 5, 2022
    Copy the full SHA
    528fe6d View commit details

Commits on Mar 7, 2022

  1. Copy the full SHA
    a7e8b6a View commit details
  2. add config subcommand

    marwanhawari committed Mar 7, 2022
    Copy the full SHA
    091b366 View commit details
  3. update tests

    marwanhawari committed Mar 7, 2022
    Copy the full SHA
    aa5c4a7 View commit details
  4. Copy the full SHA
    91aee6d View commit details
  5. Merge pull request #8 from marwanhawari/xdg_spec_4

    Allow user configuration and support XDG spec by default
    marwanhawari authored Mar 7, 2022
    Copy the full SHA
    f80e9d3 View commit details

Commits on Mar 8, 2022

  1. update default stewBinPath, add config prompt on initial use, add war…

    …ning if stewBinPath not in PATH
    marwanhawari committed Mar 8, 2022
    Copy the full SHA
    67466f6 View commit details
  2. update docs

    marwanhawari committed Mar 8, 2022
    Copy the full SHA
    047fd52 View commit details
  3. add brew to goreleaser

    marwanhawari committed Mar 8, 2022
    Copy the full SHA
    90c747e View commit details
  4. Merge pull request #9 from marwanhawari/config_updates

    Config updates
    marwanhawari authored Mar 8, 2022
    Copy the full SHA
    15ef84b View commit details
  5. bump version to v0.3.0

    marwanhawari committed Mar 8, 2022
    Copy the full SHA
    f6878c9 View commit details
  6. fix curl install script

    marwanhawari committed Mar 8, 2022
    Copy the full SHA
    4fc13dc View commit details

Commits on Mar 14, 2022

  1. Copy the full SHA
    cffaf0f View commit details
  2. Copy the full SHA
    7fe8e85 View commit details

Commits on Jul 23, 2022

  1. add ability to install from stewfile.lock.json

    kencx committed Jul 23, 2022
    Copy the full SHA
    484af1d View commit details

Commits on Jul 24, 2022

  1. Merge pull request #15 from kencx/installLockFile

    add ability to install from stewfile.lock.json
    marwanhawari authored Jul 24, 2022
    Copy the full SHA
    34945f2 View commit details

Commits on Aug 10, 2023

  1. Copy the full SHA
    13c55d1 View commit details

Commits on Jan 22, 2024

  1. Copy the full SHA
    0429936 View commit details

Commits on Mar 31, 2024

  1. Copy the full SHA
    dc0a3c7 View commit details

Commits on Apr 1, 2024

  1. Copy the full SHA
    b86e6a3 View commit details

Commits on Apr 2, 2024

  1. Copy the full SHA
    94c9ec2 View commit details
  2. Copy the full SHA
    0a27356 View commit details
  3. Copy the full SHA
    612bece View commit details

Commits on Apr 5, 2024

  1. Copy the full SHA
    ce007fb View commit details
  2. Copy the full SHA
    91895c8 View commit details
  3. Copy the full SHA
    2b6a2b8 View commit details

Commits on Apr 6, 2024

  1. Handle tgz (#28)

    hannah98 authored Apr 6, 2024
    Copy the full SHA
    ab96998 View commit details
  2. Copy the full SHA
    434edcc View commit details

Commits on Apr 7, 2024

  1. Copy the full SHA
    ce6d663 View commit details
  2. Copy the full SHA
    484b5f6 View commit details
  3. Copy the full SHA
    ed3f20f View commit details
  4. Copy the full SHA
    a9bedcc View commit details
  5. Copy the full SHA
    976c6a6 View commit details
  6. v0.4.0

    marwanhawari committed Apr 7, 2024
    Copy the full SHA
    ee8dd38 View commit details
  7. Copy the full SHA
    79280da View commit details

Commits on Jan 19, 2025

  1. Copy the full SHA
    81d6e1f View commit details
  2. Copy the full SHA
    16325c5 View commit details
Showing 631 changed files with 138,695 additions and 15,015 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
go-version: [1.17]
go-version: [1.22]

steps:
- uses: actions/checkout@v2
@@ -21,9 +21,15 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: Test and calculate coverage
run: go test -v ./... --coverprofile coverage.out
run: go test -v ./lib --coverprofile coverage.out
- name: Read the coverage
run: go tool cover --func coverage.out
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=coverage.out -service=github

goreleaser:
needs: [test]
@@ -38,14 +44,14 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.22
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ name: test
on:
push:
branches:
- '**'
- main
tags-ignore:
- v*
pull_request:
@@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
go-version: [1.17]
go-version: [1.22]

steps:
- uses: actions/checkout@v2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Stew binary
stew

# Binaries for programs and plugins
*.exe
*.exe~
29 changes: 26 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -13,9 +13,32 @@ builds:
- "amd64"
- "386"
archives:
- format: "binary"
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
- name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
checksum:
name_template: "checksums.txt"
changelog:
skip: true
disable: true
nfpms:
- builds:
- stew
vendor: marwanhawari
homepage: "https://github.com/marwanhawari/stew"
maintainer: "Marwan Hawari <marwan.hawari@gmail.com>"
description: "An independent package manager for compiled binaries"
license: MIT
formats:
- apk
- deb
- rpm
bindir: /usr/bin
brews:
- repository:
owner: marwanhawari
name: homebrew-tap
directory: Formula
commit_author:
name: Marwan Hawari
email: marwan.hawari@gmail.com
license: "MIT"
homepage: "https://github.com/marwanhawari/stew"
description: "An independent package manager for compiled binaries"
133 changes: 111 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,49 +7,113 @@
An independent package manager for compiled binaries.
</p>
<p align="center">
<img src="https://github.com/marwanhawari/stew/actions/workflows/test.yml/badge.svg" alt="build status"/>
<img src="https://goreportcard.com/badge/github.com/marwanhawari/stew" alt="go report card"/>
<img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="code of conduct"/>
<img src="https://img.shields.io/github/license/marwanhawari/stew?color=blue" alt="license"/>

<a href="https://github.com/marwanhawari/stew/actions/">
<img src="https://github.com/marwanhawari/stew/actions/workflows/test.yml/badge.svg" alt="build status"/>
</a>

<a href="https://goreportcard.com/report/github.com/marwanhawari/stew">
<img src="https://goreportcard.com/badge/github.com/marwanhawari/stew" alt="go report card"/>
</a>

<a href='https://coveralls.io/github/marwanhawari/stew?branch=main'>
<img src='https://coveralls.io/repos/github/marwanhawari/stew/badge.svg?branch=main' alt='Coverage Status'/>
</a>

<a href="https://pkg.go.dev/github.com/marwanhawari/stew">
<img src="https://pkg.go.dev/badge/github.com/marwanhawari/stew.svg" alt="pkg.go.dev reference"/>
</a>

<a href="https://github.com/avelino/awesome-go">
<img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Go"/>
</a>

</p>


# Features
* Install binaries from GitHub releases or directly from URLs
* Install binaries from GitHub releases or directly from URLs.
* Easily distribute binaries across teams and private repositories.
* Get the latest releases ahead of other package managers.
* Rapidly browse, install, and experiment with different projects.
* Isolated `~/.stew/` directory.
* [Configure](https://github.com/marwanhawari/stew/blob/main/config.md) where to install binaries.
* No need for `sudo`.
* Just a single binary with 0 dependencies.
* Portable [`Stewfile`](https://github.com/marwanhawari/stew/blob/main/examples/Stewfile) with optional pinned versioning.
* Headless batch installs from a `Stewfile.lock.json` file.

![demo](https://github.com/marwanhawari/stew/raw/main/assets/demo.gif)

# Installation
Stew supports Linux, macOS, and Windows:
```
curl -fsSL https://raw.githubusercontent.com/marwanhawari/stew/main/install.sh | sh
```
Stew supports macOS, Linux, and Windows.

### Install using a package manager
<details>
<summary>macOS</summary>

```sh
brew install marwanhawari/tap/stew
```
</details>

<details>
<summary>Arch</summary>

```sh
git clone https://aur.archlinux.org/stew.git
cd stew
makepkg -sric
```
</details>

### Download a compiled binary
Compiled binaries can be downloaded from the [releases page](https://github.com/marwanhawari/stew/releases).

### Install using Go
<details>
<summary>Install the latest released version</summary>

```sh
go install github.com/marwanhawari/stew@latest
```
</details>

<details>
<summary>Install the latest unreleased source</summary>

```sh
git clone https://github.com/marwanhawari/stew
cd stew
go install .
```
</details>

# Usage
### Install
```sh
# Install from GitHub releases
stew install junegunn/fzf # Install the latest release
stew install junegunn/fzf@0.27.1 # Install a specific, tagged version
stew install junefunn/fzf sharkdp/fd # Install multiple binaries in a single command

# Install directly from a URL
stew install https://github.com/cli/cli/releases/download/v2.4.0/gh_2.4.0_macOS_amd64.tar.gz

# Install from an Stewfile
stew install Stewfile

# Install headlessly from a Stewfile.lock.json
stew install Stewfile.lock.json

# Install mutliple binaries per repo/asset
stew install astral-sh/uv # Install uv the first time
stew install astral-sh/uv # Install uvx the second time
```

### Search
```sh
# Search for a GitHub repo and browse its contents with a terminal UI
stew search ripgrep
stew search fzf user:junegunn language:go # Use GitHub search syntax
```

### Browse
@@ -72,28 +136,53 @@ stew uninstall rg # Uninstall using the name of the binary directly
stew uninstall --all # Uninstall all binaries
```

### Rename
```sh
# Rename an installed binary using an interactive UI
stew rename rg # Rename using the name of the binary directly
```

### List
```sh
# List installed binaries
stew list # Print to console
stew list > Stewfile # Create an Stewfile without pinned tags
stew list --tags > Stewfile # Pin tags
stew list --tags --assets > Stewfile # Pin tags and assets
```

### Config
```sh
# Configure the stew file paths using an interactive UI
stew config # Automatically updates the stew.config.json
```

# Configuration
`stew` can be configured with a `stew.config.json` file. The location of this file will also depend on your OS:
|Linux/macOS | Windows |
| ------------ | ---------- |
| `$XDG_CONFIG_HOME/stew` or `~/.config/stew` | `~/AppData/Local/stew/Config` |

You can configure 2 aspects of `stew`:
1. The `stewPath`: this is where `stew` data is stored.
2. The `stewBinPath`: this is where `stew` installs binaries
3. `excludeFromUpgradeAll`: this is the list of binaries that you don't want to be upgraded during `stew upgrade --all`, perhaps because they have their own built in upgrade feature or because you want to pin a specific version.

The default locations for the `stewPath` and `stewBinPath` are:
| | Linux/macOS | Windows |
| ------------ | ------------ | ---------- |
| `stewPath` | `$XDG_DATA_HOME/stew` or `~/.local/share/stew` | `~/AppData/Local/stew` |
| `stewBinPath` | `~/.local/bin` | `~/AppData/Local/stew/bin` |

There are multiple ways to configure these:
* When you first run `stew`, it will look for a `stew.config.json` file. If it cannot find one, then you will be prompted to set the configuration values.
* After `stew` is installed, you can use the `stew config` command to set the configuration values.
* At any time, you can manually create or edit the `stew.config.json` file. It should have values for `stewPath`, `stewBinPath`, and `excludeFromUpgradeAll`.

Make sure that the installation path is in your `PATH` environment variable. Otherwise, you won't be able to use any of the binaries installed by `stew`.

# FAQ
### Why couldn't `stew` automatically find any binaries for X repo?
The repo probably uses an unconventional naming scheme for their binaries. You can always manually select the release asset.

### I've installed `stew` but the command is still not found.
The `stew` [install script](https://github.com/marwanhawari/stew/blob/main/install.sh) attempts to add `~/.stew/bin` to `PATH` in your `.zshrc` or `.bashrc` file. You will also need to start a new terminal session for the changes to take effect. Make sure that `~/.stew/bin` is in your `PATH` environment variable.

### Will `stew` work with private GitHub repositories?
Yes, `stew` will automatically detect if you have a `GITHUB_TOKEN` environment variable and allow you to access binaries from your private repositories.

### How do I uninstall `stew`?
Simply run `rm -rf $HOME/.stew/` and optionally remove this line
```
export PATH="$HOME/.stew/bin:$PATH"
```
from your `.zshrc` or `.bashrc` file.
Binary file modified assets/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 16 additions & 23 deletions cmd/browse.go
Original file line number Diff line number Diff line change
@@ -3,21 +3,20 @@ package cmd
import (
"fmt"
"os"
"path"
"path/filepath"

"github.com/marwanhawari/stew/constants"
stew "github.com/marwanhawari/stew/lib"
)

// Browse is executed when you run `stew browse`
func Browse(cliInput string) {
sp := constants.LoadingSpinner

systemInfo, err := stew.NewSystemInfo()
userOS, userArch, _, systemInfo, err := stew.Initialize()
stew.CatchAndExit(err)

userOS := systemInfo.Os
userArch := systemInfo.Arch
sp := constants.LoadingSpinner

stewBinPath := systemInfo.StewBinPath
stewPkgPath := systemInfo.StewPkgPath
stewLockFilePath := systemInfo.StewLockFilePath
@@ -56,32 +55,26 @@ func Browse(cliInput string) {
assetIndex, _ := stew.Contains(releaseAssets, asset)

downloadURL := githubProject.Releases[tagIndex].Assets[assetIndex].DownloadURL
downloadPath := path.Join(stewPkgPath, asset)
downloadPathExists, err := stew.PathExists(downloadPath)
downloadPath := filepath.Join(stewPkgPath, asset)
err = stew.DownloadFile(downloadPath, downloadURL)
stew.CatchAndExit(err)
fmt.Printf("✅ Downloaded %v to %v\n", constants.GreenColor(asset), constants.GreenColor(stewPkgPath))

if downloadPathExists {
stew.CatchAndExit(stew.AssetAlreadyDownloadedError{Asset: asset})
} else {
err = stew.DownloadFile(downloadPath, downloadURL)
stew.CatchAndExit(err)
fmt.Printf("✅ Downloaded %v to %v\n", constants.GreenColor(asset), constants.GreenColor(stewPkgPath))
}

binaryName, err := stew.InstallBinary(downloadPath, repo, systemInfo, &lockFile, false)
binaryName, binaryHash, err := stew.InstallBinary(downloadPath, repo, systemInfo, &lockFile, false, "", "")
if err != nil {
os.RemoveAll(downloadPath)
stew.CatchAndExit(err)
}

packageData := stew.PackageData{
Source: "github",
Owner: githubProject.Owner,
Repo: githubProject.Repo,
Tag: tag,
Asset: asset,
Binary: binaryName,
URL: downloadURL,
Source: "github",
Owner: githubProject.Owner,
Repo: githubProject.Repo,
Tag: tag,
Asset: asset,
Binary: binaryName,
URL: downloadURL,
BinaryHash: binaryHash,
}

lockFile.Packages = append(lockFile.Packages, packageData)
Loading