add nofify
This commit is contained in:
parent
600787aca4
commit
cfba8ee7d4
4
.github/workflows/destversion.yml
vendored
4
.github/workflows/destversion.yml
vendored
@ -15,8 +15,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Test Github Action Server Time
|
# - name: Test Github Action Server Time
|
||||||
run: echo `date`
|
# run: echo `date`
|
||||||
- name: Check new version and push
|
- name: Check new version and push
|
||||||
env:
|
env:
|
||||||
GHTOKEN: ${{ secrets.GHTOKEN }}
|
GHTOKEN: ${{ secrets.GHTOKEN }}
|
||||||
|
18
.github/workflows/notify.yml
vendored
Normal file
18
.github/workflows/notify.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
name: Wechat Release Notify
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
notify_to_tg:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Check new version and push
|
||||||
|
env:
|
||||||
|
GHTOKEN: ${{ secrets.GHTOKEN }}
|
||||||
|
BOTTOKEN: ${{ secrets.BOTTOKEN }}
|
||||||
|
CHATIDS: ${{ secrets.CHATIDS }}
|
||||||
|
run: bash -x ./scripts/notify.sh
|
@ -17,10 +17,21 @@ function install_depends() {
|
|||||||
echo -e "## \033[1;33mInstalling 7zip, shasum, wget, curl, git\033[0m"
|
echo -e "## \033[1;33mInstalling 7zip, shasum, wget, curl, git\033[0m"
|
||||||
printf "#%.0s" {1..60}
|
printf "#%.0s" {1..60}
|
||||||
echo
|
echo
|
||||||
|
|
||||||
apt install -y p7zip-full p7zip-rar libdigest-sha-perl wget curl git
|
apt install -y p7zip-full p7zip-rar libdigest-sha-perl wget curl git
|
||||||
}
|
}
|
||||||
|
|
||||||
function login_gh() {
|
function login_gh() {
|
||||||
|
printf "#%.0s" {1..60}
|
||||||
|
echo
|
||||||
|
echo -e "## \033[1;33mLogin to github to use github-cli...\033[0m"
|
||||||
|
printf "#%.0s" {1..60}
|
||||||
|
echo
|
||||||
|
if [ -z $GHTOKEN ]; then
|
||||||
|
>&2 echo -e "\033[1;31mMissing Github Token! Please get a BotToken from 'Github Settings->Developer settings->Personal access tokens' and set it in Repo Secrect\033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo $GHTOKEN > WeChatSetup/temp/GHTOKEN
|
echo $GHTOKEN > WeChatSetup/temp/GHTOKEN
|
||||||
gh auth login --with-token < WeChatSetup/temp/GHTOKEN
|
gh auth login --with-token < WeChatSetup/temp/GHTOKEN
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
@ -36,6 +47,7 @@ function download_wechat() {
|
|||||||
echo -e "## \033[1;33mDownloading the newest WechatSetup...\033[0m"
|
echo -e "## \033[1;33mDownloading the newest WechatSetup...\033[0m"
|
||||||
printf "#%.0s" {1..60}
|
printf "#%.0s" {1..60}
|
||||||
echo
|
echo
|
||||||
|
|
||||||
wget "$download_link" -O ${temp_path}/WeChatSetup.exe
|
wget "$download_link" -O ${temp_path}/WeChatSetup.exe
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
>&2 echo -e "\033[1;31mDownload Failed, please check your network!\033[0m"
|
>&2 echo -e "\033[1;31mDownload Failed, please check your network!\033[0m"
|
||||||
@ -64,6 +76,7 @@ function prepare_commit() {
|
|||||||
echo -e "## \033[1;33mPrepare to commit new version\033[0m"
|
echo -e "## \033[1;33mPrepare to commit new version\033[0m"
|
||||||
printf "#%.0s" {1..60}
|
printf "#%.0s" {1..60}
|
||||||
echo
|
echo
|
||||||
|
|
||||||
mkdir -p WeChatSetup/$dest_version
|
mkdir -p WeChatSetup/$dest_version
|
||||||
cp $temp_path/WeChatSetup.exe WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe
|
cp $temp_path/WeChatSetup.exe WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe
|
||||||
echo "DestVersion: $dest_version" > WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe.sha256
|
echo "DestVersion: $dest_version" > WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe.sha256
|
||||||
@ -79,6 +92,7 @@ function clean_data() {
|
|||||||
echo -e "## \033[1;33mClean runtime and exit...\033[0m"
|
echo -e "## \033[1;33mClean runtime and exit...\033[0m"
|
||||||
printf "#%.0s" {1..60}
|
printf "#%.0s" {1..60}
|
||||||
echo
|
echo
|
||||||
|
|
||||||
rm -rfv WeChatSetup/*
|
rm -rfv WeChatSetup/*
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
@ -103,7 +117,9 @@ function main() {
|
|||||||
prepare_commit
|
prepare_commit
|
||||||
|
|
||||||
gh release create v$dest_version ./WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe -F ./WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe.sha256 -t "Wechat v$dest_version"
|
gh release create v$dest_version ./WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe -F ./WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe.sha256 -t "Wechat v$dest_version"
|
||||||
# gh auth logout
|
|
||||||
|
gh auth logout --hostname github.com | echo "y"
|
||||||
|
|
||||||
clean_data 0
|
clean_data 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
82
scripts/notify.sh
Executable file
82
scripts/notify.sh
Executable file
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z $GHTOKEN ]; then
|
||||||
|
>&2 echo -e "\033[1;31mMissing Github Token! Please get a BotToken from 'Github Settings->Developer settings->Personal access tokens' and set it in Repo Secrect\033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $BOTTOKEN ]; then
|
||||||
|
>&2 echo -e "\033[1;31mMissing Bot Token! Please get a BotToken from @Botfather on Telegram and set it in Repo Secrect\033[0m"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $CHATIDS ]; then
|
||||||
|
>&2 echo -e "\033[1;31mMissing ChatIds! Please get ChatId from @GroupIDbot on Telegram Chats(Muti chatids split with comma ',') and set it in Repo Environment Values\033[0m"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
chat_ids=`echo $CHATIDS | sed 's/,/ /g'`
|
||||||
|
|
||||||
|
function login_gh() {
|
||||||
|
printf "#%.0s" {1..60}
|
||||||
|
echo
|
||||||
|
echo -e "## \033[1;33mLogin to github to use github-cli...\033[0m"
|
||||||
|
printf "#%.0s" {1..60}
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo $GHTOKEN > WeChatSetup/temp/GHTOKEN
|
||||||
|
gh auth login --with-token < WeChatSetup/temp/GHTOKEN
|
||||||
|
if [ "$?" -ne 0 ]; then
|
||||||
|
>&2 echo -e "\033[1;31mLogin Failed, please check your network or token!\033[0m"
|
||||||
|
clean_data 1
|
||||||
|
fi
|
||||||
|
rm -rfv WeChatSetup/temp/GHTOKEN
|
||||||
|
}
|
||||||
|
|
||||||
|
### https://kodango.com/sed-and-awk-notes-part-5
|
||||||
|
## start=${1:-""} means as follows in general
|
||||||
|
## if ($1) then
|
||||||
|
## start=$1
|
||||||
|
## else
|
||||||
|
## start=""
|
||||||
|
## end
|
||||||
|
function join_lines() {
|
||||||
|
local delim=${1:-,}
|
||||||
|
sed 'H;$!d;${x;s/^\n//;s/\n/\'$delim'/g}'
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_data() {
|
||||||
|
printf "#%.0s" {1..60}
|
||||||
|
echo
|
||||||
|
echo -e "## \033[1;33mClean runtime and exit...\033[0m"
|
||||||
|
printf "#%.0s" {1..60}
|
||||||
|
echo
|
||||||
|
|
||||||
|
rm -rfv WeChatSetup/*
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
login_gh
|
||||||
|
|
||||||
|
temp_path="WeChatSetup/temp"
|
||||||
|
mkdir -p ${temp_path}
|
||||||
|
gh release view --json body --jq ".body" > ${temp_path}/release.info
|
||||||
|
|
||||||
|
release_info=`awk '!/^$|Sha256/ { $1="*"$1"*";sub("UpdateTime", "CheckTime"); if ( match($2, /https?:\/\/([\w\.\/:])*/) ) $2="[Url]("$2")"; print $0 }' ${temp_path}/release.info | join_lines '%0A' | sed 's/ /%20/g'`
|
||||||
|
dest_version=`awk '/DestVersion/ { print $2 }' ${temp_path}/release.info`
|
||||||
|
release_info="$release_info%0A%0A*NotifyFrom:*%20[Github](https://github.com/tom-snow/wechat-windows-versions/releases/tag/v$dest_version)"
|
||||||
|
|
||||||
|
for chatid in $chat_ids
|
||||||
|
do
|
||||||
|
api_link="https://api.telegram.org/bot$BOTTOKEN/sendMessage?chat_id=$chatid&text=*New%20WeChat%20Windows%20Version!!*%0A%0A$release_info&parse_mode=Markdown&disable_web_page_preview=true"
|
||||||
|
curl -s -o /dev/null $api_link
|
||||||
|
done
|
||||||
|
|
||||||
|
gh auth logout --hostname github.com | echo "y"
|
||||||
|
clean_data 0
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
Loading…
Reference in New Issue
Block a user