Add package testing script

This commit is contained in:
2024-12-11 21:07:19 -06:00
parent 730fa7bc9b
commit 2376022d50
2 changed files with 37 additions and 0 deletions

1
.gitattributes vendored
View File

@@ -8,6 +8,7 @@
# files that should not get included in a release zip
README.md export-ignore
.vscode export-ignore
.scripts export-ignore
.git export-ignore
.github export-ignore
.gitignore export-ignore

36
.scripts/package.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
cwd=$(pwd)
rootDir=$(git rev-parse --show-toplevel)
infoFile="$rootDir/info.json"
modName=$(jq -r '.name' $infoFile)
if [ -z "$modName" ]; then
echo "Error: Mod name not found in info.json"
exit 1
fi
version=$(jq -r '.version' $infoFile)
if [ -z "$version" ]; then
echo "Error: Mod version not found in info.json"
exit 1
fi
outputFile="${modName}_${version}.zip"
# git archive --format zip --prefix $modName/ --worktree-attributes --output ./$outputFile HEAD
cd $rootDir
mkdir $modName
cp -r ./*.lua info.json thumbnail.png locale/ LICENSE $modName/
rm -f $outputFile
zip -r $outputFile $modName
rm -rf $modName/
if [ -n "$1" ]; then
mv $outputFile "$1"
outputFile="$1/$(basename $outputFile)"
fi
cd $pwd
echo $outputFile