build: Allow skipping tests during release
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
#
|
#
|
||||||
# ARG_OPTIONAL_BOOLEAN([no-check],[n],[Skip checking preconditions, such as a clean git working directory])
|
# ARG_OPTIONAL_BOOLEAN([no-check],[n],[Skip checking preconditions, such as a clean git working directory])
|
||||||
|
# ARG_OPTIONAL_BOOLEAN([no-test],[t],[Skip running gradle tests.])
|
||||||
|
# ARG_OPTIONAL_BOOLEAN([dry],[d],[Dry run])
|
||||||
# ARG_HELP([Script to help creating releases])
|
# ARG_HELP([Script to help creating releases])
|
||||||
# ARGBASH_GO()
|
# ARGBASH_GO()
|
||||||
# needed because of Argbash --> m4_ignore([
|
# needed because of Argbash --> m4_ignore([
|
||||||
@@ -23,20 +25,24 @@ die()
|
|||||||
|
|
||||||
begins_with_short_option()
|
begins_with_short_option()
|
||||||
{
|
{
|
||||||
local first_option all_short_options='nh'
|
local first_option all_short_options='ntdh'
|
||||||
first_option="${1:0:1}"
|
first_option="${1:0:1}"
|
||||||
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
|
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# THE DEFAULTS INITIALIZATION - OPTIONALS
|
# THE DEFAULTS INITIALIZATION - OPTIONALS
|
||||||
_arg_no_check="off"
|
_arg_no_check="off"
|
||||||
|
_arg_no_test="off"
|
||||||
|
_arg_dry="off"
|
||||||
|
|
||||||
|
|
||||||
print_help()
|
print_help()
|
||||||
{
|
{
|
||||||
printf '%s\n' "Script to help creating releases"
|
printf '%s\n' "Script to help creating releases"
|
||||||
printf 'Usage: %s [-n|--(no-)no-check] [-h|--help]\n' "$0"
|
printf 'Usage: %s [-n|--(no-)no-check] [-t|--(no-)no-test] [-d|--(no-)dry] [-h|--help]\n' "$0"
|
||||||
printf '\t%s\n' "-n, --no-check, --no-no-check: Skip checking preconditions, such as a clean git working directory (off by default)"
|
printf '\t%s\n' "-n, --no-check, --no-no-check: Skip checking preconditions, such as a clean git working directory (off by default)"
|
||||||
|
printf '\t%s\n' "-t, --no-test, --no-no-test: Skip running gradle tests. (off by default)"
|
||||||
|
printf '\t%s\n' "-d, --dry, --no-dry: Dry run (off by default)"
|
||||||
printf '\t%s\n' "-h, --help: Prints help"
|
printf '\t%s\n' "-h, --help: Prints help"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +65,30 @@ parse_commandline()
|
|||||||
{ begins_with_short_option "$_next" && shift && set -- "-n" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
|
{ begins_with_short_option "$_next" && shift && set -- "-n" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
-t|--no-no-test|--no-test)
|
||||||
|
_arg_no_test="on"
|
||||||
|
test "${1:0:5}" = "--no-" && _arg_no_test="off"
|
||||||
|
;;
|
||||||
|
-t*)
|
||||||
|
_arg_no_test="on"
|
||||||
|
_next="${_key##-t}"
|
||||||
|
if test -n "$_next" -a "$_next" != "$_key"
|
||||||
|
then
|
||||||
|
{ begins_with_short_option "$_next" && shift && set -- "-t" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-d|--no-dry|--dry)
|
||||||
|
_arg_dry="on"
|
||||||
|
test "${1:0:5}" = "--no-" && _arg_dry="off"
|
||||||
|
;;
|
||||||
|
-d*)
|
||||||
|
_arg_dry="on"
|
||||||
|
_next="${_key##-d}"
|
||||||
|
if test -n "$_next" -a "$_next" != "$_key"
|
||||||
|
then
|
||||||
|
{ begins_with_short_option "$_next" && shift && set -- "-d" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
print_help
|
print_help
|
||||||
exit 0
|
exit 0
|
||||||
@@ -129,19 +159,28 @@ fi
|
|||||||
|
|
||||||
echo "Confirming new version as $newversion"
|
echo "Confirming new version as $newversion"
|
||||||
|
|
||||||
|
if [ "$_arg_dry" == off ]; then
|
||||||
echo Committing release commit
|
echo Committing release commit
|
||||||
git commit --allow-empty -m 'Prepare release '"$newversion"'
|
git commit --allow-empty -m 'Prepare release '"$newversion"'
|
||||||
|
|
||||||
[no changelog]'
|
[no changelog]'
|
||||||
echo Tagging release commit
|
echo Tagging release commit
|
||||||
git tag "$newversion"
|
git tag "$newversion"
|
||||||
|
fi
|
||||||
mkdir -p "$basedir/.gradle"
|
mkdir -p "$basedir/.gradle"
|
||||||
releasenotes="$basedir/.gradle/releasenotes.md"
|
releasenotes="$basedir/.gradle/releasenotes.md"
|
||||||
|
|
||||||
|
comparetag="$(
|
||||||
|
if [ "$_arg_dry" == off ]; then
|
||||||
|
echo "$newversion"
|
||||||
|
else
|
||||||
|
echo "HEAD"
|
||||||
|
fi)"
|
||||||
|
|
||||||
echo Building release notes
|
echo Building release notes
|
||||||
echo "**Full Changelog**: <https://github.com/nea89o/Firmament/compare/$oldversion...$newversion>" > "$releasenotes"
|
echo "**Full Changelog**: <https://github.com/nea89o/Firmament/compare/$oldversion...$comparetag>" > "$releasenotes"
|
||||||
echo >> "$releasenotes"
|
echo >> "$releasenotes"
|
||||||
git log --pretty='- %s' --grep '[no changelog]' --invert-grep --fixed-strings "$oldversion..$newversion" | tac >> "$releasenotes"
|
git log --pretty='- %s' --grep '[no changelog]' --invert-grep --fixed-strings "$oldversion..$comparetag" | tac >> "$releasenotes"
|
||||||
echo >> "$releasenotes"
|
echo >> "$releasenotes"
|
||||||
|
|
||||||
echo Check Release notes:
|
echo Check Release notes:
|
||||||
@@ -153,16 +192,22 @@ read
|
|||||||
|
|
||||||
echo Building JAR
|
echo Building JAR
|
||||||
"$basedir"/gradlew --stop
|
"$basedir"/gradlew --stop
|
||||||
|
if [ "$_arg_no_test" == off ]; then
|
||||||
|
echo Building and testing
|
||||||
"$basedir"/gradlew clean build
|
"$basedir"/gradlew clean build
|
||||||
|
else
|
||||||
|
echo Building without testing
|
||||||
|
"$basedir"/gradlew clean assemble
|
||||||
|
fi
|
||||||
|
|
||||||
echo Release notes:
|
echo Release notes:
|
||||||
echo ----------------------------------------------
|
echo ----------------------------------------------
|
||||||
cat "$releasenotes"
|
cat "$releasenotes"
|
||||||
echo ----------------------------------------------
|
echo ----------------------------------------------
|
||||||
|
|
||||||
|
if [ "$_arg_dry" == off ]; then
|
||||||
echo Pushing to github
|
echo Pushing to github
|
||||||
git push "$REMOTE" "HEAD" "$newversion"
|
git push "$REMOTE" "HEAD" "$newversion"
|
||||||
|
|
||||||
if command -v gh; then
|
if command -v gh; then
|
||||||
echo Creating github release
|
echo Creating github release
|
||||||
(set -x; gh release create -t "Firmament $newversion" "$newversion" -F "$releasenotes" "$basedir/build/libs/Firmament-$newversion.jar")
|
(set -x; gh release create -t "Firmament $newversion" "$newversion" -F "$releasenotes" "$basedir/build/libs/Firmament-$newversion.jar")
|
||||||
@@ -170,6 +215,7 @@ else
|
|||||||
echo Could not find github command utility. Opening github releases
|
echo Could not find github command utility. Opening github releases
|
||||||
xdg-open "https://github.com/nea89o/firmament/releases/new"
|
xdg-open "https://github.com/nea89o/firmament/releases/new"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo Opening modrinth releases
|
echo Opening modrinth releases
|
||||||
xdg-open "https://modrinth.com/mod/firmament/versions"
|
xdg-open "https://modrinth.com/mod/firmament/versions"
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ object ItemResources {
|
|||||||
|
|
||||||
fun loadItem(name: String): ItemStack {
|
fun loadItem(name: String): ItemStack {
|
||||||
// TODO: make the load work with enchantments
|
// TODO: make the load work with enchantments
|
||||||
|
// TODO: use DFU to load older items
|
||||||
return ItemStack.CODEC.parse(getNbtOps(), loadSNbt("testdata/items/$name.snbt"))
|
return ItemStack.CODEC.parse(getNbtOps(), loadSNbt("testdata/items/$name.snbt"))
|
||||||
.getOrThrow { IllegalStateException("Could not load test item '$name': $it") }
|
.getOrThrow { IllegalStateException("Could not load test item '$name': $it") }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user