1
0
Fork 0
mirror of synced 2024-11-26 09:15:34 -05:00

Download latest release instead of from master

Using GitHub URL to latest release asset as described in
https://help.github.com/en/github/administering-a-repository/linking-to-releases#linking-to-the-latest-release

There's a counter of release assets downloads, which is nice.
Download zimfw.zsh when installing, and zimfw.zsh.gz when upgrading, so
we can have separate counts.
This commit is contained in:
Eric Nielsen 2020-01-11 17:17:09 -05:00
parent f6f7815cb7
commit 6806bea72e
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
4 changed files with 12 additions and 10 deletions

View file

@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `-v` verbose option. Normal mode output is now cleaner and more focused.
### Changed
- When upgrading, download latest release asset instead of raw file from the
master branch.
- `curl` is preferred over `wget`.
- `wget`'s output is only shown in verbose mode.

View file

@ -63,7 +63,7 @@ If you have a different shell framework installed (like oh-my-zsh or prezto),
chsh -s =zsh
3. Copy https://raw.githubusercontent.com/zimfw/zimfw/master/zimfw.zsh to
3. Copy https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh to
`~/.zim/zimfw.zsh`.
4. Add the lines in the following templates to the respective dot files:

View file

@ -1,17 +1,17 @@
_zimfw_upgrade() {
local -r ztarget=${ZIM_HOME}/zimfw.zsh
local -r zurl=https://raw.githubusercontent.com/zimfw/zimfw/master/zimfw.zsh
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
{
setopt LOCAL_OPTIONS PIPE_FAIL
if (( ${+commands[curl]} )); then
command curl -fsSL -o ${ztarget}.new ${zurl} || return 1
command curl -fsSL ${zurl} | command gunzip > ${ztarget}.new || return 1
else
local zopt
(( _zprintlevel <= 1 )) && zopt='-q'
if ! command wget -nv ${zopt} -O ${ztarget}.new ${zurl}; then
if ! command wget -nv ${zopt} -O - ${zurl} | command gunzip > ${ztarget}.new; then
(( _zprintlevel <= 1 )) && print -u2 -PR "%F{red}<%= error %>Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
return 1
fi
else
fi
_zimfw_mv ${ztarget}{.new,} && _zimfw_print -P '<%= done %>Done with upgrade.'
} always {

View file

@ -260,7 +260,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print 'Zim version: 1.1.0-SNAPSHOT (previous commit is ee99fe8)'
print 'Zim version: 1.1.0-SNAPSHOT (previous commit is f6f7815)'
print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a)
@ -281,18 +281,18 @@ _zimfw_uninstall() {
_zimfw_upgrade() {
local -r ztarget=${ZIM_HOME}/zimfw.zsh
local -r zurl=https://raw.githubusercontent.com/zimfw/zimfw/master/zimfw.zsh
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
{
setopt LOCAL_OPTIONS PIPE_FAIL
if (( ${+commands[curl]} )); then
command curl -fsSL -o ${ztarget}.new ${zurl} || return 1
command curl -fsSL ${zurl} | command gunzip > ${ztarget}.new || return 1
else
local zopt
(( _zprintlevel <= 1 )) && zopt='-q'
if ! command wget -nv ${zopt} -O ${ztarget}.new ${zurl}; then
if ! command wget -nv ${zopt} -O - ${zurl} | command gunzip > ${ztarget}.new; then
(( _zprintlevel <= 1 )) && print -u2 -PR "%F{red}x Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
return 1
fi
else
fi
_zimfw_mv ${ztarget}{.new,} && _zimfw_print -P 'Done with upgrade.'
} always {