yuler / gh-download

[GitHub CLI] extension for download folders/files
56 stars 0 forks source link

Feature request: download assets and the latest release assets #7

Open brainwo opened 1 year ago

brainwo commented 1 year ago

Description It will come handy if this extension could be use to download assets, especially the latest release assets.

Example workflows:

Download assets from a url

[ ] checksums.txt [ ] pocketbase_0.7.10_darwin_amd64.zip [ ] pocketbase_0.7.10_darwin_arm64.zip [ ] pocketbase_0.7.10_linux_amd64.zip [ ] pocketbase_0.7.10_linux_arm64.zip [ ] pocketbase_0.7.10_linux_armv7.zip [ ] pocketbase_0.7.10_windows_amd64.zip [ ] pocketbase_0.7.10_windows_arm64.zip [ ] Source code (zip) [ ] Source code (tar.gz)

[] Done [] Exit

- This could be multiply selected:

Select what to download:

[x] checksums.txt [ ] pocketbase_0.7.10_darwin_amd64.zip [ ] pocketbase_0.7.10_darwin_arm64.zip [x] pocketbase_0.7.10_linux_amd64.zip [ ] pocketbase_0.7.10_linux_arm64.zip [ ] pocketbase_0.7.10_linux_armv7.zip [ ] pocketbase_0.7.10_windows_amd64.zip [ ] pocketbase_0.7.10_windows_arm64.zip [ ] Source code (zip) [ ] Source code (tar.gz)

[] Done [] Exit

- Once "Done" is pressed, it will download the selected files

**Download latest version of an asset**

- `gh download https://github.com/pocketbase/pocketbase/releases/tag/v0.7.3 --regex pocketbase_0.7.[0-9]+_linux_amd64.zip` (Note: the extra additional tag information is ignored, it's to simplify copying url from browser)
- This will download `pocketbase_0.7.10_linux_amd64.zip` or whichever version is the latest release of `0.7.x`

**Pick from a release**
- `gh download https://github.com/pocketbase/pocketbase/releases/tag/v0.7.3 --pick-tag` (Note: the extra additional tag information is ignored, it's to simplify copying url from browser)
- Will prompt which tag to pick (from https://github.com/pocketbase/pocketbase/tags):

Select which tag to download:

[] v0.8.0-rc2 (3 hours ago) [] v0.7.10 (3 hours ago) [] v0.8.0-rc1 (4 days ago) [] v0.7.9 (29 days ago)

[_] Exit


- The next step will be the same as **Download assets from a url**
yuler commented 1 year ago

Wow, this cool.

The current code is a simple shell script.

If add interactions in the terminal, I think it may need to be rewrite with other language, e.g. (golang, node.js)

@brainwo

Do you have any good advice?

brainwo commented 1 year ago

@yuler Before using this, I experiment making my own extension written in Go. What could I say is a shell script is more fitting for this kind of extension (although I'm not sure if it's running on Windows or not).

If you want to rewrite it, I think Go is a good choice since most other gh extensions is written in Go. I'm personally won't use Node.js, running the script will requires a Node.js runtime installed on the machine which is undesirable if I run it outside of my main machine. Not sure if I will run the script for automation in GitHub Action or not. But for sure, I think of sticking with a simple shell script.