-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (159 loc) · 7.51 KB
/
check_version.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Check Spotify Version
on:
schedule:
- cron: "*/10 * * * *" # Runs every 10 minutes
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
permissions:
contents: write
statuses: write
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
echo "⚡ Dependencies installed" >> $GITHUB_STEP_SUMMARY
- name: Run version checker
id: version
run: |
echo "🔍 Checking Spotify versions..." >> $GITHUB_STEP_SUMMARY
OLD_WEB_VERSION=$(cat version.txt || echo "none")
OLD_IOS_VERSION=$(cat ios_version.txt || echo "none")
OLD_ANDROID_VERSION=$(cat android_version.txt || echo "none")
python main.py
NEW_WEB_VERSION=$(cat version.txt)
NEW_IOS_VERSION=$(cat ios_version.txt)
NEW_ANDROID_VERSION=$(cat android_version.txt)
echo "old_web_version=$OLD_WEB_VERSION" >> $GITHUB_OUTPUT
echo "new_web_version=$NEW_WEB_VERSION" >> $GITHUB_OUTPUT
echo "old_ios_version=$OLD_IOS_VERSION" >> $GITHUB_OUTPUT
echo "new_ios_version=$NEW_IOS_VERSION" >> $GITHUB_OUTPUT
echo "old_android_version=$OLD_ANDROID_VERSION" >> $GITHUB_OUTPUT
echo "new_android_version=$NEW_ANDROID_VERSION" >> $GITHUB_OUTPUT
echo "✅ Version checks complete" >> $GITHUB_STEP_SUMMARY
- name: Commit if web version changed
id: commit_web
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add version.txt
if git diff --quiet && git diff --staged --quiet; then
echo "status=unchanged" >> $GITHUB_OUTPUT
else
git commit -m "Update Spotify Web version
🔄 Web Version Change:
- Old: ${{ steps.version.outputs.old_web_version }}
- New: ${{ steps.version.outputs.new_web_version }}"
git push
echo "status=updated" >> $GITHUB_OUTPUT
fi
- name: Commit if iOS version changed
id: commit_ios
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add ios_version.txt
if git diff --quiet && git diff --staged --quiet; then
echo "status=unchanged" >> $GITHUB_OUTPUT
else
git commit -m "Update Spotify iOS version
🔄 iOS Version Change:
- Old: ${{ steps.version.outputs.old_ios_version }}
- New: ${{ steps.version.outputs.new_ios_version }}"
git push
echo "status=updated" >> $GITHUB_OUTPUT
fi
- name: Commit if Android version changed
id: commit_android
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add android_version.txt
if git diff --quiet && git diff --staged --quiet; then
echo "status=unchanged" >> $GITHUB_OUTPUT
else
git commit -m "Update Spotify Android version
🔄 Android Version Change:
- Old: ${{ steps.version.outputs.old_android_version }}
- New: ${{ steps.version.outputs.new_android_version }}"
git push
echo "status=updated" >> $GITHUB_OUTPUT
fi
- name: Update README
if: always()
run: |
WEB_VERSION=$(cat version.txt)
IOS_VERSION=$(cat ios_version.txt)
ANDROID_VERSION=$(cat android_version.txt)
DATE=$(date -u +"%Y-%m-%d %H:%M UTC")
# Update Web version badge and info
sed -i "s|Spotify%20Web-.*-brightgreen|Spotify%20Web-${WEB_VERSION}-brightgreen|g" README.md
sed -i "s|Web Version\`: \`.*\`|Web Version\`: \`${WEB_VERSION}\`|g" README.md
# Update iOS version badge and info
sed -i "s|Spotify%20iOS-.*-blue|Spotify%20iOS-${IOS_VERSION}-blue|g" README.md
sed -i "s|iOS Version\`: \`.*\`|iOS Version\`: \`${IOS_VERSION}\`|g" README.md
# Update Android version badge and info
sed -i "s|Spotify%20Android-.*-orange|Spotify%20Android-${ANDROID_VERSION}-orange|g" README.md
sed -i "s|Android Version\`: \`.*\`|Android Version\`: \`${ANDROID_VERSION}\`|g" README.md
# Update timestamps
sed -i "s|Last checked: .*|Last checked: ${DATE}|g" README.md
sed -i "s|Last Updated\`: .*UTC|Last Updated\`: ${DATE}|g" README.md
# Update status
STATUS="Active"
if [ "${{ steps.commit_web.outputs.status }}" = "updated" ] || \
[ "${{ steps.commit_ios.outputs.status }}" = "updated" ] || \
[ "${{ steps.commit_android.outputs.status }}" = "updated" ]; then
STATUS="Just Updated"
fi
sed -i "s|Status\`: .*|Status\`: ${STATUS}|g" README.md
git add README.md
git diff --quiet && git diff --staged --quiet || (git commit -m "📝 Update README with latest version info" && git push)
- name: Update Commit Status
if: always()
uses: actions/github-script@v6
env:
WEB_COMMIT_STATUS: ${{ steps.commit_web.outputs.status }}
IOS_COMMIT_STATUS: ${{ steps.commit_ios.outputs.status }}
ANDROID_COMMIT_STATUS: ${{ steps.commit_android.outputs.status }}
OLD_WEB_VERSION: ${{ steps.version.outputs.old_web_version }}
NEW_WEB_VERSION: ${{ steps.version.outputs.new_web_version }}
OLD_IOS_VERSION: ${{ steps.version.outputs.old_ios_version }}
NEW_IOS_VERSION: ${{ steps.version.outputs.new_ios_version }}
OLD_ANDROID_VERSION: ${{ steps.version.outputs.old_android_version }}
NEW_ANDROID_VERSION: ${{ steps.version.outputs.new_android_version }}
with:
script: |
const status = ['updated'].includes(process.env.WEB_COMMIT_STATUS) ||
['updated'].includes(process.env.IOS_COMMIT_STATUS) ||
['updated'].includes(process.env.ANDROID_COMMIT_STATUS)
? 'success' : 'success';
const changes = [];
if (process.env.WEB_COMMIT_STATUS === 'updated') {
changes.push(`Web: ${process.env.OLD_WEB_VERSION} → ${process.env.NEW_WEB_VERSION}`);
}
if (process.env.IOS_COMMIT_STATUS === 'updated') {
changes.push(`iOS: ${process.env.OLD_IOS_VERSION} → ${process.env.NEW_IOS_VERSION}`);
}
if (process.env.ANDROID_COMMIT_STATUS === 'updated') {
changes.push(`Android: ${process.env.OLD_ANDROID_VERSION} → ${process.env.NEW_ANDROID_VERSION}`);
}
const message = changes.length > 0
? `Updated: ${changes.join(', ')}`
: `All versions are current`;
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: status,
description: message,
context: 'Spotify Version Check'
});