Skip to content

Commit

Permalink
feat: replace docker cp with a mounted volume in build (#47)
Browse files Browse the repository at this point in the history
* feat: replace `docker cp` with mounted volume

Co-authored-by: Kyle a.k.a. TechSquidTV <33272306+KyleTryon@users.noreply.github.com>
  • Loading branch information
EricRibeiro and KyleTryon authored Nov 22, 2022
1 parent 9e3457d commit 08538a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

<!-- please check all items and add your own -->

- [x] Read the contribution [guide](../blob/main/CONTRIBUTING.md) and accept the [code](../blob/main/CODE_OF_CONDUCT.md) of conduct
- [x] Read the contribution [guide](/game-ci/unity-orb/blob/main/CONTRIBUTING.md) and accept the [code](/game-ci/unity-orb/blob/main/CODE_OF_CONDUCT.md) of conduct
- [ ] Documentation (updated or not needed)
- [ ] Tests (added, updated or not needed)
15 changes: 8 additions & 7 deletions src/scripts/windows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ trap_exit() {
}
trap trap_exit EXIT

# Create the build folder
docker exec "$CONTAINER_NAME" powershell mkdir C:/build

# Add the build target and build name in the environment variables.
docker exec "$CONTAINER_NAME" powershell "[System.Environment]::SetEnvironmentVariable('BUILD_NAME','$PARAM_BUILD_NAME', [System.EnvironmentVariableTarget]::Machine)"
docker exec "$CONTAINER_NAME" powershell "[System.Environment]::SetEnvironmentVariable('BUILD_TARGET','$PARAM_BUILD_TARGET', [System.EnvironmentVariableTarget]::Machine)"
Expand Down Expand Up @@ -53,8 +50,12 @@ if [ "$exit_code" -ne 0 ]; then
exit "$exit_code"
fi

# Compress the build folder.
docker exec "$CONTAINER_NAME" powershell 'tar -czf "C:/$Env:BUILD_NAME-$Env:BUILD_TARGET.tar.gz" -C "C:/build" .'
printf '%s\n' "Build completed successfully:"
ls -la "$base_dir/build"

# Copy the build directory to the host.
docker cp "$CONTAINER_NAME":"$PARAM_BUILD_NAME"-"$PARAM_BUILD_TARGET".tar.gz "$base_dir"/"$PARAM_BUILD_TARGET".tar.gz
if [ "$PARAM_COMPRESS" -eq 1 ]; then
printf '%s\n' "Compressing artifacts..."
tar -czf "$base_dir/${PARAM_BUILD_TARGET}.tar.gz" -C "$base_dir/build" .
printf '%s\n' "Done."
ls -la "$base_dir"
fi
6 changes: 5 additions & 1 deletion src/scripts/windows/prepare-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ if ! resolve_unity_serial; then
exit 1
fi

# Create folder to store the build artifacts.
mkdir -p "$base_dir/build" || { echo "Unable to create the build directory"; exit 1; }

set -x

# Run the container and prevent it from exiting.
Expand All @@ -105,6 +108,7 @@ docker run -dit \
--env UNITY_SERIAL="$resolved_unity_serial" \
--volume "$unity_project_full_path":C:/unity_project \
--volume "$base_dir"/regkeys:"C:/regkeys" \
--volume "$base_dir"/build:"C:/build" \
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \
Expand All @@ -118,4 +122,4 @@ docker exec "$container_name" powershell 'reg import C:\regkeys\winsdk.reg'
docker exec "$container_name" powershell 'regsvr32 /s C:\ProgramData\Microsoft\VisualStudio\Setup\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll'

# Activate Unity
docker exec "$container_name" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -quit -nographics -username $Env:UNITY_USERNAME -password $Env:UNITY_PASSWORD -serial $Env:UNITY_SERIAL -logfile | Out-Host'
docker exec "$container_name" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -quit -nographics -username $Env:UNITY_USERNAME -password $Env:UNITY_PASSWORD -serial $Env:UNITY_SERIAL -logfile | Out-Host'

0 comments on commit 08538a8

Please sign in to comment.