protonmail-bridge-nextcoud-.../update-check.sh

35 lines
1.1 KiB
Bash
Raw Normal View History

2020-04-15 11:01:07 +00:00
#!/bin/bash
set -ex
2020-06-01 04:45:01 +00:00
REMOTE_REPO="https://${GITHUB_ACTOR}:${PERSONAL_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
2020-04-18 08:00:18 +00:00
2020-06-01 04:45:01 +00:00
VERSION=`cat VERSION`
2020-04-15 11:01:07 +00:00
JSON_CONTENT=$(curl -q https://protonmail.com/download/current_version_linux.json)
URL=$(echo ${JSON_CONTENT} | sed -n "s/^.*\"DebFile\":\"\([a-z0-9:/._-]*\)\".*$/\1/p")
2020-06-01 04:45:01 +00:00
CURR_VERSION=$(echo $URL | sed -n "s/https:\/\/protonmail.com\/download\/protonmail-bridge_\([0-9.-]*\)_amd64.deb/\1/p")
2020-04-15 11:01:07 +00:00
2020-06-01 04:45:01 +00:00
if [[ $VERSION != $CURR_VERSION ]]; then
echo "New release found: ${CURR_VERSION}"
2020-04-15 11:01:07 +00:00
# bump up to new release
2020-06-01 04:45:01 +00:00
cat ${CURR_VERSION} > VERSION
2020-04-15 11:01:07 +00:00
# commit
git config --local user.email "actions@github.com"
git config --local user.name "Github Action"
2020-06-01 04:45:01 +00:00
git add VERSION
git commit -m "Bump version to ${CURR_VERSION}" --author="Xiaonan Shen <s@sxn.dev>"
2020-04-15 11:01:07 +00:00
# push
git push "${REMOTE_REPO}" master
2020-06-01 04:45:01 +00:00
# # trigger actions
# curl -H "Accept: application/vnd.github.everest-preview+json" \
# -H "Authorization: token ${PERSONAL_TOKEN}" \
# --request POST \
# --data '{"event_type": "build"}' \
# https://api.github.com/repos/${GITHUB_REPOSITORY}/dispatches
2020-04-15 11:01:07 +00:00
fi