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
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
[![Image Size](https://badges.cssnr.com/ghcr/size/smashedr/install-release)](https://github.com/smashedr/install-release/pkgs/container/install-release)
[![Go Version](https://img.shields.io/github/go-mod/go-version/smashedr/install-release?logo=go&logoColor=white&label=go)](https://github.com/smashedr/install-release/blob/master/go.mod)
[![Deployment Docs](https://img.shields.io/github/deployments/smashedr/install-release/docs?logo=materialformkdocs&logoColor=white&label=docs)](https://github.com/smashedr/install-release/deployments/docs)
[![Deployment Preview](https://img.shields.io/github/deployments/smashedr/install-release/preview?logo=materialformkdocs&logoColor=white&label=preview)](https://github.com/smashedr/install-release/deployments/preview)
[![Workflow Release](https://img.shields.io/github/actions/workflow/status/smashedr/install-release/release.yaml?logo=testcafe&logoColor=white&label=release)](https://github.com/smashedr/install-release/actions/workflows/release.yaml)
[![Workflow Lint](https://img.shields.io/github/actions/workflow/status/smashedr/install-release/lint.yaml?logo=testcafe&logoColor=white&label=lint)](https://github.com/smashedr/install-release/actions/workflows/lint.yaml)
[![Deployment Preview](https://img.shields.io/github/deployments/smashedr/install-release/preview?logo=labex&logoColor=white&label=preview)](https://github.com/smashedr/install-release/deployments/preview)
[![Workflow Release](https://img.shields.io/github/actions/workflow/status/smashedr/install-release/release.yaml?logo=norton&logoColor=white&label=release)](https://github.com/smashedr/install-release/actions/workflows/release.yaml)
[![Workflow Lint](https://img.shields.io/github/actions/workflow/status/smashedr/install-release/lint.yaml?logo=norton&logoColor=white&label=lint)](https://github.com/smashedr/install-release/actions/workflows/lint.yaml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/smashedr/install-release?logo=listenhub&label=updated)](https://github.com/smashedr/install-release/pulse)
[![GitHub Repo Size](https://img.shields.io/github/repo-size/smashedr/install-release?logo=buffer&label=repo%20size)](https://github.com/smashedr/install-release?tab=readme-ov-file#readme)
[![GitHub Repo Size](https://img.shields.io/github/repo-size/smashedr/install-release?logo=googlecloudstorage&logoColor=white&label=repo%20size)](https://github.com/smashedr/install-release?tab=readme-ov-file#readme)
[![GitHub Top Language](https://img.shields.io/github/languages/top/smashedr/install-release?logo=devbox)](https://github.com/smashedr/install-release?tab=readme-ov-file#readme)
[![GitHub Contributors](https://img.shields.io/github/contributors-anon/smashedr/install-release?logo=southwestairlines)](https://github.com/smashedr/install-release/graphs/contributors)
[![GitHub Issues](https://img.shields.io/github/issues/smashedr/install-release?logo=codeforces&logoColor=white)](https://github.com/smashedr/install-release/issues)
Expand All @@ -31,21 +31,35 @@
<img alt="Install Release" align="right" width="128" height="auto" src="https://raw.githubusercontent.com/smashedr/install-release/refs/heads/master/docs/assets/images/logo.svg"></a>

- [Install](#install)
- [Features](#features)
- [Usage](#usage)
- [Development](#development)
- [Support](#Support)
- [Contributing](#contributing)

CLI to Install a GitHub Release.

Easily Install GitHub Release binaries with Windows, Linux and macOS Support.
Easily Install GitHub Release binaries on Windows, Linux and macOS.

Interactively select the release version, asset, and executable name with automatically detected presets.

[![VHS Tape](https://cssnr.s3.amazonaws.com/install-release/demo.gif)](https://smashedr.github.io/install-release/)

> [!IMPORTANT]
> This project is in development.
> It is functional but may have bugs.

## Features

- Supports Windows, Linux and macOS
- Interactively Select Options
- Set Options w/ Flags or Variables
- Save or Set a Custom `bin` Path
- List and Remove Installed Apps
- Get App Information

[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=quicklook)](https://smashedr.github.io/install-release/)

## Install

[![Latest Release](https://img.shields.io/github/v/release/smashedr/install-release?logo=github&label=latest%20release)](https://github.com/smashedr/install-release/releases)
Expand All @@ -60,7 +74,7 @@ brew install cssnr/tap/install-release
#### Bash

```shell
curl 'https://i.jpillora.com/smashedr/install-release!?as=ir' | bash
curl 'https://raw.githubusercontent.com/smashedr/install-release/refs/heads/master/scripts/install.sh' | bash
```

💾 Alternatively, you can manually [download a release](https://github.com/smashedr/install-release/releases).
Expand All @@ -87,7 +101,7 @@ docker run --rm -itv ~/bin:/out ghcr.io/smashedr/ir:latest -b /out smashedr/inst

_Note: Docker requires you to mount the target bin directory._

[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://smashedr.github.io/install-release/)
[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=quicklook)](https://smashedr.github.io/install-release/)

## Usage

Expand Down Expand Up @@ -169,7 +183,7 @@ Edit the settings.
ir config
```

[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://smashedr.github.io/install-release/)
[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=quicklook)](https://smashedr.github.io/install-release/)

# Development

Expand Down Expand Up @@ -225,8 +239,8 @@ For a full list of current projects visit: [https://cssnr.github.io/](https://cs

<a href="https://github.com/smashedr/install-release/stargazers">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=top-left&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=top-left" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=top-left" />
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=bottom-right&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=bottom-right" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=bottom-right" />
</picture>
</a>
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tasks:
- task: pslint

pslint:
desc: Invoke-ScriptAnalyzer does NOT exit with error!
platforms: [windows]
cmd: powershell -Command "Invoke-ScriptAnalyzer -Path scripts -Recurse"

Expand Down
14 changes: 14 additions & 0 deletions assets/main.tape
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ Type "ir smashedr/bup"
Sleep 0.5s
Enter

# select version
Wait / [0-9]\.[0-9]/
Sleep 1.5s
Down
Sleep 0.2s
Down
Sleep 0.5s
Up
Sleep 0.2s
Up
Sleep 0.5s
Enter
# select asset
Wait / bup_/
Sleep 1.5s
Up
Expand All @@ -14,6 +27,7 @@ Sleep 0.2s
Down
Sleep 0.5s
Enter
# set name
Wait /\> /
Sleep 1s
Backspace
Expand Down
5 changes: 4 additions & 1 deletion cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ var infoCmd = &cobra.Command{
}
log.Info("Repository", "owner", owner, "repo", repo, "tag", tag)
client := getClient()
release, err := getRelease(client, owner, repo, tag, preRelease)
release, err := getRelease(client, owner, repo, tag, preRelease, true)
if err != nil {
log.Fatalf("Error getting release: %v", err)
}
if release == nil {
log.Fatalf("No release found")
}
if verbose >= 3 {
log.Debugf("%v", release)
}
Expand Down
60 changes: 51 additions & 9 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ func runInstall(cmd *cobra.Command, args []string) error { // NOSONAR

client := getClient()

release, err := getRelease(client, owner, repo, tag, preRelease)
release, err := getRelease(client, owner, repo, tag, preRelease, skipPrompts)
if err != nil {
return fmt.Errorf("get release error: %w", err)
}
if release == nil {
return fmt.Errorf("no release found")
}
if verbose >= 3 {
log.Debugf("release: %v", release)
}
Expand Down Expand Up @@ -392,19 +395,22 @@ func getClient() *github.Client {
return github.NewClient(httpClient)
}

func getRelease(client *github.Client, owner, repo, tag string, pre bool) (*github.RepositoryRelease, error) {
func getRelease(client *github.Client, owner, repo, tag string, pre, skip bool) (*github.RepositoryRelease, error) {
ctx := context.Background()
var release *github.RepositoryRelease
var err error
if tag != "" {
log.Debugf("client.Repositories.GetReleaseByTag: %v", tag)
release, _, err = client.Repositories.GetReleaseByTag(ctx, owner, repo, tag)
} else if pre {
log.Debugf("GetLatestRelease - Including Pre-Releases")
log.Debugf("GetLatestRelease")
release, err = getLatestRelease(client, owner, repo)
} else {
} else if skip {
log.Debugf("client.Repositories.GetLatestRelease")
release, _, err = client.Repositories.GetLatestRelease(ctx, owner, repo)
} else {
log.Debugf("chooseRelease")
release, err = chooseRelease(client, owner, repo, 30)
}
if err != nil {
return nil, fmt.Errorf("get release error: %w", err)
Expand All @@ -413,16 +419,52 @@ func getRelease(client *github.Client, owner, repo, tag string, pre bool) (*gith
}

func getLatestRelease(client *github.Client, owner, repo string) (*github.RepositoryRelease, error) {
releases, err := getReleases(client, owner, repo, 1)
if err != nil {
return nil, err
}
if len(releases) == 0 {
return nil, nil
}
return releases[0], nil
}

func getReleases(client *github.Client, owner, repo string, number int) ([]*github.RepositoryRelease, error) {
ctx := context.Background()
releases, _, err := client.Repositories.ListReleases(ctx, owner, repo, &github.ListOptions{PerPage: 1})
releases, _, err := client.Repositories.ListReleases(ctx, owner, repo, &github.ListOptions{PerPage: number})
if err != nil {
return nil, err
}
if len(releases) > 0 {
return releases[0], nil
return releases, nil
}

func chooseRelease(client *github.Client, owner, repo string, number int) (*github.RepositoryRelease, error) {
releases, err := getReleases(client, owner, repo, number)
if err != nil {
return nil, fmt.Errorf("error getting releases: %w", err)
}

log.Debugf("releases: %v", len(releases))
var result1 int
options := make([]huh.Option[int], len(releases))
for i, release := range releases {
options[i] = huh.NewOption(release.GetTagName(), i)
}
// TODO: Consider returning an error here...
return nil, nil
form := huh.NewSelect[int]().
Title("Select a version:").
Options(options...).
Value(&result1)

err = form.Run()
if err != nil {
return nil, fmt.Errorf("prompt failed: %w", err)
}
log.Debugf("result1: %v", result1)

chosen := releases[result1]
log.Debugf("release: %v", chosen)
log.Debugf("tag: %v", chosen.GetTagName())
return chosen, nil
}

func ensureWinExt(destName string) string {
Expand Down
18 changes: 10 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ icon: lucide/rocket
[![Image Size](https://badges.cssnr.com/ghcr/size/smashedr/install-release)](https://github.com/smashedr/install-release/pkgs/container/install-release)
[![Go Version](https://img.shields.io/github/go-mod/go-version/smashedr/install-release?logo=go&logoColor=white&label=go)](https://github.com/smashedr/install-release/blob/master/go.mod)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/smashedr/install-release?logo=listenhub&label=updated)](https://github.com/smashedr/install-release/pulse)
[![GitHub Repo Size](https://img.shields.io/github/repo-size/smashedr/install-release?logo=buffer&label=repo%20size)](https://github.com/smashedr/install-release?tab=readme-ov-file#readme)
[![GitHub Repo Size](https://img.shields.io/github/repo-size/smashedr/install-release?logo=googlecloudstorage&logoColor=white&label=repo%20size)](https://github.com/smashedr/install-release?tab=readme-ov-file#readme)
[![GitHub Top Language](https://img.shields.io/github/languages/top/smashedr/install-release?logo=devbox)](https://github.com/smashedr/install-release?tab=readme-ov-file#readme)
[![GitHub Contributors](https://img.shields.io/github/contributors-anon/smashedr/install-release?logo=southwestairlines)](https://github.com/smashedr/install-release/graphs/contributors)
[![GitHub Issues](https://img.shields.io/github/issues/smashedr/install-release?logo=codeforces&logoColor=white)](https://github.com/smashedr/install-release/issues)
[![GitHub Discussions](https://img.shields.io/github/discussions/smashedr/install-release?logo=theconversation&logoColor=white)](https://github.com/smashedr/install-release/discussions)
[![GitHub Discussions](https://img.shields.io/github/discussions/smashedr/install-release?logo=theconversation)](https://github.com/smashedr/install-release/discussions)
[![GitHub Forks](https://img.shields.io/github/forks/smashedr/install-release?style=flat&logo=forgejo&logoColor=white)](https://github.com/smashedr/install-release/forks)
[![GitHub Repo Stars](https://img.shields.io/github/stars/smashedr/install-release?style=flat&logo=gleam&logoColor=white)](https://github.com/smashedr/install-release/stargazers)
[![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=apachespark&logoColor=white&label=org%20stars)](https://cssnr.github.io/)
Expand All @@ -24,7 +24,9 @@ icon: lucide/rocket

CLI to Install a GitHub Release.

Easily Install GitHub Release binaries with Windows, Linux and macOS Support.
Easily Install GitHub Release binaries on Windows, Linux and macOS.

Interactively select the release version, asset, and executable name with automatically detected presets.

--8<-- "docs/snippets/install.md"

Expand All @@ -38,12 +40,12 @@ If you run into any issues or have any questions, [support](support.md) is avail

## :lucide-sparkles: Features

- Supports Windows
- Custom `bin` Path
- Automatic Release Detection
- Select Asset and Name Interactively
- Set Asset and Name Programmatically
- Supports Windows, Linux and macOS
- Interactively Select Options
- Set Options w/ Flags or Variables
- Save or Set a Custom `bin` Path
- List and Remove Installed Apps
- Get App Information

## :lucide-plane-takeoff: Install

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
=== ":lucide-terminal-square: bash"

```shell
curl 'https://i.jpillora.com/smashedr/install-release!?as=ir' | bash # (1)!
curl 'https://raw.githubusercontent.com/smashedr/install-release/refs/heads/master/scripts/install.sh' | bash # (1)!
```

1. Alternatively, you can manually [download a release](https://github.com/smashedr/install-release/releases).
Expand Down
10 changes: 9 additions & 1 deletion docs/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ From here you can contact me directly, `Shane@111150265075298304`.

More information available at: [https://cssnr.com/](https://cssnr.com/)

[![Image title](https://cdn.prod.website-files.com/5c14e387dab576fe667689cf/670f5a01c01ea9191809398c_support_me_on_kofi_blue.png){ width="360" }](https://ko-fi.com/cssnr)
[![Support on Ko-fi](https://cdn.prod.website-files.com/5c14e387dab576fe667689cf/670f5a01c01ea9191809398c_support_me_on_kofi_blue.png){ width="360" }](https://ko-fi.com/cssnr)

<a href="https://github.com/smashedr/install-release/stargazers">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=bottom-right&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=bottom-right" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=smashedr/install-release&type=date&legend=bottom-right" />
</picture>
</a>
Loading
Loading