Skip to content

Commit

Permalink
scripts: added a script to download the latest release
Browse files Browse the repository at this point in the history
This script downloads the latest release from a remote Github repository
into the current directory.

Invoke './scripts/get_latest_release.sh' to get the latest release in the
local repository directory.
  • Loading branch information
ebold-cscotos committed Jun 8, 2022
1 parent 553c27b commit 3eca8f7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

Repository for WRS firmware releases used in GSI.

The latest release in usage is labeled as 'latest' in Releases.
## Usage

Download the latest release into the local repository directory:

```
$ ./scripts/get_latest_release.sh
```
43 changes: 43 additions & 0 deletions scripts/get_latest_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Download the latest WRS release (tarball) from the Github repo

# URLs
url_repo_api="https://api.github.com/repos/GSI-CS-CO/wrs-gsi-releases"
url_latest_api="$url_repo_api/releases/latest"

# Get the information about the latest release

latest_release_api=$(curl -s $url_latest_api)
#echo $latest_release_api

# Extract a download URL from the release information

url_download=$(echo $latest_release_api | sed -e 's/.*"browser_download_url": "\([^"]*\)".*/\1/')
#url_download=$(echo $latest_release_api | sed -E 's/.*"browser_download_url": "?([^,"]*)"?.*/\1/') # works too
#echo $url_download

# Download a target tarball

wget -nc $url_download

# Command options

# curl options:
# -L: redirect to moved location
# -s: silent

# sed options:
# -e: basic expression
# s/regexp/replacement/[flags]: attempt to match the pattern space against 'regexp'
# if the match found, then that portion is replaced with 'replacement'
# \1: in 'replacement' it refers to a portion of the match which is contained
# between the 'n'th and '\)' and its matching '\)'
# [^"]: bracket subexpression that excludes '"' from list
# \(regexp\): groups 'regexp' as a whole
# \([^"]*\): all characters until first '"'

# -E: extended regular expression

# wget options:
# -nc: prevent download an existing target file

0 comments on commit 3eca8f7

Please sign in to comment.