-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (146 loc) · 6.16 KB
/
rpgxp-release.yml
File metadata and controls
178 lines (146 loc) · 6.16 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
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
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)
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 "No script changes detected. Skipping release."
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)
readable=$(echo "$folder" | sed 's/^[0-9]*-//' | sed 's/-/ /g')
case "$status" in
A*) scripts_added+=("$readable") ;;
D*) scripts_removed+=("$readable") ;;
*) scripts_modified+=("$readable") ;;
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+="**Release: $RELEASE_DATE at $RELEASE_TIME**"$'\n\n'
if [ "$IS_FIRST_RELEASE" = true ]; then
BODY+="This release contains $total_files RPG Maker XP scripts designed to improve gameplay mechanics and visual presentation. Each script is a drop-in replacement that maintains full compatibility with the standard RPG Maker XP framework while adding new functionality."$'\n\n'
for s in "${scripts_added[@]}"; do
BODY+="• ⠀Added ${s}"$'\n'
done
else
parts=()
[ $count_added -gt 0 ] && parts+=("$count_added added")
[ $count_modified -gt 0 ] && parts+=("$count_modified updated")
[ $count_removed -gt 0 ] && parts+=("$count_removed removed")
summary=$(IFS=", "; echo "${parts[*]}")
BODY+="This release includes ${summary} script(s)."$'\n\n'
if [ $count_added -gt 0 ]; then
for s in "${scripts_added[@]}"; do
BODY+="• ⠀Added ${s}"$'\n'
done
fi
if [ $count_modified -gt 0 ]; then
for s in "${scripts_modified[@]}"; do
BODY+="• ⠀Enhanced ${s}"$'\n'
done
fi
if [ $count_removed -gt 0 ]; then
for s in "${scripts_removed[@]}"; do
BODY+="• ⠀Removed ~~${s}~~"$'\n'
done
fi
fi
BODY+=$'\n'"**Note:** If you encounter any bugs or issues, please don't hesitate to open an issue. For any questions or to start a discussion, feel free to initiate a discussion on the GitHub repository."
# ── Release-Assets sammeln (einzelne .rb Dateien)
ASSET_FILES=()
while IFS=$'\t' read -r status filepath; do
[ -z "$status" ] && continue
[[ "$status" == D* ]] && continue
[ -f "$filepath" ] && ASSET_FILES+=("$filepath")
done <<< "$DIFF"
if [ ${#ASSET_FILES[@]} -eq 0 ]; then
echo "No files to include in the release."
exit 0
fi
echo "Assets to upload (${#ASSET_FILES[@]}):"
printf " %s\n" "${ASSET_FILES[@]}"
# ── Release erstellen
echo "$BODY" > /tmp/release_notes.md
echo ""
echo "Release Notes:"
cat /tmp/release_notes.md
echo ""
echo "Creating release: $TAG_NAME"
gh release create "$TAG_NAME" \
"${ASSET_FILES[@]}" \
--title "RPG Maker XP Script Library $NEW_VERSION" \
--notes-file /tmp/release_notes.md \
--latest
echo "Release '$TAG_NAME' created successfully!"