upgrades: the X.Y version is equivalent to the latest patch release
This commit is contained in:
parent
4dc1068027
commit
bc55c01cc6
2 changed files with 27 additions and 3 deletions
|
@ -9,7 +9,7 @@ SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
version=$1
|
version=$1
|
||||||
DIR=$2
|
DIR=$2
|
||||||
|
|
||||||
v=$(echo $version | sed -E -e 's/([0-9]+\.[0-9]+).*/\1/')
|
v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||||
read url ref semver < $SELF_DIR/sources/$v
|
read url ref semver < $SELF_DIR/sources/$v
|
||||||
|
|
||||||
rm -fr $DIR/src
|
rm -fr $DIR/src
|
||||||
|
|
|
@ -87,16 +87,40 @@ function retry() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function full_version() {
|
||||||
|
local version=$1
|
||||||
|
local owner=$2
|
||||||
|
|
||||||
|
if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then
|
||||||
|
full_version=$(curl -sS https://codeberg.org/api/v1/repos/$owner/forgejo/releases | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort -r | head -1)
|
||||||
|
echo ${full_version#v}
|
||||||
|
else
|
||||||
|
echo $version
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function download() {
|
function download() {
|
||||||
local version=$1
|
local version=$1
|
||||||
|
|
||||||
if ! test -f $DIR/forgejo-$version ; then
|
if ! test -f $DIR/forgejo-$version ; then
|
||||||
mkdir -p $DIR
|
mkdir -p $DIR
|
||||||
for owner in forgejo forgejo-experimental forgejo-integration ; do
|
for owner in forgejo forgejo-experimental forgejo-integration ; do
|
||||||
if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$version/forgejo-$version-linux-amd64 ; then
|
full_version=$(full_version $version $owner)
|
||||||
|
if test "$full_version" = "" ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if test -s $DIR/forgejo-$version ; then
|
||||||
|
if test "$version" != "$full_version" ; then
|
||||||
|
log_info "downloaded $full_version for $version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo unable to download Forgejo $version
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
chmod +x $DIR/forgejo-$version
|
chmod +x $DIR/forgejo-$version
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -208,7 +232,7 @@ function create_user() {
|
||||||
local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path"
|
local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path"
|
||||||
$cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email "$FORGEJO_USER@example.com"
|
$cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email "$FORGEJO_USER@example.com"
|
||||||
local scopes="--scopes all"
|
local scopes="--scopes all"
|
||||||
if echo $version | grep --quiet 1.18. ; then
|
if echo $version | grep --quiet 1.18 ; then
|
||||||
scopes=""
|
scopes=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue