diff --git a/.gitattributes b/.gitattributes index dd67689..622b74c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.scripts/package.sh b/.scripts/package.sh new file mode 100755 index 0000000..7ee3eda --- /dev/null +++ b/.scripts/package.sh @@ -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