Install Unity Package Manager CLI
Set up the command-line interface and configure your environment with the required credentials.
阅读时间5 分钟最后更新于 1 个月前
Set up the Unity Package Manager command-line interface (UPM CLI) so you can pack and sign Unity Package Manager (UPM) packages you create. You can use the UPM CLI from the command line or as part of a continuous integration (CI) environment.
UPM CLI supports the same platforms and architectures as the Unity Editor.
Before you can use UPM CLI to pack and sign UPM packages, you need to install UPM CLI and configure your environment with the required credentials. You need to install UPM CLI only once, and then update it each time a newer version of UPM CLI is available. The following sections describe the prerequisites, the installation process, and how to verify your installation.
The install script runs locally. It doesn't send private data to Unity.
For background information about UPM CLI, refer to Unity Package Manager CLI workflow.
Prerequisites
Before you install and use UPM CLI, complete the following steps.
-
Create a service account:
- Follow the instructions at Create a service account.
- When you add access to the service account at the organization level, select Manage organization roles, go to the Package Manager field, and select Package Manager Package Signer. Select Save.
-
Store service account credentials:
-
Set the following environment variables (if running the script locally) or in the secrets settings of your CI tool (if running the script in an automated environment):
- : The key ID that you generated when you created the service account.
UPM_SERVICE_ACCOUNT_KEY_ID - : The secret key that you generated when you created the service account.
UPM_SERVICE_ACCOUNT_KEY_SECRET
-
-
Copy your organization ID. For details, refer to Identify the organization ID.
- The pack command requires this value as part of the signing process.
Check if UPM CLI is already installed
To check if UPM CLI is already installed:
-
Open a terminal window (macOS or Linux) or a PowerShell window (Windows).
-
Run one of the following commands:upm --versionupm -v
-
Check the results:
- If the command returns an error such as or
command not found, UPM CLI isn't installed. Proceed to Install UPM CLI.'upm' is not recognized - If the command returns a version number, compare it against the latest version listed at https://cdn.packages.unity.com/upm-cli/latest.txt. If your version is out of date, proceed to Install UPM CLI to update. Otherwise, go to Pack and sign a UPM package with Unity Package Manager CLI.
- If the command returns an error such as
Install UPM CLI
You can install or update to the latest version of UPM CLI with one command, or you can run multiple commands if you want to inspect the script.
Both methods install UPM CLI and add it to the environment variable, so you can run commands from any directory.
PATHupmInstall with one command
To download and install the latest version of UPM CLI without inspecting the script, run the command that matches your operating system:
-
macOS or Linux:curl -fsSL https://cdn.packages.unity.com/upm-cli/install.sh | bash
-
Windows (PowerShell):irm https://cdn.packages.unity.com/upm-cli/install.ps1 | iex
When the install command completes, make sure you restart your terminal session for the changes to take effect.
Install with multiple commands
To install or update to the latest version of UPM CLI with the option to inspect the script:
-
Open a terminal window (macOS or Linux) or a PowerShell window (Windows).
-
Download the install script for the latest version of UPM CLI:
-
macOS or Linux:curl -fsSL https://cdn.packages.unity.com/upm-cli/install.sh -o install.sh
-
Windows (PowerShell):Invoke-WebRequest https://cdn.packages.unity.com/upm-cli/install.ps1 -OutFile install.ps1
-
-
(Optional) Inspect the install script before you run it:
-
macOS or Linux:less install.shTypeto return to the terminal prompt.
q -
Windows (PowerShell):Get-Content install.ps1 | moreTypeto return to the PowerShell prompt.
q
-
-
Run the install script:
-
macOS or Linux:bash install.sh
-
Windows (PowerShell):. .\install.ps1Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass.\install.ps1
-
When the install script completes, make sure you restart your terminal session for the changes to take effect.
Restart your terminal session
Restart your Terminal or PowerShell session for the changes to take effect.
On macOS or Linux, you can also run a shell-specific command within the current session:
- Zsh shell:
source ~/.zshrc - Bash shell:
source ~/.bashrc
Next steps
With UPM CLI installed, you're ready to pack and sign a UPM package with UPM CLI.