-
Notifications
You must be signed in to change notification settings - Fork 480
153 lines (150 loc) · 5.7 KB
/
watch-df-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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Watch DF Releases
on:
schedule:
- cron: '8/10 * * * *'
workflow_dispatch:
jobs:
check-steam:
if: github.repository == 'DFHack/dfhack'
name: Check Steam (${{ matrix.df_steam_branch }}) for new DF releases
runs-on: ubuntu-latest
concurrency: watch-release-steam-${{ matrix.df_steam_branch }}
strategy:
fail-fast: false
matrix:
# df_steam_branch: which DF Steam branch to watch
# platform: leave blank to default to all
# structures_ref: leave blank to default to master
# dfhack_ref: leave blank if no structures update is desired
# steam_branch: leave blank if no DFHack steam push is desired
include:
- df_steam_branch: public
- df_steam_branch: beta
steps:
- name: Fetch state
uses: actions/cache/restore@v4
with:
path: state
key: watch-release-steam-${{ matrix.df_steam_branch }}
- name: Compare branch metadata
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
command: |
blob=$(wget 'https://api.steamcmd.net/v1/info/975370?pretty=1' -O- | \
awk '/^ *"branches"/,0' | \
awk '/^ *"${{ matrix.df_steam_branch }}"/,0')
buildid=$(echo "$blob" | \
fgrep buildid | \
head -n1 | \
cut -d'"' -f4)
timestamp=$(echo "$blob" | \
fgrep timeupdated | \
head -n1 | \
cut -d'"' -f4)
test -z "$buildid" && echo "no buildid result" && exit 1
test -z "$timestamp" && echo "no timestamp result" && exit 1
test "$buildid" -gt 0 || exit 1
test "$timestamp" -gt 0 || exit 1
echo "buildid and timestamp of last branch update: $buildid, $timestamp"
mkdir -p state
touch state/buildid state/timestamp
last_buildid=$(cat state/buildid)
last_timestamp=$(cat state/timestamp)
if [ -z "$last_timestamp" ]; then
echo "no stored timestamp"
last_buildid=0
last_timestamp=0
else
echo "stored buildid and timestamp of last branch update: $last_buildid, $last_timestamp"
fi
if [ "$buildid" -ne "$last_buildid" -a "$timestamp" -gt "$last_timestamp" ]; then
echo "branch updated"
echo "$buildid" >state/buildid
echo "$timestamp" >state/timestamp
echo BUILDID=$buildid >> $GITHUB_ENV
fi
- name: Discord Webhook Action
uses: tsickert/discord-webhook@v5.3.0
if: env.BUILDID
with:
webhook-url: ${{ secrets.DISCORD_TEAM_PRIVATE_WEBHOOK_URL }}
content: "<@&${{ secrets.DISCORD_TEAM_ROLE_ID }}> Steam ${{ matrix.df_steam_branch }} branch updated (build id: ${{ env.BUILDID }})"
- name: Launch symbol generation workflow
if: env.BUILDID && matrix.dfhack_ref
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run generate-symbols.yml \
-R DFHack/dfhack \
-r ${{ matrix.dfhack_ref }} \
-f structures_ref=${{ matrix.structures_ref }} \
-f version=auto \
-f platform=${{ matrix.platform }} \
-f channel=steam \
-f df_steam_branch=${{ matrix.df_steam_branch }} \
-f steam_branch=${{ matrix.steam_branch }}
- name: Save state
uses: actions/cache/save@v4
if: env.BUILDID
with:
path: state
key: watch-release-steam-${{ matrix.df_steam_branch }}-${{ env.BUILDID }}
check-non-steam:
if: github.repository == 'DFHack/dfhack'
name: Check ${{ matrix.channel }} for new DF releases
runs-on: ubuntu-latest
concurrency: watch-release-${{ matrix.channel }}
strategy:
fail-fast: false
matrix:
include:
- channel: itch
url: 'https://kitfoxgames.itch.io/dwarf-fortress'
prefix: 'dwarf_fortress'
- channel: classic
url: 'https://www.bay12games.com/dwarves/'
prefix: 'df'
steps:
- name: Fetch state
uses: actions/cache/restore@v4
with:
path: state
key: watch-release-${{ matrix.channel }}
- name: Compare versions
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
command: |
version=$(wget "${{ matrix.url }}" -qO- | tr '"' '\n' | fgrep 'tar.bz2' | head -n1 | sed -r 's/${{ matrix.prefix }}_([0-9]{2})_([0-9]{2})_linux.tar.bz2/\1.\2/')
echo "latest ${{ matrix.channel }} version: $version"
if ! grep -qE '^[0-9]+\.[0-9]+$' <<<"$version"; then
echo "invalid version"
exit 1
fi
mkdir -p state
touch state/last_version
last_version=$(cat state/last_version)
if [ -z "$last_version" ]; then
echo "no stored version"
last_version=0
else
echo "stored ${{ matrix.channel }} version: $last_version"
fi
if [ "$(tr -d '.' <<<"$version")" -gt "$(tr -d '.' <<<"$last_version")" ]; then
echo "${{ matrix.channel }} has been updated"
echo "$version" >state/last_version
echo NEW_VERSION=$version >> $GITHUB_ENV
fi
- name: Discord Webhook Action
uses: tsickert/discord-webhook@v5.3.0
if: env.NEW_VERSION
with:
webhook-url: ${{ secrets.DISCORD_TEAM_PRIVATE_WEBHOOK_URL }}
content: "<@&${{ secrets.DISCORD_TEAM_ROLE_ID }}> ${{ matrix.channel }} updated to ${{ env.NEW_VERSION }}"
- name: Save state
uses: actions/cache/save@v4
if: env.NEW_VERSION
with:
path: state
key: watch-release-${{ matrix.channel }}-${{ env.NEW_VERSION }}