Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload the zsync file #4529

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions admin/linux/upload-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,20 @@ else
fi

export UPDATE=$(readlink -f ./Nextcloud*.AppImage.zsync)
export BASENAME=$(basename ${APPIMAGE})
export BASENAME_APPIMAGE=$(basename ${APPIMAGE})
export BASENAME_UPDATE=$(basename ${UPDATE})

if ! test -e $APPIMAGE ; then
exit 1
fi

echo "Found AppImage: $BASENAME"
echo "Found AppImage: $BASENAME_APPIMAGE"

if ! test -e $UPDATE ; then
exit 1
fi

echo "Found zsync: $BASENAME_UPDATE"

if [ $TAG_NAME != "master" ]; then
# Delete all old comments in desktop PR, starting with "AppImage file:"
Expand Down Expand Up @@ -86,8 +93,8 @@ get_release_assets()
upload_release_asset()
{
uploadUrl=$1
echo $(curl --max-time 900 -u $GIT_USERNAME:$GIT_TOKEN -X POST $uploadUrl --header "Content-Type: application/octet-stream" --upload-file $APPIMAGE)
echo $(curl --max-time 900 -u $GIT_USERNAME:$GIT_TOKEN -X POST $uploadUrl --header "Content-Type: application/octet-stream" --upload-file $UPDATE)
asset=$2
echo $(curl --max-time 900 -u $GIT_USERNAME:$GIT_TOKEN -X POST $uploadUrl --header "Content-Type: application/octet-stream" --upload-file $asset)
}

delete_release_asset()
Expand Down Expand Up @@ -117,7 +124,8 @@ if [[ "$uploadUrl" == "null" ]]; then
fi

# Prepare upload url
uploadUrl=$(echo "${uploadUrl/'{?name,label}'/?name=$BASENAME}")
uploadUrlAppImage=$(echo "${uploadUrl/'{?name,label}'/?name=$BASENAME_APPIMAGE}")
uploadUrlUpdate=$(echo "${uploadUrl/'{?name,label}'/?name=$BASENAME_UPDATE}")

# Try to delete existing AppImage assets for this PR
assets=$(get_release_assets $releaseId)
Expand All @@ -132,23 +140,38 @@ for data in $(echo $assets | jq -r '.[] | @uri'); do
echo "Deleting old asset: $name"
$(delete_release_asset $assetId)
fi

if [[ "$name" == *.zsync ]]; then
echo "Deleting old asset: $name"
$(delete_release_asset $assetId)
fi
done

# Upload release asset
echo "Uploading new asset: $BASENAME"
echo "Uploading new asset: $BASENAME_APPIMAGE"

jsonAppImage=$(upload_release_asset "$uploadUrlAppImage" "$APPIMAGE")
browserDownloadUrlAppImage=$(echo $jsonAppImage | jq -r '.browser_download_url')

if [[ "$browserDownloadUrlAppImage" == "null" ]]; then
echo "upload_release_asset failed: $jsonAppImage"
exit 3
fi

json=$(upload_release_asset "$uploadUrl")
browserDownloadUrl=$(echo $json | jq -r '.browser_download_url')
echo "Uploading new asset: $BASENAME_UPDATE"
jsonUpdate=$(upload_release_asset "$uploadUrlUpdate" "$UPDATE")
browserDownloadUrlUpdate=$(echo $jsonUpdate | jq -r '.browser_download_url')

if [[ "$browserDownloadUrl" == "null" ]]; then
echo "upload_release_asset failed: $json"
if [[ "$browserDownloadUrlUpdate" == "null" ]]; then
echo "upload_release_asset failed: $jsonUpdate"
exit 3
fi

if [ $TAG_NAME != "master" ]; then
# Create comment in desktop PR
curl 2>/dev/null -u $GIT_USERNAME:$GIT_TOKEN -X POST $DESKTOP_API_BASE_URL/issues/$PR/comments -d "{ \"body\" : \"AppImage file: [$BASENAME]($browserDownloadUrl) <br/><br/>To test this change/fix you can simply download above AppImage file and test it. <br/><br/>Please make sure to quit your existing Nextcloud app and backup your data. \" }"
curl 2>/dev/null -u $GIT_USERNAME:$GIT_TOKEN -X POST $DESKTOP_API_BASE_URL/issues/$PR/comments -d "{ \"body\" : \"AppImage file: [$BASENAME_APPIMAGE]($browserDownloadUrlAppImage) <br/><br/>[$BASENAME_UPDATE]($browserDownloadUrlUpdate)<br/><br/>To test this change/fix you can simply download above AppImage file and test it. <br/><br/>Please make sure to quit your existing Nextcloud app and backup your data. \" }"
fi

echo
echo "AppImage link: $browserDownloadUrl"
echo "AppImage link: $browserDownloadUrlAppImage"
echo "zsync link: $browserDownloadUrlUpdate"