-
Notifications
You must be signed in to change notification settings - Fork 146
119 lines (108 loc) · 4.46 KB
/
notify-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Sends a notification to Discord whenever a new version of Leather is available in FireFox or Chrome stores
name: Notify on Release
on:
schedule:
# Run every hour
- cron: '0 * * * *'
jobs:
firefox-notify:
runs-on: ubuntu-latest
steps:
- name: Get latest Firefox version
run: curl -s https://addons.mozilla.org/api/v5/addons/addon/leather-wallet/versions/ | jq -r '.results[0].version' > firefox_version
- name: Upload latest Firefox version info
uses: actions/upload-artifact@v3
with:
name: firefox_version
path: firefox_version
- name: Download previous Firefox version info
uses: dawidd6/action-download-artifact@v2
with:
workflow: notify-release.yml
workflow_conclusion: success
name: firefox_version
path: old
- name: Determine if new version is live
id: firefox
run: |
NEWEST_VERSION=$(sort -V old/firefox_version firefox_version | tail -n 1)
LATEST_VERSION=$(cat firefox_version)
DIFF=$(diff old/firefox_version firefox_version || true)
if [[ -n "${DIFF}" && ${NEWEST_VERSION} == ${LATEST_VERSION} ]]; then
echo "::warning::New Firefox version detected: ${LATEST_VERSION}"
echo "::set-output name=is_new::true"
echo "::set-output name=new_version::${LATEST_VERSION}"
else
echo "::warning::No new Firefox version detected"
fi
- name: Firefox Discord notification - userx
if: steps.firefox.outputs.is_new
uses: Ilshidur/action-discord@f1ed8844d9b33c17221fab0f36672cde39800eed
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_LEATHER_WEBHOOK }}
DISCORD_USERNAME: Leather Team
DISCORD_AVATAR: 'https://i.imgur.com/z9Iy6ug.png'
DISCORD_EMBEDS: |
[{
"title": "Leather for Firefox",
"url": "https://addons.mozilla.org/en-US/firefox/addon/leather-wallet/"
}]
with:
args: ':rocket: A new version (${{ steps.firefox.outputs.new_version }}) of Leather is available on the Firefox Web Store!'
chrome-notify:
runs-on: ubuntu-latest
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Get latest Chrome version
run: |
npm install chrome-webstore
node <<EOF> chrome_version
var webstore = require('chrome-webstore')
;(async () => {
var webstore_api_version = await webstore.version()
var details = await webstore.detail({id: '${{ secrets.CHROME_APP_ID }}', version: webstore_api_version})
console.log(details.version)
})()
EOF
- name: Upload latest Chrome version info
uses: actions/upload-artifact@v3
with:
name: chrome_version
path: chrome_version
- name: Download previous Chrome version info
uses: dawidd6/action-download-artifact@v2
with:
workflow: notify-release.yml
workflow_conclusion: success
name: chrome_version
path: old
- name: Determine if new version is live
id: chrome
run: |
NEWEST_VERSION=$(sort -V old/chrome_version chrome_version | tail -n 1)
LATEST_VERSION=$(cat chrome_version)
DIFF=$(diff old/chrome_version chrome_version || true)
if [[ -n "${DIFF}" && ${NEWEST_VERSION} == ${LATEST_VERSION} ]]; then
echo "::warning::New Chrome version detected: ${LATEST_VERSION}"
echo "::set-output name=is_new::true"
echo "::set-output name=new_version::${LATEST_VERSION}"
else
echo "::warning::No new Chrome version detected"
fi
- name: Chrome Discord notification - userx
if: steps.chrome.outputs.is_new
uses: Ilshidur/action-discord@f1ed8844d9b33c17221fab0f36672cde39800eed
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_LEATHER_WEBHOOK }}
DISCORD_USERNAME: Leather Team
DISCORD_AVATAR: 'https://i.imgur.com/z9Iy6ug.png'
DISCORD_EMBEDS: |
[{
"title": "Leather for Chrome",
"url": "https://chrome.google.com/webstore/detail/leather/ldinpeekobnhjjdofggfgjlcehhmanlj"
}]
with:
args: ':rocket: A new version (${{ steps.chrome.outputs.new_version }}) of Leather is available on the Chrome Web Store!'