1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00

Update updater.sh

Should now handle all source downloads
This commit is contained in:
tituspijean 2021-10-03 09:59:03 +02:00
parent a765c50767
commit 1f4a6f5907
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720

View file

@ -21,11 +21,19 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
# version=${version:1} version=${version:1}
# fi fi
# x86-64 and enterprise assets are hosted on Mattermost's servers.
assets=()
assets+=("https://releases.mattermost.com/$version/mattermost-team-$version-linux-amd64.tar.gz")
assets+=("https://releases.mattermost.com/$version/mattermost-enterprise-$version-linux-amd64.tar.gz")
# ARM and ARM64 are published in another repository (with a leading "v" for version tags)
other_repo="SmartHoneybee/ubiquitous-memory"
other_assets=($(curl --silent "https://api.github.com/repos/$other_repo/releases" | jq -r '[ .[] | select(.tag_name=="'v$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# Setting up the environment variables # Setting up the environment variables
echo "Current version: $current_version" echo "Current version: $current_version"
@ -43,6 +51,13 @@ elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.
echo "::warning ::A branch already exists for this update" echo "::warning ::A branch already exists for this update"
exit 0 exit 0
fi fi
# Proceed only if all the binaries have been found
if (( ${#other_assets[@]} == 0 )); then
echo "::warning ::$other_repo has not released anything for v$version"
exit 0
else
assets+=( ${other_assets[@]} )
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) # Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)" echo "${#assets[@]} available asset(s)"
@ -63,17 +78,20 @@ echo "Handling asset at $asset_url"
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) # Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset # Leave $src empty to ignore the asset
case $asset_url in case $asset_url in
*"mattermost-"*"-linux-arm.tar.gz"*) *"mattermost-"*"-linux-arm.tar.gz")
src="arm" src="arm"
;; ;;
*"mattermost-"*"-linux-arm64.tar.gz"*) *"mattermost-"*"-linux-arm64.tar.gz")
src="arm64" src="arm64"
;; ;;
*"mattermost-"*"-linux-amd64.tar.gz"*) *"mattermost-team-"*"-linux-amd64.tar.gz")
src="x86-64" src="x86-64"
;; ;;
*"mattermost-enterprise-"*"-linux-amd64.tar.gz"*) *"mattermost-enterprise-"*"-linux-amd64.tar.gz")
src="entreprise" src="enterprise"
;;
*)
src=""
;; ;;
esac esac