generated from RageAgainstThePixel/github-action-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
create-unity-project@v1.0.0 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d145d48
create-unity-project@v1.0.0
StephenHodgson d4cebc7
fix readme
StephenHodgson 2368306
update readme
StephenHodgson 248adbe
readme
StephenHodgson e84ef94
use github action path
StephenHodgson 7958349
use workspace as default
StephenHodgson 88e879b
format
StephenHodgson afeef02
readme
StephenHodgson ad6ca4f
readme links
StephenHodgson b4a6ad9
readme
StephenHodgson 7feada3
readme
StephenHodgson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,47 @@ | ||
| # github-action-template | ||
| # create-unity-project | ||
|
|
||
| A GitHub Actions template repository for TypeScript based Actions. | ||
| A GitHub Action to create a new Unity Project using a predefined template package. | ||
|
|
||
| ## How to use | ||
|
|
||
| ### Requirements | ||
|
|
||
| > [!IMPORTANT] | ||
| > This action requires that the Unity Editor is installed on the runner. | ||
| > | ||
| > You can use [`unity-setup`](https://github.com/RageAgainstThePixel/unity-setup) action to install Unity Editor before using this action. | ||
|
|
||
| - `UNITY_EDITOR_PATH` environment variable must be set to the path of the Unity Editor executable. | ||
|
|
||
| > [!IMPORTANT] | ||
| > This action requires an active Unity license be available on the runner. | ||
| > | ||
| > You can use [`activate-unity-license`](https://github.com/RageAgainstThePixel/activate-unity-license) action to activate the Unity license before using this action. | ||
|
|
||
| - A license activation for the Unity Editor must also be completed before using this action. | ||
|
|
||
| ### workflow | ||
|
|
||
| ```yaml | ||
| steps: | ||
| - uses: RageAgainstThePixel/github-action-template@v1 | ||
| - uses: RageAgainstThePixel/create-unity-project@v1 | ||
| with: | ||
| project-name: Test Project | ||
| project-directory: ./Unity Project | ||
| template-name: com.unity.template.3d(-cross-platform)? | ||
| ``` | ||
|
|
||
| ### inputs | ||
|
|
||
| | name | description | required | | ||
| | ---- | ----------- | -------- | | ||
| | .... | ........... | ........ | | ||
| | `project-name` | The name of the Unity project to create. | true | | ||
| | `project-directory` | The directory where the Unity project will be created. | Defaults to the root of the workspace. | | ||
| | `template-name` | The name of the template package to use for creating the Unity project. | Default: `com.unity.template.3d(-cross-platform)?` | | ||
|
|
||
| > [!NOTE] | ||
| > `template-name` supports regex patterns, allowing you to match multiple template packages. For example, `com.unity.template.3d(-cross-platform)?` will match both `com.unity.template.3d` and `com.unity.template.3d-cross-platform`. | ||
|
|
||
| ### outputs | ||
|
|
||
| - `project-path`: The path to the created Unity project. This is the absolute path to the project directory. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,33 @@ | ||
| name: github-action-template | ||
| description: 'A GitHub Actions template repository for TypeScript based Actions' | ||
| # inputs: | ||
| # outputs: | ||
| name: create-unity-project | ||
| branding: | ||
| icon: cloud-lightning | ||
| color: blue | ||
| description: A GitHub Action to create a new Unity Project using a predefined template package. | ||
| inputs: | ||
| project-name: | ||
| description: The name of the Unity project to create. | ||
| required: true | ||
| project-directory: | ||
| description: The directory where the Unity project will be created. Defaults to the root of the workspace. | ||
| required: false | ||
| default: '${{ github.workspace }}' | ||
| template-name: | ||
| description: The name of the template package to use for creating the Unity project. | ||
| required: false | ||
| default: 'com.unity.template.3d(-cross-platform)?' | ||
| outputs: | ||
| project-path: | ||
| description: The path to the created Unity project. | ||
| value: '${{ inputs.project-directory }}/${{ inputs.project-name }}' | ||
| runs: | ||
| using: 'node20' | ||
| main: 'dist/index.js' | ||
| #post: 'dist/index.js' | ||
| using: composite | ||
| steps: | ||
| - name: Get Unity Template | ||
| id: template | ||
| shell: bash | ||
| run: ${{ github.action_path }}/get-unity-template.sh "${{ inputs.template-name }}" | ||
| - uses: RageAgainstThePixel/unity-action@v2 | ||
| name: Create Unity Project | ||
| with: | ||
| log-name: create-unity-project | ||
| args: '-quit -nographics -batchmode -createProject "${{ inputs.project-directory }}/${{ inputs.project-name }}" -cloneFromTemplate "${{ steps.template.outputs.template-path }}"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/bin/bash | ||
| # This script is used to fetch the Unity template from the editor path in env variables. | ||
| set -e | ||
|
|
||
| if [ -z "$UNITY_EDITOR_PATH" ]; then | ||
| echo "UNITY_EDITOR_PATH is not set. Please set it to the path of your Unity editor." | ||
| exit 1 | ||
| fi | ||
|
|
||
| PACKAGE="$1" | ||
|
|
||
| if [ -z "$PACKAGE" ]; then | ||
| echo "Usage: $0 <package-name-or-regex>" | ||
| echo "Example: $0 'com.unity.template.3d'" | ||
| echo " $0 'com.unity.template.3d-cross-platform'" | ||
| echo " $0 'com.unity.template.3d*' (regex supported)" | ||
| echo " $0 'com.unity.template.3d(-cross-platform)?' (regex supported)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| EDITOR_ROOT=$(dirname "${UNITY_EDITOR_PATH}") | ||
| EDITOR_ROOT=${EDITOR_ROOT//\\//\/} | ||
| TEMPLATE_DIR="${EDITOR_ROOT}/Data/Resources/PackageManager/ProjectTemplates" | ||
| OS_NAME=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
|
|
||
| if [[ "${OS_NAME}" == "darwin" ]]; then | ||
| TEMPLATE_DIR=$(dirname "${EDITOR_ROOT}")/Resources/PackageManager/ProjectTemplates | ||
| fi | ||
|
|
||
| if [ ! -d "${TEMPLATE_DIR}" ]; then | ||
| echo "Template directory not found: ${TEMPLATE_DIR}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| PACKAGES=$(find "${TEMPLATE_DIR}" -name "*.tgz" 2>/dev/null) | ||
|
|
||
| if [ -z "${PACKAGES}" ]; then | ||
| echo "No templates found in ${TEMPLATE_DIR}" | ||
| else | ||
| echo "Available templates:" | ||
| echo "${PACKAGES}" | while IFS= read -r pkg; do | ||
| echo " - $(basename \""${pkg}"\")" | ||
| done | ||
| fi | ||
|
|
||
| MATCHES=$(find "${TEMPLATE_DIR}" -name "*.tgz" 2>/dev/null | grep -E "${PACKAGE}.*[0-9]+\.[0-9]+\.[0-9]+\.tgz") | ||
StephenHodgson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| TEMPLATE_PATH=$(echo "${MATCHES}" | awk '{ print length, $0 }' | sort -nr | cut -d" " -f2- | head -n 1) | ||
|
|
||
| if [ -z "${TEMPLATE_PATH}" ]; then | ||
| echo "${PACKAGE} path not found in ${TEMPLATE_DIR}!" | ||
| exit 1 | ||
| fi | ||
|
|
||
| TEMPLATE_PATH=${TEMPLATE_PATH//\\//\/} | ||
|
|
||
| echo "TEMPLATE_PATH=${TEMPLATE_PATH}" | ||
| echo "template-path=${TEMPLATE_PATH}" >> "${GITHUB_OUTPUT}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.