Skip to content

Commit 3dab606

Browse files
committed
watch Itch and Classic for releases too
also fix steam monitoring so it doesn't notify unless there is a new build id. this will prevent spurious notifications when there is just a metadata update
1 parent ca6f334 commit 3dab606

File tree

2 files changed

+153
-84
lines changed

2 files changed

+153
-84
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Watch DF Releases
2+
3+
on:
4+
schedule:
5+
- cron: '8/10 * * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
check-steam:
10+
if: github.repository == 'DFHack/dfhack'
11+
name: Check Steam for new DF releases (${{ matrix.df_steam_branch }} branch)
12+
runs-on: ubuntu-latest
13+
concurrency: watch-release-steam-${{ matrix.df_steam_branch }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
# df_steam_branch: which DF Steam branch to watch
18+
# platform: leave blank to default to all
19+
# structures_ref: leave blank to default to master
20+
# dfhack_ref: leave blank if no structures update is desired
21+
# steam_branch: leave blank if no DFHack steam push is desired
22+
include:
23+
- df_steam_branch: public
24+
- df_steam_branch: beta
25+
steps:
26+
- name: Fetch state
27+
uses: actions/cache/restore@v4
28+
with:
29+
path: state
30+
key: watch-release-steam-${{ matrix.df_steam_branch }}
31+
- name: Compare branch metadata
32+
uses: nick-fields/retry@v3
33+
with:
34+
timeout_minutes: 2
35+
command: |
36+
blob=$(wget 'https://api.steamcmd.net/v1/info/975370?pretty=1' -O- | \
37+
awk '/^ *"branches"/,0' | \
38+
awk '/^ *"${{ matrix.df_steam_branch }}"/,0')
39+
buildid=$(echo "$blob" | \
40+
fgrep buildid | \
41+
head -n1 | \
42+
cut -d'"' -f4)
43+
timestamp=$(echo "$blob" | \
44+
fgrep timeupdated | \
45+
head -n1 | \
46+
cut -d'"' -f4)
47+
test -z "$buildid" && echo "no buildid result" && exit 1
48+
test -z "$timestamp" && echo "no timestamp result" && exit 1
49+
test "$buildid" -gt 0 || exit 1
50+
test "$timestamp" -gt 0 || exit 1
51+
echo "buildid and timestamp of last branch update: $buildid, $timestamp"
52+
mkdir -p state
53+
touch state/buildid state/timestamp
54+
last_buildid=$(cat state/buildid)
55+
last_timestamp=$(cat state/timestamp)
56+
if [ -z "$last_timestamp" ]; then
57+
echo "no stored timestamp"
58+
buildid=0
59+
last_timestamp=0
60+
else
61+
echo "stored buildid and timestamp of last branch update: $last_buildid, $last_timestamp"
62+
fi
63+
if [ "$buildid" -ne "$last_buildid" -a "$timestamp" -gt "$last_timestamp" ]; then
64+
echo "branch updated"
65+
echo "$buildid" >state/buildid
66+
echo "$timestamp" >state/timestamp
67+
echo BUILDID=$timestamp >> $GITHUB_ENV
68+
fi
69+
- name: Discord Webhook Action
70+
uses: tsickert/[email protected]
71+
if: env.BUILDID
72+
with:
73+
webhook-url: ${{ secrets.DISCORD_TEAM_PRIVATE_WEBHOOK_URL }}
74+
content: "<@&${{ secrets.DISCORD_TEAM_ROLE_ID }}> DF Steam branch updated: ${{ matrix.df_steam_branch }} (build id: ${{ env.BUILDID }})"
75+
- name: Launch symbol generation workflow
76+
if: env.BUILDID && matrix.dfhack_ref
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
run: |
80+
gh workflow run generate-symbols.yml \
81+
-R DFHack/dfhack \
82+
-r ${{ matrix.dfhack_ref }} \
83+
-f structures_ref=${{ matrix.structures_ref }} \
84+
-f version=auto \
85+
-f platform=${{ matrix.platform }} \
86+
-f channel=steam \
87+
-f df_steam_branch=${{ matrix.df_steam_branch }} \
88+
-f steam_branch=${{ matrix.steam_branch }}
89+
- name: Save state
90+
uses: actions/cache/save@v4
91+
if: env.BUILDID
92+
with:
93+
path: state
94+
key: watch-release-steam-${{ matrix.df_steam_branch }}-${{ env.BUILDID }}
95+
96+
check-non-steam:
97+
if: github.repository == 'DFHack/dfhack'
98+
name: Check ${{ matrix.channel }} for new DF releases
99+
runs-on: ubuntu-latest
100+
concurrency: watch-release-${{ matrix.channel }}
101+
strategy:
102+
fail-fast: false
103+
matrix:
104+
include:
105+
- channel: itch
106+
url: 'https://kitfoxgames.itch.io/dwarf-fortress'
107+
prefix: 'dwarf_fortress'
108+
- channel: classic
109+
url: 'https://www.bay12games.com/dwarves/'
110+
prefix: 'df'
111+
steps:
112+
- name: Fetch state
113+
uses: actions/cache/restore@v4
114+
with:
115+
path: state
116+
key: watch-release-${{ matrix.channel }}
117+
- name: Compare versions
118+
uses: nick-fields/retry@v3
119+
with:
120+
timeout_minutes: 2
121+
command: |
122+
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/')
123+
echo "latest ${{ matrix.channel }} version: $version"
124+
if ! grep -qE '^[0-9]+\.[0-9]+$' <<<"$version"; then
125+
echo "invalid version"
126+
exit 1
127+
fi
128+
mkdir -p state
129+
touch state/last_version
130+
last_version=$(cat state/last_version)
131+
if [ -z "$last_version" ]; then
132+
echo "no stored version"
133+
last_version=0
134+
else
135+
echo "stored version: $last_version"
136+
fi
137+
if [ "$(tr -d '.' <<<"$version")" -gt "$(tr -d '.' <<<"$last_version")" ]; then
138+
echo "${{ matrix.channel }} has been updated"
139+
echo "$version" >state/last_version
140+
echo NEW_VERSION=$version >> $GITHUB_ENV
141+
fi
142+
- name: Discord Webhook Action
143+
uses: tsickert/[email protected]
144+
if: env.NEW_VERSION
145+
with:
146+
webhook-url: ${{ secrets.DISCORD_TEAM_PRIVATE_WEBHOOK_URL }}
147+
content: "<@&${{ secrets.DISCORD_TEAM_ROLE_ID }}> DF ${{ matrix.channel }} updated to ${{ env.NEW_VERSION }}"
148+
- name: Save state
149+
uses: actions/cache/save@v4
150+
if: env.NEW_VERSION
151+
with:
152+
path: state
153+
key: watch-release-${{ matrix.channel }}-${{ env.NEW_VERSION }}

.github/workflows/watch-df-steam.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)