From 2c9ef4cd8de176295c253c8837c2028702b0cb50 Mon Sep 17 00:00:00 2001 From: Xiaonan Shen Date: Sun, 31 May 2020 21:45:01 -0700 Subject: [PATCH] Improve update check --- .github/workflows/update-check.yaml | 7 ++++-- VERSION | 2 +- update-check.sh | 34 ++++++++++++----------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/update-check.yaml b/.github/workflows/update-check.yaml index e8ae575..6f3f0cb 100644 --- a/.github/workflows/update-check.yaml +++ b/.github/workflows/update-check.yaml @@ -3,7 +3,11 @@ name: update check on: push: branches: - - update-check + - master + - dev + paths: + - .github/workflows/update-check.yaml + - update-check.sh schedule: - cron: '0 0 * * *' # runs everyday at midnight @@ -16,5 +20,4 @@ jobs: - name: Check Update run: bash update-check.sh env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }} diff --git a/VERSION b/VERSION index 7c5e509..2f29afd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.7-1 \ No newline at end of file +1.2.6-1 \ No newline at end of file diff --git a/update-check.sh b/update-check.sh index 134f951..d19ffc9 100644 --- a/update-check.sh +++ b/update-check.sh @@ -2,39 +2,33 @@ set -ex -REMOTE_REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" +REMOTE_REPO="https://${GITHUB_ACTOR}:${PERSONAL_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" -# Switch to master branch -git clone "${REMOTE_REPO}" master -cd master - -source ./releaserc +VERSION=`cat VERSION` 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") -CURR_RELEASE=$(echo $URL | sed -n "s/https:\/\/protonmail.com\/download\/protonmail-bridge_\([0-9.-]*\)_amd64.deb/\1/p") +CURR_VERSION=$(echo $URL | sed -n "s/https:\/\/protonmail.com\/download\/protonmail-bridge_\([0-9.-]*\)_amd64.deb/\1/p") -if [[ $RELEASE != $CURR_RELEASE ]]; then - echo "New release found: ${CURR_RELEASE}" +if [[ $VERSION != $CURR_VERSION ]]; then + echo "New release found: ${CURR_VERSION}" # bump up to new release - sed -i "s/^RELEASE=.*$/RELEASE=${CURR_RELEASE}/" releaserc + cat ${CURR_VERSION} > VERSION # commit git config --local user.email "actions@github.com" git config --local user.name "Github Action" - git add releaserc - git commit -m "Release ${CURR_RELEASE}" --author="Xiaonan Shen " - git tag -a "v${CURR_RELEASE}" -m "Release ${CURR_RELEASE}" + git add VERSION + git commit -m "Bump version to ${CURR_VERSION}" --author="Xiaonan Shen " # push git push "${REMOTE_REPO}" master - git push "${REMOTE_REPO}" master --tags - # 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 + # # 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 fi