From 8722a6dccd4a9deb142a8d4062d359db9e2413fd Mon Sep 17 00:00:00 2001 From: Andrew Kahr <22359829+AndrewKahr@users.noreply.github.com> Date: Tue, 31 Oct 2023 17:16:24 -0700 Subject: [PATCH] Update Windows to 2022 and enable Android Windows Images (#231) - Update windows images to 2022 from 2019. We need to do this because 2019 will go EOL in January which means Github will start failing builds using it and ultimately remove it within a few months after EOL based on how they operated with Server 2016. This means people will need to upgrade their workflows to use windows-2022 instead of windows-2019 and update any self hosted runners to support server-2022 containers (either use Windows Server 2022 or Windows 11 as their host) - Setup Android dependencies to allow for Android builds on Windows. This enables using Burst on Android builds which is a major performance booster. - Update several action workflow versions to fix dependabot warnings - Setup better test exclusion patterns for Windows - Move Unity install path to C:/UnityEditor. This fixes old versions of sdkmanager that don't handle spaces in the path. Using the UNITY_PATH environment variable will mitigate any changes like this in the future in downstream scripts. --- .github/workflows/main.yml | 4 +- .../new-ubuntu-base-image-requested.yml | 12 +-- .../new-ubuntu-hub-image-requested.yml | 12 +-- ...w-ubuntu-legacy-editor-image-requested.yml | 14 +-- ...ntu-post-2019-2-editor-image-requested.yml | 14 +-- .../new-windows-base-image-requested.yml | 14 +-- .../new-windows-hub-image-requested.yml | 15 ++-- ...-windows-legacy-editor-image-requested.yml | 27 +++--- ...ows-post-2019-2-editor-image-requested.yml | 23 ++--- .../retry-ubuntu-editor-image-requested.yml | 12 +-- .../retry-windows-editor-image-requested.yml | 4 +- .github/workflows/test.yml | 89 +++++++++++-------- images/windows/README.md | 3 - images/windows/base/Dockerfile | 6 +- images/windows/editor/Dockerfile | 77 +++++++++++----- .../editor/scripts/AcceptAndroidLicenses.ps1 | 8 ++ .../editor/scripts/HelperFunctions.ps1 | 57 ++++++++++++ .../windows/editor/scripts/SetupAndroid.ps1 | 36 ++++++++ 18 files changed, 286 insertions(+), 141 deletions(-) delete mode 100644 images/windows/README.md create mode 100644 images/windows/editor/scripts/AcceptAndroidLicenses.ps1 create mode 100644 images/windows/editor/scripts/HelperFunctions.ps1 create mode 100644 images/windows/editor/scripts/SetupAndroid.ps1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ace99e1..e86d2816 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,7 @@ name: Docs 📚 on: - push: { branches: [ main ] } + push: { branches: [main] } jobs: updateDescriptions: @@ -16,7 +16,7 @@ jobs: - editor steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Caveat - Currently we use the ubuntu readme as we do not have a catch-all readme (yet?) - run: | echo "SHORT_DESCRIPTION=$(cat ./images/ubuntu/${{ matrix.imageType }}/100-characters-dockerhub-description.txt)" >> $GITHUB_ENV diff --git a/.github/workflows/new-ubuntu-base-image-requested.yml b/.github/workflows/new-ubuntu-base-image-requested.yml index c8fcfa6b..78e9c08d 100644 --- a/.github/workflows/new-ubuntu-base-image-requested.yml +++ b/.github/workflows/new-ubuntu-base-image-requested.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -25,7 +25,7 @@ jobs: run: | LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) git checkout $LATEST_TAG - + ################# # Variables # ################# @@ -50,11 +50,11 @@ jobs: # Setup # ############# - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -81,7 +81,7 @@ jobs: # Base image # ################## - name: Build and publish - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 id: build_ubuntu_base_image with: file: ./images/ubuntu/base/Dockerfile diff --git a/.github/workflows/new-ubuntu-hub-image-requested.yml b/.github/workflows/new-ubuntu-hub-image-requested.yml index 47654a4d..8caab97b 100644 --- a/.github/workflows/new-ubuntu-hub-image-requested.yml +++ b/.github/workflows/new-ubuntu-hub-image-requested.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -25,7 +25,7 @@ jobs: run: | LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) git checkout $LATEST_TAG - + ################# # Variables # ################# @@ -50,11 +50,11 @@ jobs: # Setup # ############# - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -86,7 +86,7 @@ jobs: # Hub image # ################# - name: Build and publish - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 id: build_ubuntu_hub_image with: file: ./images/ubuntu/hub/Dockerfile diff --git a/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml b/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml index 3c61ff4c..f75ccf1e 100644 --- a/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml +++ b/.github/workflows/new-ubuntu-legacy-editor-image-requested.yml @@ -27,7 +27,7 @@ jobs: - webgl steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -35,7 +35,7 @@ jobs: run: | LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) git checkout $LATEST_TAG - + ################# # Variables # ################# @@ -64,11 +64,11 @@ jobs: # Setup # ############# - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -99,7 +99,7 @@ jobs: # Ubuntu Editor image # ########################### - name: Build and publish - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 id: build_ubuntu_editor_image continue-on-error: true with: @@ -126,7 +126,7 @@ jobs: # Retry the above # ####################### - name: Build and publish (retry) - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 if: steps.build_ubuntu_editor_image.outcome=='failure' id: build_ubuntu_editor_image_retry with: diff --git a/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml b/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml index ac12655f..045b15f8 100644 --- a/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml +++ b/.github/workflows/new-ubuntu-post-2019-2-editor-image-requested.yml @@ -27,7 +27,7 @@ jobs: - webgl steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -35,7 +35,7 @@ jobs: run: | LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) git checkout $LATEST_TAG - + ################# # Variables # ################# @@ -64,11 +64,11 @@ jobs: # Setup # ############# - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -99,7 +99,7 @@ jobs: # Ubuntu Editor image # ########################### - name: Build and publish - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 id: build_ubuntu_editor_image continue-on-error: true with: @@ -126,7 +126,7 @@ jobs: # Retry the above # ####################### - name: Build and publish (retry) - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 if: steps.build_ubuntu_editor_image.outcome=='failure' id: build_ubuntu_editor_image_retry with: diff --git a/.github/workflows/new-windows-base-image-requested.yml b/.github/workflows/new-windows-base-image-requested.yml index 5d244ef1..c100cf06 100644 --- a/.github/workflows/new-windows-base-image-requested.yml +++ b/.github/workflows/new-windows-base-image-requested.yml @@ -8,17 +8,17 @@ on: workflow_dispatch: inputs: jobId: - description: 'Job ID' + description: "Job ID" required: true - default: 'dryRun' + default: "dryRun" repoVersionFull: - description: 'All digits of the latest tag of this repository, e.g. `1.23.45`' + description: "All digits of the latest tag of this repository, e.g. `1.23.45`" required: true repoVersionMinor: - description: 'Minor digit of that tag, e.g. `23`' + description: "Minor digit of that tag, e.g. `23`" required: true repoVersionMajor: - description: 'Major digit of that tag, e.g. `1`' + description: "Major digit of that tag, e.g. `1`" required: true # Further reading: @@ -29,10 +29,10 @@ on: jobs: build: name: "🛠 Build unityci/base" - runs-on: windows-2019 + runs-on: windows-2022 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/new-windows-hub-image-requested.yml b/.github/workflows/new-windows-hub-image-requested.yml index 8c930383..a3506885 100644 --- a/.github/workflows/new-windows-hub-image-requested.yml +++ b/.github/workflows/new-windows-hub-image-requested.yml @@ -8,17 +8,17 @@ on: workflow_dispatch: inputs: jobId: - description: 'Job ID' + description: "Job ID" required: true - default: 'dryRun' + default: "dryRun" repoVersionFull: - description: 'All digits of the latest tag of this repository, e.g. `1.23.45`' + description: "All digits of the latest tag of this repository, e.g. `1.23.45`" required: true repoVersionMinor: - description: 'Minor digit of that tag, e.g. `23`' + description: "Minor digit of that tag, e.g. `23`" required: true repoVersionMajor: - description: 'Major digit of that tag, e.g. `1`' + description: "Major digit of that tag, e.g. `1`" required: true # Further reading: @@ -29,10 +29,10 @@ on: jobs: build: name: "🛠 Build unityci/hub" - runs-on: windows-2019 + runs-on: windows-2022 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -112,7 +112,6 @@ jobs: # TODO: Cache layers, currently not supported on windows - ############################ # Pull previous images # ############################ diff --git a/.github/workflows/new-windows-legacy-editor-image-requested.yml b/.github/workflows/new-windows-legacy-editor-image-requested.yml index 61832076..f93a2aa7 100644 --- a/.github/workflows/new-windows-legacy-editor-image-requested.yml +++ b/.github/workflows/new-windows-legacy-editor-image-requested.yml @@ -4,25 +4,25 @@ on: workflow_dispatch: inputs: jobId: - description: 'Job ID' + description: "Job ID" required: true - default: 'dryRun' + default: "dryRun" editorVersion: - description: 'Unity Editor Version' + description: "Unity Editor Version" required: true - default: '2020.3.24f1' + default: "2020.3.24f1" changeSet: - description: 'Unity Editor Changeset' + description: "Unity Editor Changeset" required: true - default: '79c78de19888' + default: "79c78de19888" repoVersionFull: - description: 'All digits of the latest tag of this repository, e.g. `1.23.45`' + description: "All digits of the latest tag of this repository, e.g. `1.23.45`" required: true repoVersionMinor: - description: 'Minor digit of that tag, e.g. `23`' + description: "Minor digit of that tag, e.g. `23`" required: true repoVersionMajor: - description: 'Major digit of that tag, e.g. `1`' + description: "Major digit of that tag, e.g. `1`" required: true # Further reading: @@ -33,19 +33,16 @@ on: jobs: buildImage: name: "🛠 Build unityci/editor (${{ matrix.targetPlatform }})" - runs-on: windows-2019 + runs-on: windows-2022 strategy: fail-fast: false matrix: targetPlatform: - base - # - windows-il2cpp - # - universal-windows-platform - # - appletv steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -54,7 +51,7 @@ jobs: LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) git checkout $LATEST_TAG shell: bash - + ################# # Variables # ################# diff --git a/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml b/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml index 3caa9e01..d62cab6c 100644 --- a/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml +++ b/.github/workflows/new-windows-post-2019-2-editor-image-requested.yml @@ -7,25 +7,25 @@ on: workflow_dispatch: inputs: jobId: - description: 'Job ID' + description: "Job ID" required: true - default: 'dryRun' + default: "dryRun" editorVersion: - description: 'Unity Editor Version' + description: "Unity Editor Version" required: true - default: '2020.3.24f1' + default: "2020.3.24f1" changeSet: - description: 'Unity Editor Changeset' + description: "Unity Editor Changeset" required: true - default: '79c78de19888' + default: "79c78de19888" repoVersionFull: - description: 'All digits of the latest tag of this repository, e.g. `1.23.45`' + description: "All digits of the latest tag of this repository, e.g. `1.23.45`" required: true repoVersionMinor: - description: 'Minor digit of that tag, e.g. `23`' + description: "Minor digit of that tag, e.g. `23`" required: true repoVersionMajor: - description: 'Major digit of that tag, e.g. `1`' + description: "Major digit of that tag, e.g. `1`" required: true # Further reading: @@ -36,7 +36,7 @@ on: jobs: buildImage: name: "🛠 Build unityci/editor (${{ matrix.targetPlatform }})" - runs-on: windows-2019 + runs-on: windows-2022 strategy: fail-fast: false matrix: @@ -45,11 +45,12 @@ jobs: - windows-il2cpp - universal-windows-platform - appletv + - android # - lumin # TODO: Determine if we can build for lumin. Requires 3rd party SDK with several versions steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/retry-ubuntu-editor-image-requested.yml b/.github/workflows/retry-ubuntu-editor-image-requested.yml index 8c3ca5b7..4f000fbf 100644 --- a/.github/workflows/retry-ubuntu-editor-image-requested.yml +++ b/.github/workflows/retry-ubuntu-editor-image-requested.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 ################# # Variables # ################# @@ -46,11 +46,11 @@ jobs: # Setup # ############# - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -81,7 +81,7 @@ jobs: # Editor image # #################### - name: Build and publish - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 id: build_ubuntu_editor_image continue-on-error: true with: @@ -107,7 +107,7 @@ jobs: # Retry the above # ####################### - name: Build and publish (retry) - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 if: steps.build_ubuntu_editor_image.outcome=='failure' id: build_ubuntu_editor_image_retry with: diff --git a/.github/workflows/retry-windows-editor-image-requested.yml b/.github/workflows/retry-windows-editor-image-requested.yml index 91d4b360..1d41a60f 100644 --- a/.github/workflows/retry-windows-editor-image-requested.yml +++ b/.github/workflows/retry-windows-editor-image-requested.yml @@ -13,10 +13,10 @@ on: jobs: buildImage: name: "🛠 Retry unityci/editor (${{ github.event.client_payload.targetPlatform }})" - runs-on: windows-2019 + runs-on: windows-2022 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 ################# # Variables # ################# diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7ba212f..552e8116 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: targetPlatform: android steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Report new build uses: ./.github/workflows/actions/report-to-backend with: @@ -70,7 +70,7 @@ jobs: editorVersion: ${{ matrix.editorVersion }} targetPlatform: ${{ matrix.targetPlatform }} # Failed specific - reason: 'no real reason' + reason: "no real reason" - name: Report publication uses: ./.github/workflows/actions/report-to-backend with: @@ -89,7 +89,7 @@ jobs: friendlyTag: ${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }} specificTag: ${{ matrix.baseOs }}-${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }} digest: sha256:ef872b67450a680fbeebe1b037190b8f8fbfb04088531f422873915520e26e0f; - + ########################## # Setup build matrix # ########################## @@ -98,7 +98,8 @@ jobs: runs-on: ubuntu-latest outputs: versions: ${{ steps.setup.outputs.versions }} - excludes: ${{ steps.setup.outputs.excludes }} + linuxExcludes: ${{ steps.setup.outputs.linuxExcludes }} + windowsExcludes: ${{ steps.setup.outputs.windowsExcludes }} steps: - name: "Setup build matrix" id: setup @@ -108,22 +109,33 @@ jobs: echo "Versions: $VERSIONS" echo "versions=$VERSIONS" >> $GITHUB_OUTPUT - # Exclude linux-il2cpp and windows-il2cpp for Unity 2019.2 or earlier - EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2\")) | { version: ., module: \"linux-il2cpp\"} ]'`" - - # Unity 2021.1 and 2021.2 do not build properly on windows targets - EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2|2021.1|2021.2\")) | { version: ., module: \"windows-il2cpp\"} ]'`" + # Exclude il2cpp for Unity 2019.2 or earlier + LINUX_EXCLUDES="$LINUX_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2\")) | { version: ., module: \"linux-il2cpp\"} ]'`" + + # Exclude il2cpp for Unity 2019.2 or earlier. Unity 2021.1 and 2021.2 also do not build properly and will be skipped + WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2|2021.1|2021.2\")) | { version: ., module: \"windows-il2cpp\"} ]'`" + + # Universal Windows Platform is added in 2019. Issues with 2021.1 and 2021.2 so they are skipped too + WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2021.1|2021.2\")) | { version: ., module: \"universal-windows-platform\"} ]'`" + + # AppleTV isn't stable until 2019.2. Issues with 2021.1 and 2021.2 so they are skipped too + WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2021.1|2021.2\")) | { version: ., module: \"appletv\"} ]'`" + + # No Windows 2018 Android Builds. Issues with 2021.1 and 2021.2 so they are skipped too + WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2021.1|2021.2\")) | { version: ., module: \"android\"} ]'`" + + # No Windows mono Builds for Unity 2019.2 or earlier. Issues with 2021.1 and 2021.2 so they are skipped too + WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2|2021.1|2021.2\")) | { version: ., module: \"base\"} ]'`" - # Universal Windows Platform is added in 2019 - EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2021.1|2021.2\")) | { version: ., module: \"universal-windows-platform\"} ]'`" + LINUX_EXCLUDES=`echo "$LINUX_EXCLUDES" | jq -s -c 'flatten'` + WINDOWS_EXCLUDES=`echo "$WINDOWS_EXCLUDES" | jq -s -c 'flatten'` - # AppleTV isn't stable until 2019.2 - EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2021.1|2021.2\")) | { version: ., module: \"appletv\"} ]'`" + echo "Linux Excludes: $LINUX_EXCLUDES" + echo "Windows Excludes: $WINDOWS_EXCLUDES" + + echo "linuxExcludes=$LINUX_EXCLUDES" >> $GITHUB_OUTPUT + echo "windowsExcludes=$WINDOWS_EXCLUDES" >> $GITHUB_OUTPUT - EXCLUDES=`echo "$EXCLUDES" | jq -s -c 'flatten'` - echo "Excludes: $EXCLUDES" - echo "excludes=$EXCLUDES" >> $GITHUB_OUTPUT - ################################# # Build Ubuntu base and hub # ################################# @@ -134,9 +146,9 @@ jobs: ############# # Setup # ############# - - uses: actions/checkout@v3 - - uses: docker/setup-qemu-action@v2 - - uses: docker/setup-buildx-action@v2 + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 with: driver: docker @@ -144,12 +156,12 @@ jobs: # Build Ubuntu base and hub # ################################# - name: Build base - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: file: ./images/ubuntu/base/Dockerfile tags: base:ubuntu-dev - name: Build hub - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: file: ./images/ubuntu/hub/Dockerfile build-args: baseImage=base:ubuntu-dev @@ -173,12 +185,12 @@ jobs: ################################## windows-base-and-hub: name: Windows Base and Hub - runs-on: windows-2019 + runs-on: windows-2022 steps: ############# # Setup # ############# - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ################################## # Build Windows base and hub # @@ -189,7 +201,7 @@ jobs: - name: Build hub run: | docker build -t hub:windows-dev -f ./images/windows/hub/Dockerfile --build-arg baseImage=base:windows-dev . - + ################################################### # Save images for later steps in the workflow # ################################################### @@ -205,7 +217,7 @@ jobs: cd c:\artifact docker save -o windows-base-and-hub.tar base:windows-dev hub:windows-dev zstd -z -12 --format=zstd windows-base-and-hub.tar - + - uses: actions/upload-artifact@v3 with: name: windows-base-and-hub @@ -251,15 +263,15 @@ jobs: platform: Android - module: webgl platform: WebGL - exclude: ${{ fromJson(needs.build-matrix.outputs.excludes) }} + exclude: ${{ fromJson(needs.build-matrix.outputs.linuxExcludes) }} steps: ############# # Setup # ############# - - uses: actions/checkout@v3 - - uses: docker/setup-qemu-action@v2 - - uses: docker/setup-buildx-action@v2 + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 with: driver: docker - name: Free disk space @@ -297,7 +309,7 @@ jobs: ########################### - name: Build # if: steps.build-1.outcome == 'failure' - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 id: build-1 continue-on-error: true timeout-minutes: 40 @@ -320,7 +332,7 @@ jobs: - name: Build (Retry) if: steps.build-1.outcome == 'failure' - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 id: build-2 # continue-on-error: true timeout-minutes: 40 @@ -430,7 +442,7 @@ jobs: windows-editor: needs: [windows-base-and-hub, build-matrix] name: Windows (${{ matrix.version }}, ${{ matrix.module }}) - runs-on: windows-2019 + runs-on: windows-2022 strategy: fail-fast: false matrix: @@ -441,6 +453,7 @@ jobs: - windows-il2cpp - universal-windows-platform - appletv + - android include: - module: base platform: StandaloneWindows64 @@ -450,13 +463,15 @@ jobs: platform: tvOS - module: universal-windows-platform platform: WSAPlayer - exclude: ${{ fromJson(needs.build-matrix.outputs.excludes) }} + - module: android + platform: Android + exclude: ${{ fromJson(needs.build-matrix.outputs.windowsExcludes) }} steps: ############# # Setup # ############# - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ############################ # Restore base and hub # @@ -498,7 +513,7 @@ jobs: ########################### - name: Build continue-on-error: true - timeout-minutes: 60 + timeout-minutes: 90 id: build-1 run: | docker build -t editor:windows-dev --build-arg baseImage=base:windows-dev ` @@ -515,7 +530,7 @@ jobs: - name: Build (Retry) if: steps.build-1.outcome == 'failure' id: build-2 - timeout-minutes: 60 + timeout-minutes: 90 run: | docker build -t editor:windows-dev --build-arg baseImage=base:windows-dev ` --build-arg hubImage=hub:windows-dev --build-arg version=${{ matrix.version }} ` diff --git a/images/windows/README.md b/images/windows/README.md deleted file mode 100644 index c738f4e8..00000000 --- a/images/windows/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Windows images - -See _#windows-images_ on our Discord server to follow our progress. diff --git a/images/windows/base/Dockerfile b/images/windows/base/Dockerfile index 9c57e485..7feddb44 100644 --- a/images/windows/base/Dockerfile +++ b/images/windows/base/Dockerfile @@ -1,8 +1,8 @@ -ARG windowsDllSourceImage="mcr.microsoft.com/windows:1809" -ARG windowsImage="mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019" +ARG windowsDllSourceImage="mcr.microsoft.com/windows/server:ltsc2022" +ARG windowsImage="mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022" # Need this image to grab missing dlls for the server core version -FROM $windowsDllSourceImage as dll-source +FROM $windowsDllSourceImage AS dll-source # We use the .net framework servercore image because we will need the .net support # anyway and there is no real benefit to try and make this smaller by diff --git a/images/windows/editor/Dockerfile b/images/windows/editor/Dockerfile index 90dfa762..b7a46902 100644 --- a/images/windows/editor/Dockerfile +++ b/images/windows/editor/Dockerfile @@ -5,30 +5,46 @@ ARG hubImage="unityci/hub:windows-latest" # Builder # ############# -FROM $hubImage as Builder +FROM $hubImage AS Builder + +# Using bash to process unity install +RUN choco install git --no-progress -y + +SHELL ["cmd", "/S", "/C"] + +RUN setx path "C:\\Program Files\\Git\\bin;%path%" + +SHELL ["bash.exe", "-c"] # Install Editor # The portion after the & is to change the exit code to 0 if we exited 1 from # the installation. Otherwise docker believes there was an error ARG version ARG changeSet -RUN powershell -Command "&'C:/Program Files/Unity Hub/Unity Hub.exe' '--%' '--no-sandbox --headless install \ - --version %version% --changeset %changeset%' 2>$null | \ - Tee-Object -FilePath 'C:\install-editor.log'; \ - if ((select-string -Path 'C:\install-editor.log' -Pattern \ - 'Failed to install|Error while installing an editor|Completed with errors') -ne $null) { exit 1 } \ - else { exit 0 }" + +RUN "mkdir -p /var/log && mkdir -p C:/UnityEditor" + +RUN "C:/Program\ Files/Unity\ Hub/Unity\ Hub.exe -- --headless install-path --set C:/UnityEditor" + +RUN "C:/Program\ Files/Unity\ Hub/Unity\ Hub.exe -- --headless install \ + --version $version \ + --changeset $changeSet \ + | tee /var/log/install-editor.log \ + && grep 'Error' /var/log/install-editor.log \ + | exit $(wc -l)" ARG module -RUN IF NOT "%module%"=="base" ( \ - powershell -Command \ - "&'C:/Program Files/Unity Hub/Unity Hub.exe' '--%' '--no-sandbox --headless \ - install-modules --version %version% --module %module% --childModules' 2>$null | \ - Tee-Object -FilePath 'C:\install-module-%module%.log'; \ - if ((select-string -Path 'C:\install-module-%module%.log' -Pattern \ - 'Failed to install|Error while installing an editor|Completed with errors|Missing module|No modules found') -ne $null) \ - { exit 1 } else { exit 0 }" \ - ) +RUN "if [ $module = 'base' ]; then \ + echo 'running default modules for this base OS'; \ + else \ + C:/Program\ Files/Unity\ Hub/Unity\ Hub.exe -- --headless install-modules \ + --version $version \ + --module $module \ + --childModules \ + | tee /var/log/install-module-${module}.log \ + && grep 'Missing module' /var/log/install-module-${module}.log \ + | exit $(wc -l); \ + fi" ############ # Editor # @@ -36,8 +52,10 @@ RUN IF NOT "%module%"=="base" ( \ FROM $baseImage +SHELL ["powershell.exe", "-Command"] + # Copy the editor from the builder to the final editor image -COPY --from=Builder ["C:/Program Files/Unity/Hub/Editor/", "C:/Program Files/Unity/Hub/Editor/"] +COPY --from=Builder ["C:/UnityEditor/", "C:/UnityEditor/"] # Need to grab these dependencies that the editor needs to run COPY --from=Builder C:/windows/system32/MSVCP100.dll \ @@ -48,14 +66,31 @@ COPY --from=Builder C:/windows/system32/MSVCP100.dll \ # Add version to file at editor path ARG version -RUN echo %version% > "C:/Program Files/Unity/Hub/Editor/%version%/version" +RUN echo "$Env:version" > "C:/UnityEditor/$Env:version/version" + +RUN setx -M UNITY_PATH "C:/UnityEditor/$Env:version" + +# Packages/manifest.json could have git dependencies +RUN choco install git --no-progress -y + +# Unity package manager throws an error about not being in a git directory when +# importing git packages without this +RUN git config --global --add safe.directory "*" # Need to enable these services to make Unity happy # When these were in base, things blew up, not sure why they have to be specifically here -RUN powershell -Command foreach ($service in 'nlasvc', 'netprofm') {"Set-Service $service -StartupType Automatic"} +RUN foreach ("$service" in 'nlasvc', 'netprofm') {"Set-Service $service -StartupType Automatic"} # Not needed with the dotnet base image # RUN powershell -Command Set-Service 'wmiApSrv' -StartupType Automatic -# Packages/manifest.json could have git dependencies -RUN choco install git --no-progress -y +ADD scripts ./scripts + +ARG module +RUN if ("$Env:module" -eq 'Android') { .\scripts\SetupAndroid.ps1 } + +# Accept Android Licenses. Needs to be separate from the above script to +# ensure the environment variables are set. +RUN if ("$Env:module" -eq 'Android') { .\scripts\AcceptAndroidLicenses.ps1 } + +RUN Remove-Item .\scripts -Recurse -Force diff --git a/images/windows/editor/scripts/AcceptAndroidLicenses.ps1 b/images/windows/editor/scripts/AcceptAndroidLicenses.ps1 new file mode 100644 index 00000000..4406373b --- /dev/null +++ b/images/windows/editor/scripts/AcceptAndroidLicenses.ps1 @@ -0,0 +1,8 @@ +$ErrorActionPreference = "Stop" + +. scripts/HelperFunctions.ps1 + +# Accept Android Licenses +Set-Location "$Env:ANDROID_CMDLINE_TOOLS/bin" +bash -c "yes | ./sdkmanager.bat --licenses" +CheckLastExitCode diff --git a/images/windows/editor/scripts/HelperFunctions.ps1 b/images/windows/editor/scripts/HelperFunctions.ps1 new file mode 100644 index 00000000..eee111df --- /dev/null +++ b/images/windows/editor/scripts/HelperFunctions.ps1 @@ -0,0 +1,57 @@ +######################## +# General Helpers # +######################## + +function CheckLastExitCode { + param ([int[]]$SuccessCodes = @(0), [scriptblock]$CleanupScript=$null) + + if ($SuccessCodes -notcontains $LastExitCode) { + if ($CleanupScript) { + "Executing cleanup script: $CleanupScript" + &$CleanupScript + } + $msg = @" +EXE RETURNED EXIT CODE $LastExitCode +CALLSTACK:$(Get-PSCallStack | Out-String) +"@ + throw $msg + } +} + +######################## +# Unity Module Helpers # +######################## + +function Get-ModuleDestinationPath { + + param ( + $ModuleList, + $ModuleID, + $UnityPath + ) + $index=$ModuleList.FindIndex( {$args[0].id.contains($ModuleID)} ) + $rawPath=$ModuleList[$index].destination + return $rawPath.Replace('{UNITY_PATH}', $UnityPath) +} + +function Get-ModuleRenamedPath { + +param ( + $ModuleList, + $ModuleID, + $UnityPath +) +$index=$ModuleList.FindIndex( {$args[0].id.contains($ModuleID)} ) +$rawPath=$ModuleList[$index].extractedPathRename.to +return $rawPath.Replace('{UNITY_PATH}', $UnityPath) +} + +function Find-Module { + + param ( + $ModuleList, + $ModuleID + ) + $index=$ModuleList.FindIndex( {$args[0].id.contains($ModuleID)} ) + return $index -ne -1 +} diff --git a/images/windows/editor/scripts/SetupAndroid.ps1 b/images/windows/editor/scripts/SetupAndroid.ps1 new file mode 100644 index 00000000..2396b98f --- /dev/null +++ b/images/windows/editor/scripts/SetupAndroid.ps1 @@ -0,0 +1,36 @@ +$ErrorActionPreference = "Stop" + +. scripts/HelperFunctions.ps1 + +# Read the modules.json file for the editor to figure out the proper paths dynamically +[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") +$raw_modules = Get-Content "$Env:UNITY_PATH/modules.json" +$UNITY_MODULES_JSON = (New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer -Property @{MaxJsonLength=67108864}).DeserializeObject($raw_modules) +$UNITY_MODULES_LIST = [Collections.Generic.List[Object]]($UNITY_MODULES_JSON) + +# Find our environment variables +$ANDROID_SDK_ROOT = Get-ModuleDestinationPath $UNITY_MODULES_LIST 'android-sdk-platform-tools' $Env:UNITY_PATH +$ANDROID_NDK_HOME = Get-ModuleDestinationPath $UNITY_MODULES_LIST 'android-ndk' $Env:UNITY_PATH +$JAVA_HOME = Get-ModuleDestinationPath $UNITY_MODULES_LIST 'android-open-jdk' $Env:UNITY_PATH + +if (Find-Module $UNITY_MODULES_LIST 'android-sdk-command-line-tools') +{ + $TOOLS_PATH = Get-ModuleRenamedPath $UNITY_MODULES_LIST 'android-sdk-command-line-tools' $Env:UNITY_PATH +} +else +{ + $TOOLS_PATH = "$ANDROID_SDK_ROOT/tools" +} + +# Set our environment variables +$newPath = "$JAVA_HOME/bin;$ANDROID_SDK_ROOT/tools;$TOOLS_PATH/bin;$ANDROID_SDK_ROOT/platform-tools;$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin;C:/Program Files/Git/bin" +$oldPath = [Environment]::GetEnvironmentVariable('PATH', 'Machine'); + +[Environment]::SetEnvironmentVariable('PATH', "$newPath;$oldPath", 'Machine'); +[Environment]::SetEnvironmentVariable('ANDROID_HOME', "$ANDROID_SDK_ROOT", 'Machine'); +[Environment]::SetEnvironmentVariable('ANDROID_NDK_HOME', "$ANDROID_NDK_HOME", 'Machine'); +[Environment]::SetEnvironmentVariable('JAVA_HOME', "$JAVA_HOME", 'Machine'); +[Environment]::SetEnvironmentVariable('ANDROID_CMDLINE_TOOLS', "$TOOLS_PATH", 'Machine'); + +# Unity seems to always look for this file and can't find it so we manually create an empty one +New-Item -ItemType file -Path "$Env:USERPROFILE/.android/repositories.cfg" -Force