Skip to content

Commit 7bd0b38

Browse files
committed
Extend -n to allow setting the file label as well
Resolves #108
1 parent de9cb3c commit 7bd0b38

File tree

2 files changed

+70
-37
lines changed

2 files changed

+70
-37
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,30 @@ Usage: release.sh [options]
273273
-a wago-id Set the project id used on Wago Addons for uploading. (Use 0 to unset the TOC value)
274274
-g game-version Set the game version to use for uploading.
275275
-m pkgmeta.yaml Set the pkgmeta file to use.
276-
-n package-name Set the package zip file name. Use "-n help" for more info.
276+
-n "{template}" Set the package zip file name and upload label. Use "-n help" for more info.
277+
```
278+
279+
```text
280+
Usage: release.sh -n "{template}"
281+
Set the package zip file name and upload file label. There are several string
282+
substitutions you can use to include version control and build type infomation in
283+
the file name and upload label.
284+
285+
The default file name is "{package-name}-{project-version}{nolib}{classic}".
286+
The default upload label is "{project-version}{classic}{nolib}".
287+
288+
To set both, seperate with a ":", i.e, "{file template}:{label template}".
289+
If either side of the ":" is blank, the default will be used. Not including a ":"
290+
will set the file name template, leaving upload label as default.
291+
292+
Tokens: {package-name}{project-revision}{project-hash}{project-abbreviated-hash}
293+
{project-author}{project-date-iso}{project-date-integer}{project-timestamp}
294+
{project-version}{game-type}{release-type}
295+
296+
Flags: {alpha}{beta}{nolib}{classic}
297+
298+
Tokens are always replaced with their value. Flags are shown prefixed with a dash
299+
depending on the build type.
277300
```
278301

279302
### Uploading

release.sh

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ pkgmeta_file=
5454
game_version=
5555
game_type=
5656
file_type=
57-
file_name="{package-name}-{project-version}{nolib}{classic}"
57+
file_template="{package-name}-{project-version}{nolib}{classic}"
58+
label_template="{project-version}{classic}{nolib}"
5859

5960
wowi_markup="bbcode"
6061

@@ -150,7 +151,7 @@ usage() {
150151
-a wago-id Set the project id used on Wago Addons for uploading. (Use 0 to unset the TOC value)
151152
-g game-version Set the game version to use for uploading.
152153
-m pkgmeta.yaml Set the pkgmeta file to use.
153-
-n package-name Set the package zip file name. Use "-n help" for more info.
154+
-n "{template}" Set the package zip file name and upload label. Use "-n help" for more info.
154155
EOF
155156
}
156157

@@ -234,28 +235,43 @@ while getopts ":celLzusop:dw:a:r:t:g:m:n:" opt; do
234235
n) # Set the package file name
235236
if [ "$OPTARG" = "help" ]; then
236237
cat <<-'EOF' >&2
237-
Set the package zip file name. There are several string substitutions you can
238-
use to include version control and build type infomation in the file name.
238+
Usage: release.sh [options]
239+
Set the package zip file name and upload file label. There are several string
240+
substitutions you can use to include version control and build type infomation in
241+
the file name and upload label.
239242
240-
The default file name is "{package-name}-{project-version}{nolib}{classic}".
243+
The default file name is "{package-name}-{project-version}{nolib}{classic}".
244+
The default upload label is "{project-version}{classic}{nolib}".
241245
242-
Tokens: {package-name}{project-revision}{project-hash}{project-abbreviated-hash}
243-
{project-author}{project-date-iso}{project-date-integer}{project-timestamp}
244-
{project-version}{game-type}{release-type}
246+
To set both, seperate with a ":", i.e, "{file template}:{label template}".
247+
If either side of the ":" is blank, the default will be used.Not including a ":"
248+
will set the file name template, leaving upload label as default.
245249
246-
Flags: {alpha}{beta}{nolib}{classic}
250+
Tokens: {package-name}{project-revision}{project-hash}{project-abbreviated-hash}
251+
{project-author}{project-date-iso}{project-date-integer}{project-timestamp}
252+
{project-version}{game-type}{release-type}
247253
248-
Tokens are always replaced with their value. Flags are shown prefixed with a dash
249-
depending on the build type.
254+
Flags: {alpha}{beta}{nolib}{classic}
255+
256+
Tokens are always replaced with their value. Flags are shown prefixed with a dash
257+
depending on the build type.
250258
EOF
251259
exit 0
252260
fi
253-
file_name="$OPTARG"
254-
if skip_invalid=true filename_filter "$file_name" | grep -q '[{}]'; then
255-
tokens=$( skip_invalid=true filename_filter "$file_name" | sed -e '/^[^{]*{\|}[^{]*{\|}[^{]*/s//}{/g' -e 's/^}\({.*}\){$/\1/' )
261+
if skip_invalid=true filename_filter "$OPTARG" | grep -q '[{}]'; then
262+
tokens=$( skip_invalid=true filename_filter "$OPTARG" | sed -e '/^[^{]*{\|}[^{]*{\|}[^{]*/s//}{/g' -e 's/^}\({.*}\){$/\1/' )
256263
echo "Invalid argument for option \"-n\" - Invalid substitutions: $tokens" >&2
257264
exit 1
258265
fi
266+
file_template=${OPTARG%%:*}
267+
if [ -z "$file_template" ]; then
268+
file_template="{package-name}-{project-version}{nolib}{classic}"
269+
fi
270+
label_template=${OPTARG##*:}
271+
if [ -z "$label_template" ]; then
272+
label_template="{project-version}{classic}{nolib}"
273+
fi
274+
#"{package-name}-{project-version}{nolib}{classic}:{project-version}{classic}{nolib}"
259275
;;
260276
:)
261277
echo "Option \"-$OPTARG\" requires an argument." >&2
@@ -2158,42 +2174,36 @@ fi
21582174
###
21592175

21602176
if [ -z "$skip_zipfile" ]; then
2161-
archive_version="$project_version"
2162-
archive_name="$( filename_filter "$file_name" ).zip"
2163-
archive_label="$archive_version"
2164-
if [[ "${file_name}" == *"{game-type}"* ]] || [[ "$game_type" != "retail" && "${file_name}" == *"{classic}"* ]]; then
2165-
# append the game-type for clarity
2166-
archive_label="$archive_version-$game_type"
2167-
if [[ "$game_type" == "classic" && "${project_version,,}" == *"-classic"* ]] || [[ "$game_type" == "bcc" && "${project_version,,}" == *"-bcc"* ]]; then
2168-
# this is mostly for BigWigs projects that tag classic separately (eg, v10-classic)
2169-
# to prevent the extra -classic without changing all our workflows
2170-
archive_label="$archive_version"
2171-
fi
2172-
fi
2177+
archive_version="$project_version" # XXX used for wowi version. should probably switch to label, but the game type gets added on by default :\
2178+
archive_label="$( filename_filter "$label_template" )"
2179+
archive_name="$( filename_filter "$file_template" ).zip"
21732180
archive="$releasedir/$archive_name"
21742181

2175-
if [ -n "$GITHUB_ACTIONS" ]; then
2176-
echo "::set-output name=archive_path::${archive}"
2177-
fi
2178-
21792182
nolib_archive_version="${project_version}-nolib"
2180-
nolib_archive_name="$( nolib=true filename_filter "$file_name" ).zip"
2183+
nolib_archive_label="$( nolib=true filename_filter "$archive_label" )"
2184+
nolib_archive_name="$( nolib=true filename_filter "$file_template" ).zip"
2185+
# someone didn't include {nolib} and they're forcing nolib creation
2186+
if [ "$archive_label" = "$nolib_archive_label" ]; then
2187+
nolib_archive_label="${nolib_archive_label}-nolib"
2188+
fi
21812189
if [ "$archive_name" = "$nolib_archive_name" ]; then
2182-
# someone didn't include {nolib} and they're forcing nolib creation
21832190
nolib_archive_name="${nolib_archive_name#.zip}-nolib.zip"
21842191
fi
2185-
nolib_archive_label="${archive_label}-nolib"
21862192
nolib_archive="$releasedir/$nolib_archive_name"
21872193

21882194
if [ -n "$nolib" ]; then
21892195
archive_version="$nolib_archive_version"
2190-
archive_name="$nolib_archive_name"
21912196
archive_label="$nolib_archive_label"
2197+
archive_name="$nolib_archive_name"
21922198
archive="$nolib_archive"
21932199
nolib_archive=
21942200
fi
21952201

2196-
start_group "Creating archive: $archive_name" "archive"
2202+
if [ -n "$GITHUB_ACTIONS" ]; then
2203+
echo "::set-output name=archive_path::${archive}"
2204+
fi
2205+
2206+
start_group "Creating archive: $archive_name ($archive_label)" "archive"
21972207
if [ -f "$archive" ]; then
21982208
rm -f "$archive"
21992209
fi
@@ -2218,7 +2228,7 @@ if [ -z "$skip_zipfile" ]; then
22182228
# make the exclude paths relative to the release directory
22192229
nolib_exclude=${nolib_exclude//$releasedir\//}
22202230

2221-
start_group "Creating no-lib archive: $nolib_archive_name" "archive.nolib"
2231+
start_group "Creating no-lib archive: $nolib_archive_name ($nolib_archive_label)" "archive.nolib"
22222232
if [ -f "$nolib_archive" ]; then
22232233
rm -f "$nolib_archive"
22242234
fi

0 commit comments

Comments
 (0)