-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (160 loc) · 6.48 KB
/
Copy pathrpgxp-release.yml
File metadata and controls
193 lines (160 loc) · 6.48 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
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
183
184
185
186
187
188
189
190
191
192
193
name: RPG Maker XP Release
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
IGNORED_PATHS="README.md|LICENSE|images/|\.github/|\.gitattributes|\.gitignore"
# ── Letzten Release-Tag ermitteln
LATEST_TAG=$(git tag -l 'v*-rpgxp-scripts' --sort=-v:refname | head -n1 || true)
if [ -z "$LATEST_TAG" ]; then
IS_FIRST_RELEASE=true
NEW_VERSION="v1.0.0"
DIFF=$(find . -name "*.rb" -not -path "./.git/*" | sed 's|^\./||' | sed 's/^/A\t/')
else
IS_FIRST_RELEASE=false
LAST_SHA=$(git rev-list -n1 "$LATEST_TAG" 2>/dev/null || true)
if [ -z "$LAST_SHA" ] || ! git cat-file -e "$LAST_SHA" 2>/dev/null; then
IS_FIRST_RELEASE=true
NEW_VERSION="v1.0.0"
DIFF=$(find . -name "*.rb" -not -path "./.git/*" | sed 's|^\./||' | sed 's/^/A\t/')
else
DIFF=$(git diff --name-status "$LAST_SHA" HEAD -- '*.rb' | grep -vP "\t($IGNORED_PATHS)" || echo "")
fi
if [ "$IS_FIRST_RELEASE" = false ]; then
# Version aus dem letzten Tag parsen
CURRENT=$(echo "$LATEST_TAG" | sed 's/^v//' | sed 's/-rpgxp-scripts$//')
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3)
# Prüfen ob neue Ordner hinzugefügt wurden
HAS_NEW_FOLDER=false
if [ -n "$DIFF" ]; then
while IFS=$'\t' read -r status filepath; do
if [[ "$status" == A* ]]; then
folder=$(echo "$filepath" | cut -d'/' -f1)
if ! git ls-tree --name-only "$LAST_SHA" | grep -qF "$folder"; then
HAS_NEW_FOLDER=true
break
fi
fi
done <<< "$DIFF"
fi
if [ "$HAS_NEW_FOLDER" = true ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
fi
fi
TAG_NAME="${NEW_VERSION}-rpgxp-scripts"
if [ -z "$DIFF" ]; then
echo "Keine Script-Änderungen erkannt. Release wird übersprungen."
exit 0
fi
total_files=$(echo "$DIFF" | grep -c . || echo "0")
# ── Kategorien vorbereiten
scripts_added=()
scripts_removed=()
scripts_modified=()
while IFS=$'\t' read -r status filepath; do
[ -z "$status" ] && continue
folder=$(echo "$filepath" | cut -d'/' -f1)
name=$(basename "$filepath")
display="${name%.rb} ($folder)"
case "$status" in
A*) scripts_added+=("$display") ;;
D*) scripts_removed+=("$display") ;;
*) scripts_modified+=("$display") ;;
esac
done <<< "$DIFF"
count_added=${#scripts_added[@]}
count_removed=${#scripts_removed[@]}
count_modified=${#scripts_modified[@]}
# ── Release Notes zusammenbauen
BODY=""
RELEASE_DATE=$(date -u +"%d-%m-%Y")
RELEASE_TIME=$(date -u +"%I:%M %p UTC")
BODY+="**Released: $RELEASE_DATE at $RELEASE_TIME**"$'\n\n'
if [ "$IS_FIRST_RELEASE" = true ]; then
BODY+="Initial release containing $total_files RPG Maker XP scripts across all script collections."$'\n\n'
BODY+="**Included Scripts ($total_files)**"$'\n\n'
for s in "${scripts_added[@]}"; do
BODY+="• ⠀**${s}** added"$'\n'
done
BODY+=$'\n'
else
parts=()
[ $count_added -gt 0 ] && parts+=("$count_added added")
[ $count_modified -gt 0 ] && parts+=("$count_modified modified")
[ $count_removed -gt 0 ] && parts+=("$count_removed removed")
summary=$(IFS=", "; echo "${parts[*]}")
BODY+="Update with $summary script(s)."$'\n\n'
if [ $count_added -gt 0 ]; then
BODY+="**Added ($count_added)**"$'\n\n'
for s in "${scripts_added[@]}"; do
BODY+="• ⠀**${s}** added"$'\n'
done
BODY+=$'\n'
fi
if [ $count_modified -gt 0 ]; then
BODY+="**Modified ($count_modified)**"$'\n\n'
for s in "${scripts_modified[@]}"; do
BODY+="• ⠀**${s}** updated"$'\n'
done
BODY+=$'\n'
fi
if [ $count_removed -gt 0 ]; then
BODY+="**Removed ($count_removed)**"$'\n\n'
for s in "${scripts_removed[@]}"; do
BODY+="• ⠀~~${s}~~ removed"$'\n'
done
BODY+=$'\n'
fi
fi
# ── ZIP-Asset erstellen
echo "Creating release archive..."
if [ "$IS_FIRST_RELEASE" = true ]; then
find . -name "*.rb" -not -path "./.git/*" | zip -@ -q /tmp/rpgxp-scripts.zip
else
FILE_LIST=""
while IFS=$'\t' read -r status filepath; do
[ -z "$status" ] && continue
[[ "$status" == D* ]] && continue
[ -f "$filepath" ] && FILE_LIST+="$filepath"$'\n'
done <<< "$DIFF"
if [ -z "$FILE_LIST" ]; then
echo "No files to include in the release asset."
exit 0
fi
echo -n "$FILE_LIST" | zip -@ -q /tmp/rpgxp-scripts.zip
fi
DATA_SIZE=$(du -h /tmp/rpgxp-scripts.zip | cut -f1)
echo " Archive size: $DATA_SIZE"
# ── Release erstellen
echo "$BODY" > /tmp/release_notes.md
echo "Release Notes:"
cat /tmp/release_notes.md
echo "Creating release: $TAG_NAME"
gh release create "$TAG_NAME" \
/tmp/rpgxp-scripts.zip \
--title "RPG Maker XP Script Library $NEW_VERSION" \
--notes-file /tmp/release_notes.md \
--latest
echo "Release '$TAG_NAME' successfully created!"