Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ This action requires several secrets that need to be setup in the repository or

| name | description | required |
| ---- | ----------- | -------- |
| `license` | Must be one of `Personal`, `Professional`, or `Floating` | Defaults to `Personal` |
| `username` | The email address you use for your Unity Id | Required for `Personal` and `Professional` license activations |
| `password` | The password you use for Unity Id access | Required for `Personal` and `Professional` license activations |
| `serial` | The Serial number for the seat | Required for `Professional` license activations |
| `configuration` | Unity License Client `services-config.json` encoded as base64 string | Required for `Floating` license activations |
| `license` | Must be one of `personal`, `professional`, `floating`, or `industry`. | Defaults to `personal` |
| `username` | The email address you use for your Unity Id | Required for `personal`, `professional`, and `industry` license activations |
| `password` | The password you use for Unity Id access | Required for `personal`, `professional`, and `industry` license activations |
| `serial` | The Serial number for the seat | Required for `professional` license activations, but not named seats. |
| `configuration` | Unity License Client `services-config.json` encoded as base64 string | Required for `floating` license activations |

### workflow

```yaml
steps:
- uses: buildalon/activate-unity-license@v1
with:
license: 'Personal' # Choose license type to use [ Personal, Professional, Floating ]
license: personal # Choose license type to use [ personal, professional, floating, industry ]
username: ${{ secrets.UNITY_USERNAME }}
password: ${{ secrets.UNITY_PASSWORD }}
# serial: ${{ secrets.UNITY_SERIAL }} # Required for pro activations
Expand Down
10 changes: 5 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ branding:
icon: 'log-in'
inputs:
license:
description: 'Must be one of `Personal`, `Professional`, `Floating`.'
description: 'Must be one of `personal`, `professional`, `floating`, or `industry`.'
required: false
default: 'Personal'
default: 'personal'
username:
description: 'The email address you use for your Unity Id. Required for `Personal` and `Professional` license activations.'
description: 'The email address you use for your Unity Id. Required for `personal`, `professional`, and `industry` license activations.'
required: false
default: ''
password:
description: 'The password you use for Unity Id access. Required for `Personal` and `Professional` license activations.'
description: 'The password you use for Unity Id access. Required for `personal`, `professional`, and `industry` license activations.'
required: false
default: ''
serial:
description: 'The Serial number for the seat. Required for Professional license activations.'
required: false
default: ''
configuration:
description: 'Unity License Client `services-config.json` encoded base base64 string. Required for `Floating` license activations.'
description: 'Unity License Client `services-config.json` encoded base base64 string. Required for `floating` license activations.'
required: false
default: ''
runs:
Expand Down
72 changes: 50 additions & 22 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28097,37 +28097,40 @@ exports.Activate = Activate;
const core = __nccwpck_require__(2186);
const process_1 = __nccwpck_require__(7282);
const licensing_client_1 = __nccwpck_require__(8447);
const types_1 = __nccwpck_require__(5077);
async function Activate() {
let license = undefined;
try {
core.saveState('isPost', true);
await (0, licensing_client_1.Version)();
let activeLicenses = await (0, licensing_client_1.ShowEntitlements)();
license = core.getInput('license', { required: true });
switch (license.toLowerCase()) {
case 'professional':
case 'personal':
case 'floating':
const licenseInput = core.getInput('license', { required: true });
license = licenseInput.toLowerCase();
switch (license) {
case types_1.LicenseType.professional:
case types_1.LicenseType.personal:
case types_1.LicenseType.floating:
case types_1.LicenseType.industry:
break;
default:
throw Error(`Invalid License: ${license}! Must be Professional, Personal, or Floating.`);
throw Error(`Invalid License: ${license}! Must be one of: ${Object.values(types_1.LicenseType).join(', ')}`);
}
core.saveState('license', license);
if (activeLicenses.includes(license.toLocaleLowerCase())) {
if (activeLicenses.includes(license)) {
core.warning(`Unity ${license} License already activated!`);
return;
}
core.startGroup('Attempting to activate Unity License...');
try {
if (license.toLowerCase().startsWith('f')) {
if (license === types_1.LicenseType.floating) {
const servicesConfig = core.getInput('services-config', { required: true });
await (0, licensing_client_1.ActivateLicenseWithConfig)(servicesConfig);
}
else {
const isPro = license.toLowerCase().startsWith('pro');
const isPro = license === types_1.LicenseType.professional;
let username = core.getInput('username', { required: isPro }).trim();
let password = core.getInput('password', { required: isPro }).trim();
const serial = core.getInput('serial', { required: isPro });
const serial = core.getInput('serial');
if (!username) {
const encodedUsername = process_1.env['UNITY_USERNAME_BASE64'];
if (!encodedUsername) {
Expand All @@ -28142,10 +28145,10 @@ async function Activate() {
}
password = Buffer.from(encodedPassword, 'base64').toString('utf-8');
}
await (0, licensing_client_1.ActivateLicense)(username, password, serial);
await (0, licensing_client_1.ActivateLicense)(license, username, password, serial);
}
activeLicenses = await (0, licensing_client_1.ShowEntitlements)();
if (!activeLicenses.includes(license.toLowerCase())) {
if (!activeLicenses.includes(license)) {
throw Error(`Failed to activate Unity License with ${license}!`);
}
}
Expand Down Expand Up @@ -28186,7 +28189,7 @@ async function Deactivate() {
try {
const activeLicenses = await licensingClient.ShowEntitlements();
if (license !== undefined &&
!activeLicenses.includes(license.toLowerCase())) {
!activeLicenses.includes(license)) {
throw Error(`Unity ${license} License is not activated!`);
}
else {
Expand All @@ -28199,8 +28202,8 @@ async function Deactivate() {
core.info(`Unity ${license} License successfully returned.`);
}
catch (error) {
core.setFailed(`Failed to deactivate license!\n${error}`);
process.exit(1);
core.error(`Failed to deactivate license!\n${error}`);
process.exit(0);
}
}

Expand All @@ -28223,6 +28226,7 @@ const core = __nccwpck_require__(2186);
const exec = __nccwpck_require__(1514);
const path = __nccwpck_require__(1017);
const fs = __nccwpck_require__(7147);
const types_1 = __nccwpck_require__(5077);
let client = undefined;
async function getLicensingClient() {
core.debug('Getting Licensing Client...');
Expand Down Expand Up @@ -28358,29 +28362,35 @@ async function ShowEntitlements() {
if (match.groups.license) {
switch (match.groups.license) {
case 'Unity Pro':
if (!licenses.includes('professional')) {
licenses.push('professional');
if (!licenses.includes(types_1.LicenseType.professional)) {
licenses.push(types_1.LicenseType.professional);
}
break;
case 'Unity Personal':
if (!licenses.includes('personal')) {
licenses.push('personal');
if (!licenses.includes(types_1.LicenseType.personal)) {
licenses.push(types_1.LicenseType.personal);
}
break;
}
}
}
return licenses;
}
async function ActivateLicense(username, password, serial) {
const args = [`--activate-ulf`, `--username`, username, `--password`, password];
async function ActivateLicense(license, username, password, serial) {
const args = [`--activate-ulf`];
if (serial !== undefined && serial.length > 0) {
serial = serial.trim();
args.push(`--serial`, serial);
const maskedSerial = serial.slice(0, -4) + `XXXX`;
core.setSecret(maskedSerial);
}
else {
if (license !== types_1.LicenseType.personal) {
args.push(`--serial`);
}
}
args.push(`--username`, username, `--password`, password);
if (license === types_1.LicenseType.personal) {
args.push(`--include-personal`);
}
await execWithMask(args);
Expand All @@ -28394,12 +28404,30 @@ async function ReturnLicense(license) {
await execWithMask([`--return-ulf`]);
const activeLicenses = await ShowEntitlements();
if (license !== undefined &&
activeLicenses.includes(license.toLowerCase())) {
activeLicenses.includes(license)) {
throw Error(`${license} was not returned.`);
}
}


/***/ }),

/***/ 5077:
/***/ ((__unused_webpack_module, exports) => {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LicenseType = void 0;
var LicenseType;
(function (LicenseType) {
LicenseType["personal"] = "personal";
LicenseType["professional"] = "professional";
LicenseType["floating"] = "floating";
LicenseType["industry"] = "industry";
})(LicenseType || (exports.LicenseType = LicenseType = {}));


/***/ }),

/***/ 5418:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "activate-unity-license",
"version": "1.0.9",
"version": "1.1.0",
"description": "A GitHub Action to activate a Unity Game Engine license for CI/CD workflows.",
"author": "buildalon",
"license": "MIT",
Expand All @@ -26,10 +26,10 @@
"@actions/glob": "^0.4.0"
},
"devDependencies": {
"@types/node": "^22.15.32",
"@types/node": "^22.17.0",
"@vercel/ncc": "^0.34.0",
"shx": "^0.3.4",
"typescript": "^5.8.3"
"typescript": "^5.9.2"
},
"scripts": {
"build": "npm run clean && npm run bundle",
Expand Down
29 changes: 16 additions & 13 deletions src/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,40 @@ import {
ShowEntitlements,
Version,
} from './licensing-client';
import { LicenseType } from './types';

export async function Activate(): Promise<void> {
let license = undefined;
let license: LicenseType | undefined = undefined;
try {
core.saveState('isPost', true);
await Version();
let activeLicenses = await ShowEntitlements();
license = core.getInput('license', { required: true });
switch (license.toLowerCase()) {
case 'professional':
case 'personal':
case 'floating':
const licenseInput = core.getInput('license', { required: true });
license = licenseInput.toLowerCase() as LicenseType;
switch (license) {
case LicenseType.professional:
case LicenseType.personal:
case LicenseType.floating:
case LicenseType.industry:
break;
default:
throw Error(`Invalid License: ${license}! Must be Professional, Personal, or Floating.`);
throw Error(`Invalid License: ${license}! Must be one of: ${Object.values(LicenseType).join(', ')}`);
}
core.saveState('license', license);
if (activeLicenses.includes(license.toLocaleLowerCase())) {
if (activeLicenses.includes(license)) {
core.warning(`Unity ${license} License already activated!`);
return;
}
core.startGroup('Attempting to activate Unity License...');
try {
if (license.toLowerCase().startsWith('f')) {
if (license === LicenseType.floating) {
const servicesConfig = core.getInput('services-config', { required: true });
await ActivateLicenseWithConfig(servicesConfig);
} else {
const isPro = license.toLowerCase().startsWith('pro');
const isPro = license === LicenseType.professional;
let username = core.getInput('username', { required: isPro }).trim();
let password = core.getInput('password', { required: isPro }).trim();
const serial = core.getInput('serial', { required: isPro });
const serial = core.getInput('serial');
if (!username) {
const encodedUsername = env['UNITY_USERNAME_BASE64'];
if (!encodedUsername) {
Expand All @@ -53,10 +56,10 @@ export async function Activate(): Promise<void> {

password = Buffer.from(encodedPassword, 'base64').toString('utf-8');
}
await ActivateLicense(username, password, serial);
await ActivateLicense(license, username, password, serial);
}
activeLicenses = await ShowEntitlements();
if (!activeLicenses.includes(license.toLowerCase())) {
if (!activeLicenses.includes(license)) {
throw Error(`Failed to activate Unity License with ${license}!`);
}
} finally {
Expand Down
9 changes: 5 additions & 4 deletions src/deactivate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import licensingClient = require('./licensing-client');
import core = require('@actions/core');
import { LicenseType } from './types';

export async function Deactivate(): Promise<void> {
try {
const license = core.getState('license');
const license: LicenseType | undefined = core.getState('license') as LicenseType | undefined;
if (!license) {
throw Error(`Failed to get post license state!`);
}
Expand All @@ -15,7 +16,7 @@ export async function Deactivate(): Promise<void> {
try {
const activeLicenses = await licensingClient.ShowEntitlements();
if (license !== undefined &&
!activeLicenses.includes(license.toLowerCase())) {
!activeLicenses.includes(license)) {
throw Error(`Unity ${license} License is not activated!`);
} else {
await licensingClient.ReturnLicense(license);
Expand All @@ -26,7 +27,7 @@ export async function Deactivate(): Promise<void> {
}
core.info(`Unity ${license} License successfully returned.`);
} catch (error) {
core.setFailed(`Failed to deactivate license!\n${error}`);
process.exit(1);
core.error(`Failed to deactivate license!\n${error}`);
process.exit(0);
}
}
Loading
Loading