Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build-options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"os": [
"macos-latest"
],
"unity-version": [
"2021.x",
"2022.x",
"6000.0.x",
"6000.1.x",
"6000.2.x"
],
"build-target": [
"StandaloneOSX",
"iOS",
"VisionOS"
],
"xcode-version": [
"16.3",
""
],
"exclude": [
{
"unity-version": "2021.x",
"build-target": "VisionOS"
},
{
"unity-version": "2022.x",
"build-target": "VisionOS"
}
]
}
186 changes: 186 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: build
permissions:
contents: read
on:
workflow_call:
inputs:
matrix:
required: true
type: string
secrets:
UNITY_USERNAME:
required: true
UNITY_PASSWORD:
required: true
jobs:
build:
name: ${{ matrix.name }}
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
fail-fast: false
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
VERSION: ''
EXPORT_OPTION: ''
BUILD_DIRECTORY: ''
UNITY_PROJECT_PATH: ${{ github.workspace }}/UnityProject
steps:
- uses: actions/checkout@v4
- run: 'npm install -g openupm-cli'
- uses: RageAgainstThePixel/unity-setup@v1
with:
version-file: 'None'
build-targets: ${{ matrix.build-target }}
unity-version: ${{ matrix.unity-version }}
- name: Set Build Args
shell: bash
run: |
set -e
# Read version from package.json instead of git tags
package_json_path="${{ github.workspace }}/package.json"
version=$(jq -r .version "$package_json_path")

if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version from package.json: $version"
else
echo "Version: $version is not a valid version string"
exit 1
fi
echo "VERSION=$version" >> "$GITHUB_ENV"

# Only set export option to app-store-connect if unity-version is 6000.2.x AND xcode-version is 16.4
if [[ "${{ matrix.unity-version }}" == "6000.2.x" && "${{ matrix.xcode-version }}" == "16.2" ]]; then
echo "EXPORT_OPTION=app-store-connect" >> "$GITHUB_ENV"
else
if [[ "${{ matrix.build-target }}" == "StandaloneOSX" ]]; then
if [[ "${{ matrix.unity-version }}" == "2022.x" ]]; then
echo "EXPORT_OPTION=steam" >> "$GITHUB_ENV"
else
echo "EXPORT_OPTION=developer-id" >> "$GITHUB_ENV"
fi
else
echo "EXPORT_OPTION=development" >> "$GITHUB_ENV"
fi
fi

# set BUILD_DIRECTORY to a path in the root of the workspace named ./Builds/<build-target>/
build_directory="${{ github.workspace }}/Builds/${{ matrix.build-target }}"
echo "Creating build directory at $build_directory"
mkdir -p "$build_directory"
echo "BUILD_DIRECTORY=$build_directory" >> "$GITHUB_ENV"
- uses: RageAgainstThePixel/activate-unity-license@v1
with:
license: 'Personal'
username: ${{ secrets.UNITY_USERNAME }}
password: ${{ secrets.UNITY_PASSWORD }}
- uses: RageAgainstThePixel/create-unity-project@v1
name: Create Test Project
with:
project-name: UnityProject
template-name: com.unity.template.3d(-cross-platform)?
- run: openupm add com.utilities.buildpipeline
name: Add Build Pipeline Package
working-directory: ${{ env.UNITY_PROJECT_PATH }}
- uses: RageAgainstThePixel/unity-action@v2
name: '${{ matrix.build-target }}-Validate'
with:
build-target: ${{ matrix.build-target }}
log-name: '${{ matrix.build-target }}-Validate'
args: '-quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
- uses: RageAgainstThePixel/unity-action@v2
name: '${{ matrix.build-target }}-Build'
with:
build-target: ${{ matrix.build-target }}
log-name: '${{ matrix.build-target }}-Build'
args: '-quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity -export -enableAppleAutomaticSigning -bundleIdentifier com.rageagainstthepixel.xcode -versionName ${{ env.VERSION }} -buildOutputDirectory ${{ env.BUILD_DIRECTORY }}'
- name: Update Info.Plist with encryption compliance
shell: bash
run: |
set -e
BUILD_DIRECTORY="${{ env.BUILD_DIRECTORY }}"

if [ -z "$BUILD_DIRECTORY" ]; then
echo "env.BUILD_DIRECTORY is not set!"
exit 1
fi

# recursively list build output files
echo "::group::Build Output Directory: ${BUILD_DIRECTORY}/com.rageagainstthepixel.xcode"
ls -alR "${BUILD_DIRECTORY}/com.rageagainstthepixel.xcode"
echo "::endgroup::"

# find the Info.plist file in the build directory
# MacOSStandalone Info.plist path: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/StandaloneOSX/com.rageagainstthepixel.xcode/UnityProject/UnityProject/Info.plist
# all others: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/iOS/com.rageagainstthepixel.xcode/Info.plist
EXPORT_OPTION="${{ env.EXPORT_OPTION }}"

if [ "$EXPORT_OPTION" != "app-store-connect" ]; then
exit 0
fi

TARGET_PLATFORM="${{ matrix.build-target }}"

INFO_PLIST_PATH="${BUILD_DIRECTORY}/com.rageagainstthepixel.xcode/UnityProject/UnityProject/Info.plist"

if [ ! -f "$INFO_PLIST_PATH" ]; then
INFO_PLIST_PATH="${BUILD_DIRECTORY}/com.rageagainstthepixel.xcode/Info.plist"
fi

# test path exists
if [ ! -f "$INFO_PLIST_PATH" ]; then
echo "Info.plist not found at path: $INFO_PLIST_PATH"
exit 1
fi

# make sure plist buddy is installed
if ! command -v /usr/libexec/PlistBuddy &> /dev/null
then
echo "PlistBuddy could not be found"
# list build output files recursively
ls -alR "${BUILD_DIRECTORY}/com.rageagainstthepixel.xcode"
exit 1
fi

# set ITSAppUsesNonExemptEncryption to false in Info.plist using PlistBuddy
/usr/libexec/PlistBuddy -c "Add :ITSAppUsesNonExemptEncryption bool false" "$INFO_PLIST_PATH"
- uses: ./ # RageAgainstThePixel/unity-xcode-builder
id: xcode-build
with:
xcode-version: ${{ matrix.xcode-version }}
project-path: ${{ env.BUILD_DIRECTORY }}/**/*.xcodeproj
app-store-connect-key: ${{ secrets.APP_STORE_CONNECT_KEY }}
app-store-connect-key-id: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
app-store-connect-issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
team-id: ${{ secrets.APPLE_TEAM_ID }}
export-option: ${{ env.EXPORT_OPTION }}
notarize: ${{ env.EXPORT_OPTION != 'app-store-connect' }}
archive-type: pkg
test-groups: Beta
developer-id-application-certificate: ${{ secrets.DEVELOPER_ID_APPLICATION_CERT }}
developer-id-application-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
developer-id-installer-certificate: ${{ secrets.DEVELOPER_ID_INSTALLER_CERT }}
developer-id-installer-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
- name: print outputs
run: |
set -e

EXECUTABLE="${{ steps.xcode-build.outputs.executable }}"

if [ -z "${EXECUTABLE}" ]; then
echo "No executable found in outputs"
exit 1
fi

echo "Executable: ${EXECUTABLE}"
OUTPUT_DIRECTORY="${{ steps.xcode-build.outputs.output-directory }}"

if [ -z "${OUTPUT_DIRECTORY}" ]; then
echo "No output directory found in outputs"
exit 1
fi

echo "::group::Output Directory: ${OUTPUT_DIRECTORY}"
ls -R "${OUTPUT_DIRECTORY}"
echo "::endgroup::"
163 changes: 25 additions & 138 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,153 +3,40 @@ on:
push:
branches: ['main']
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches: ['*']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unity-build:
setup:
if: github.event.pull_request.draft == false
name: '(${{ matrix.unity-version }}) ${{ matrix.build-target }}'
runs-on: ubuntu-latest
permissions:
contents: read
env:
VERSION: ''
TEMPLATE_PATH: ''
EXPORT_OPTION: ''
UNITY_PROJECT_PATH: ''
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
unity-version: [2021.x, 2022.x, 6000.x]
build-target: [iOS, StandaloneOSX, VisionOS]
exclude:
- os: macos-latest
unity-version: 2021.x
build-target: VisionOS
- os: macos-latest
unity-version: 2022.x
build-target: VisionOS
steps:
- uses: actions/checkout@v4
- run: 'npm install -g openupm-cli'
- uses: RageAgainstThePixel/unity-setup@v1
with:
version-file: 'None'
build-targets: ${{ matrix.build-target }}
unity-version: ${{ matrix.unity-version }}
- name: Find Unity Template Path and Version
run: |
$rootPath = $env:UNITY_EDITOR_PATH -replace "Editor.*", ""
Write-Host "ROOT_PATH=$rootPath"
$templatePath = Get-ChildItem -Recurse -Filter "com.unity.template.3d*.tgz" -Path $rootPath | Select-Object -First 1 | Select-Object -ExpandProperty FullName
Write-Host "TEMPLATE_PATH=$templatePath"
echo "TEMPLATE_PATH=$templatePath" >> $env:GITHUB_ENV
$projectPath = "${{ github.workspace }}/UnityProject"
echo "UNITY_PROJECT_PATH=$projectPath" >> $env:GITHUB_ENV

# Read version from package.json instead of git tags
$packageJsonPath = "${{ github.workspace }}/package.json"
$packageJson = Get-Content -Raw -Path $packageJsonPath | ConvertFrom-Json
$version = $packageJson.version

if ($version -match '^\d+\.\d+\.\d+$') {
Write-Host "Version from package.json: $version"
} else {
Write-Host "Version: $version is not a valid version string"
exit 1
}
echo "VERSION=$version" >> $env:GITHUB_ENV

# if the unity-version is 6000.x then set export option to app-store-connect otherwise set it to development
if ('${{ matrix.unity-version }}' -eq '6000.x') {
echo "EXPORT_OPTION=app-store-connect" >> $env:GITHUB_ENV
} else {
if ('${{ matrix.build-target }}' -eq 'StandaloneOSX') {
if ('${{ matrix.unity-version }}' -eq '2022.x') {
echo "EXPORT_OPTION=steam" >> $env:GITHUB_ENV
} else {
echo "EXPORT_OPTION=developer-id" >> $env:GITHUB_ENV
}
} else {
echo "EXPORT_OPTION=development" >> $env:GITHUB_ENV
}
}
shell: pwsh
- uses: RageAgainstThePixel/activate-unity-license@v1
with:
license: 'Personal'
username: ${{ secrets.UNITY_USERNAME }}
password: ${{ secrets.UNITY_PASSWORD }}
- uses: RageAgainstThePixel/unity-action@v1
name: Create Test Project
with:
log-name: 'create-test-project'
args: '-quit -nographics -batchmode -createProject "${{ github.workspace }}/UnityProject" -cloneFromTemplate "${{ env.TEMPLATE_PATH }}"'
- run: openupm add com.utilities.buildpipeline
name: Add Build Pipeline Package
working-directory: ${{ github.workspace }}/UnityProject
- uses: RageAgainstThePixel/unity-action@v1
name: '${{ matrix.build-target }}-Validate'
sparse-checkout: .github/
- uses: RageAgainstThePixel/job-builder@v1
id: setup-jobs
with:
build-target: ${{ matrix.build-target }}
log-name: '${{ matrix.build-target }}-Validate'
args: '-quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
- uses: RageAgainstThePixel/unity-action@v1
name: '${{ matrix.build-target }}-Build'
with:
build-target: ${{ matrix.build-target }}
log-name: '${{ matrix.build-target }}-Build'
args: '-quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity -export -enableAppleAutomaticSigning -bundleIdentifier com.rageagainstthepixel.xcode -versionName ${{ env.VERSION }}'
- name: Update Info.Plist with encryption compliance
shell: bash
run: |
set -xe
# find the Info.plist file in the build directory
# MacOSStandalone Info.plist path: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/StandaloneOSX/com.test.buildalon.xcode/UnityProject/UnityProject/Info.plist
# all others: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/iOS/com.test.buildalon.xcode/Info.plist
EXPORT_OPTION=${{ env.EXPORT_OPTION }}
if [ "$EXPORT_OPTION" != "app-store-connect" ]; then
exit 0
fi
TARGET_PLATFORM=${{ matrix.build-target }}
if [ "$TARGET_PLATFORM" == "StandaloneOSX" ]; then
INFO_PLIST_PATH="${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/com.test.buildalon.xcode/UnityProject/UnityProject/Info.plist"
else
INFO_PLIST_PATH="${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/com.test.buildalon.xcode/Info.plist"
fi
# make sure plist buddy is installed
if ! command -v /usr/libexec/PlistBuddy &> /dev/null
then
echo "PlistBuddy could not be found"
exit 1
fi
# set ITSAppUsesNonExemptEncryption to false in Info.plist using PlistBuddy
/usr/libexec/PlistBuddy -c "Add :ITSAppUsesNonExemptEncryption bool false" "$INFO_PLIST_PATH"
- uses: ./ # RageAgainstThePixel/unity-xcode-builder
id: xcode-build
with:
project-path: ${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/**/*.xcodeproj
app-store-connect-key: ${{ secrets.APP_STORE_CONNECT_KEY }}
app-store-connect-key-id: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
app-store-connect-issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
team-id: ${{ secrets.APPLE_TEAM_ID }}
export-option: ${{ env.EXPORT_OPTION }}
notarize: ${{ matrix.unity-version != '6000.x' }}
archive-type: pkg
test-groups: Beta
developer-id-application-certificate: ${{ secrets.DEVELOPER_ID_APPLICATION_CERT }}
developer-id-application-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
developer-id-installer-certificate: ${{ secrets.DEVELOPER_ID_INSTALLER_CERT }}
developer-id-installer-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
- name: print outputs
if: always()
run: |
echo "Executable: ${{ steps.xcode-build.outputs.executable }}"
echo "Output Directory: ${{ steps.xcode-build.outputs.output-directory }}"
ls -R "${{ steps.xcode-build.outputs.output-directory }}"
build-options: ./.github/workflows/build-options.json
group-by: 'unity-version'
outputs:
jobs: ${{ steps.setup-jobs.outputs.jobs }}
validate:
if: ${{ needs.setup.outputs.jobs }}
needs: setup
name: build ${{ matrix.jobs.name }}
permissions:
contents: read
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.jobs) }}
fail-fast: false
max-parallel: 1
secrets: inherit
uses: ./.github/workflows/build.yml
with:
matrix: ${{ toJSON(matrix.jobs.matrix) }}
Loading
Loading