How to build a unitypackage
I looked at a few projects using this setup and thanks to @fillefilip8, he made a project that builds a .unitypackage
.
All he did was to adapt the build.sh
as shown here.
I'm leaving this as an issue, but I'd like to add this to the ci
folder with it's own script. It should look something like this:
#!/usr/bin/env bash
set -e
set -x
echo "Building package..."
FILE_PATH=$CI_COMMIT_SHA.unitypackage
export BUILD_PATH=./Builds/
export FULL_PATH=$BUILD_PATH$FILE_PATH
export PACKAGE_PATH=Assets\Hertzole
mkdir -p $BUILD_PATH
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/Unity/Editor/Unity \
-projectPath $(pwd) \
-quit \
-batchmode \
-exportPackage $PACKAGE_PATH $FULL_PATH \
-logFile
UNITY_EXIT_CODE=$?
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $UNITY_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $UNITY_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $UNITY_EXIT_CODE";
fi
The file is even published to a different repo with something like this in the .gitlab-ci.yml
:
publish:
variables:
SOME_PROJECT_NAME: some-project-name
image: alpine:latest
stage: deploy
script:
- apk add git
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_LOGIN"
- git clone https://"$GITLAB_USER_LOGIN":"$GITLAB_USER_PASSWORD"@gitlab.com/$GITLAB_USER/$SOME_PROJECT_NAME.git
- mv Builds/* ${SOME_PROJECT_NAME}-files/
- cd ${SOME_PROJECT_NAME}-files
- ls
- git add .
- git status
- git commit -m "$CI_COMMIT_SHA"
- git push
To close this issue, we should add this to the documentation or provide an actual example in the project and document how to use it. :)
Again, thanks to @fillefilip8 <3