Skip to content

Commit

Permalink
First Release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kavishgr committed Jul 6, 2023
1 parent cdf4133 commit 2d884e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
8 changes: 5 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
builds:
- env:
-
ldflags:
- -s -w
env:
- CGO_ENABLED=0
goos:
- linux
Expand All @@ -14,7 +16,7 @@ builds:
archives:
- format: tar.gz
snapshot:
name_template: "{{ incpatch .Version }}-next"
name_template: "{{ incpatch .Version }}"
changelog:
sort: asc
filters:
Expand Down
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# getghrel

getghrel" is a command-line interface (CLI) tool that locates and downloads the most recent release assets from Github for MacOS and Linux architectures, specifically "amd64" and "arm64". However, currently, it only supports "amd64" architecture for Linux. The tool automatically identifies your operating system and architecture, and downloads the binary. If the release is compressed or in an archive format, it will automatically extract and unpack it, no matter how it's compressed, and keep only the binary.

getghrel" is a command-line interface (CLI) tool that locates and downloads the most recent release assets from Github for MacOS and Linux architectures, specifically "amd64" and "arm64". The tool automatically identifies your operating system and architecture, and downloads the binary. If the release is compressed or in an archive format, it will automatically extract and unpack it, no matter how it's compressed, and keep only the binary.

## Installation

Download the latest binary from the [releases](https://test) section and place it in your `$PATH`.

### Dependencies

- A GitHub token. By default, the tool will search for the `GITHUB_TOKEN` environment variable. Alternatively, you can also provide it directly through the command line.
- A GitHub token. By default, the tool will search for the `GITHUB_TOKEN` environment variable. Alternatively, you can also provide it directly on the command line.

## Usage

Expand Down Expand Up @@ -40,7 +39,7 @@ All the supported flags:

### List Found Releases

To list the found releases, create a text file with a complete URL or owner/repo per line, and run:
To list the found releases, create a text file with a **complete URL** or **owner/repo** per line, and run:

```sh
# List of URLs
Expand All @@ -51,6 +50,8 @@ cat testurls.txt | getghrel -list -con 3 | sort | tee releases.txt
echo "sharkdp/bat" | getghrel -list | sort
```

### Demo

```sh
❯ cat urls.txt | getghrel -list | sort
N/A: https://github.com/Elkowar/pipr
Expand Down Expand Up @@ -80,30 +81,34 @@ In case a repository lacks a latest release tag, the tool will search for the mo

### Download Found Assets

To download the found assets and keep the binaries in a temporary folder (which is /tmp/getghrel by default), simply use the '-download' flag:
To download the found assets and keep the binaries in a temporary folder (which is `/tmp/getghrel` by default), simply use the '-download' flag:

```sh
# List of URLS
# List of URLS found with -list
cat releases.txt | getghrel -download
cat releases.txt | getghrel -download -con 3

# Single one
echo "https://github.com/sharkdp/bat" | getghrel -download
echo "https://github.com/sharkdp/bat" | getghrel -list | getghrel -download
```

Download to a different location for the temporary folder, use the `-tempdir` flag:
### Demo

something here........

To download to a different location, use the `-tempdir` flag :

```sh
# List of URLS
cat releases.txt | getghrel -download -tempdir '/tmp/tempbin'

# Single one
echo "https://github.com/sharkdp/bat" | getghrel -download -tempdir '/tmp/tempbin'
echo "https://github.com/sharkdp/bat" | getghrel -list | getghrel -download -tempdir '/tmp/tempbin'
```

## TODO

Add a boolean flag to control the search for recent release tags. With this flag, you can choose to download the most recent nightly or unstable releases, or skip them altogether. The flag also ensures that unstable releases are excluded from the search for recent releases.
Add a flag to control the search for recent release tags. With this flag, you can choose to download the most recent nightly/unstable releases or one below them, or skip them altogether.

## Contributing

Expand Down
6 changes: 3 additions & 3 deletions utils/regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ func CompileRegex(ost, arch string) string{
// myregex = `.*(?i)(linux|unknown).*?(amd64|x86_64)|(amd64|x86_64).*?(?i)(linux|unknown)`
myregex = `(?i)(?=.*(?:linux))(?=.*(?:amd64|x86_64))(?!.*(?:freebsd|netbsd|openbsd|windows|apple|darwin|macos|mac))(?:.*(?:linux).*?(?:amd64|x86_64)|(?:amd64|x86_64).*?(?:linux))(?:[^a-z]|$)`

// case (ost == "linux" && arch == "aarch64"):
case (ost == "linux" && arch == "aarch64"):
// // myregex = `.*(?i)(linux|unknown).*?(amd64|x86_64)|(amd64|x86_64).*?(?i)(linux|unknown)`
// myregex = `(?i)(?=.*(?:linux))(?=.*(?:arm64|aarch64))(?!.*(?:freebsd|netbsd|openbsd|windows|apple|darwin|macos|mac))(?:.*(?:linux).*?(?:arm64|aarch64)|(?:arm64|aarch64).*?(?:linux))(?:[^a-z]|$)`
myregex = `(?i)(?=.*(?:linux))(?=.*(?:arm64|aarch64))(?!.*(?:freebsd|netbsd|openbsd|windows|apple|darwin|macos|mac))(?:.*(?:linux).*?(?:arm64|aarch64)|(?:arm64|aarch64).*?(?:linux))(?:[^a-z]|$)`

default:
msg1 := "OS or Architecture is not supported or not found in the regex pattern"
msg2 := "File an issue or make a pull request for your OS and Arch"
msg3 := "Will only list/download for macOS for the following arch: x86_64/amd64 and arm64"
msg4 := "and Linux for thwe following arch: x86_64/amd64"
msg4 := "and Linux for the following arch: x86_64/amd64"
log.Fatalf("%v\n%v\n%v\n%v", msg1, msg2, msg3, msg4)
}
return myregex
Expand Down

0 comments on commit 2d884e4

Please sign in to comment.