-
-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (102 loc) · 3.93 KB
/
weekly-release.yml
File metadata and controls
120 lines (102 loc) · 3.93 KB
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
name: Weekly Release
on:
schedule:
- cron: "0 0 * * 0" # every Sunday at 00:00 UTC
workflow_dispatch:
jobs:
screenshot:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install cwebp
run: sudo apt-get update && sudo apt-get install -y webp
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
cache: "npm"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm ci
- name: Fetch repository data
run: |
git fetch --tags origin
git fetch --unshallow origin main 2>/dev/null || git fetch origin main
- name: Check for new AppIDs
id: new-appids
run: |
# Get the commit SHA of the last release tag
LAST_RELEASE_INFO=$(git ls-remote --tags origin | grep -oP 'refs/tags/v[0-9]{8}' | sort -V | tail -1)
if [ -z "$LAST_RELEASE_INFO" ]; then
# No previous tags, get all commits
COMMIT_HISTORY=$(git log --pretty=format:"%s" origin/main)
echo "No previous release tag found, using all commits"
else
# Get commit SHA of the last tag
LAST_COMMIT_SHA=$(git ls-remote --tags origin "$LAST_RELEASE_INFO" | awk '{print $1}')
echo "Last release commit: $LAST_COMMIT_SHA"
# Get all commits between the last release and current branch
COMMIT_HISTORY=$(git log ${LAST_COMMIT_SHA}..origin/main --pretty=format:"%s")
echo "Last release was: $LAST_RELEASE_INFO"
echo "Total commits since last release:"
echo "$COMMIT_HISTORY" | wc -l
echo "Sample commits:"
echo "$COMMIT_HISTORY" | head -20
fi
# Extract all app IDs from commit messages
APP_IDS=$(echo "$COMMIT_HISTORY" | grep -oP 'Add artwork for app \K[0-9]+' | sort -u)
if [ -z "$APP_IDS" ]; then
echo "has_new=false" >> $GITHUB_OUTPUT
echo "Nothing new since last release."
echo "Debug: All commits (looking for pattern 'Add artwork for app'):"
echo "$COMMIT_HISTORY" | head -50
else
echo "has_new=true" >> $GITHUB_OUTPUT
echo "Found AppIDs: $APP_IDS"
# Save for later use
echo "$APP_IDS" > /tmp/app_ids.txt
fi
- name: Take screenshots
run: node scripts/screenshot.js
- name: Create zip
run: |
cd screenshots
zip -r ../grid.zip grid
- name: Set release date
run: echo "RELEASE_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Format release notes
run: |
if [ -f /tmp/app_ids.txt ] && [ -s /tmp/app_ids.txt ]; then
FORMATTED_IDS=$(while read id; do echo -n "[\`$id\`](https://steamdb.info/app/$id), "; done < /tmp/app_ids.txt | sed 's/, $//')
echo "FORMATTED_IDS<<EOF" >> $GITHUB_ENV
echo "$FORMATTED_IDS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "FORMATTED_IDS=No new AppIDs" >> $GITHUB_ENV
fi
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ env.RELEASE_DATE }}"
name: "v${{ env.RELEASE_DATE }}"
body: |
New artworks for the following games:
${{ env.FORMATTED_IDS }}
files: grid.zip
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup
if: always()
run: |
rm -f /tmp/app_ids.txt
echo "Cleaned up temporary files"