From cf0dac5b2a8616f4378a5af062d6640062f49457 Mon Sep 17 00:00:00 2001 From: Dino Fejzagic Date: Mon, 7 Apr 2025 20:14:13 +0200 Subject: [PATCH 01/23] Init new Unity Versioning Task --- .../UnityVersioningV1/CHANGELOG.md | 10 ++++++ .../UnityVersioningV1/README.md | 3 ++ .../UnityVersioningV1/icon.png | Bin 0 -> 2596 bytes .../UnityVersioningV1/package.json | 29 ++++++++++++++++ .../UnityVersioningV1/task.json | 32 ++++++++++++++++++ .../UnityVersioningV1/tsconfig.json | 9 +++++ .../UnityVersioningV1/unity-versioning.ts | 0 7 files changed, 83 insertions(+) create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/README.md create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/icon.png create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/package.json create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/task.json create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/tsconfig.json create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts diff --git a/Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md b/Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md new file mode 100644 index 0000000..fb12c29 --- /dev/null +++ b/Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0.0] + +Initial release \ No newline at end of file diff --git a/Tasks/UnityVersioning/UnityVersioningV1/README.md b/Tasks/UnityVersioning/UnityVersioningV1/README.md new file mode 100644 index 0000000..7146e75 --- /dev/null +++ b/Tasks/UnityVersioning/UnityVersioningV1/README.md @@ -0,0 +1,3 @@ +# About Unity Versioning V1 + +Please visit [https://unitydevops.com/docs/unity-versioning-task](https://unitydevops.com/docs/unity-versioning-task) for task documentation. \ No newline at end of file diff --git a/Tasks/UnityVersioning/UnityVersioningV1/icon.png b/Tasks/UnityVersioning/UnityVersioningV1/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..381641428e36fadbda042059eba6c1175d114e00 GIT binary patch literal 2596 zcmbVO3se->86JF#V3j~1n8IcNL!h%W`(PhqP;eLBwJhP)KoEknv$GG~-Pz0xPf3yD z2FdXeqKJZ)C;~?;C`Y6kBcjA(NsgFRniQ2yz3(@wAk|WDSS!o<0lnOuBG5DNKWDYzoR~ zQspvKLT*eVnY)3M>);j3d9P>VfWSg=1TWiSwz7D3I6TgagSB%Tg?Zx;ZbLX6=~T!| z*2MA@G(+(ud<-EmOvIDQ`2vYJOep;gPlyRIQ~>TUL?Fe*GF&9&O4Xaw+cd3}oeUEQ7@AGkPyruvx-<^dk<&O^24fyqt|L*(Oj#%^#{#Ti z8f!Ds9L*Z(XHZWc|4ac0twuAgPGES&PcI20572MVf2M{vad1nWp#Pcs$* z_-wKe1`4%V4KQyylDL94(+p4ytP?%CuU05x8Cq{Lg9A2x^-7*PN+A)*B@#r)7mS;$ z(co$;%Mn(RQY*t@5FftDq{HQUJtiac5=2IdBnTl8ixD{~(<3qosg+S8on9;fipG+*XkrvM55Kp!bAe8787Zwcf>EOw2(^Dewd>%~DW*I3!`U`b2 z0b^-BmqjpCqya?hc}fp`mi;V|`ODTnU;ch>{WDATxvUq0ih8nZCWJ^MVKq=-vZAol z8Pqw0Ch~&*cgn`ko|sota4-a&%jxM0KBnh4Wd+m>n9c!nJX0WOW|vwSnW!p0vzt(@ zH~3ui5Bf}28pECY_=Io4kvob=@2&Qw%u7|fBd=YsI*NRDe)OxtA3wsjuJQ34JnS{I z(Bn1ji*fP(gH5}5ht}1OPFl_OXfmy)t3Vn)HH z)JH#!CB0QpQBl#^KQcON=e29sHj6c6pvSq|l~s;Ko7%cs8yf`-ef;Zh^|Km|9?k#! zkGtP{Z%#)=VA0jyz;Em7LX^s;>wSl4o2|dBDdO}u4OCmo+O-0|9kupX;5F6pH#<8! zS1Ug~eq40rRZmyCa#lk_LuMlpQW_F!&dn_!UbbwRygYhoK#Hr4qN*$06GBRd`};pw z{GzK}7Ao{{W4J2Eu=tDhC;s(Saa&v4OOesHIs8LXQjx%w*T^IM;PY3mTsb{9HWpOl z8Rt3s%_Clc9`iT1bu|Sci{@>5`{-Nz+PNDUvY0$ z_dxdL2Dp7e_hF#owoTTuN_k^-Rb0r(VXSDymI$8eNOw<t)Q)kZ>oj<=a7)2j~0AFrDxVN(M z@xtT;o!GbXgs~|FY2UkduiEjAHS0$U(U?5vt1p_HoB!0h4*ScEq`4OaAU~lq}w(3Osi5{g3qF`bt7YZz{*uP&Pj7GU(#GWI)}H(RZ^Xp>Gc7Ic?3+nRg{!Ju z>?>WiZQB;RcI|?^<^F#D{*i$mCG~-xuIlQ0BYD3oEiLs%muvS#*Z6-;yFgh@UMNIR6s@K?Zt&Hm(pt86VBnoI7rz_%?7M*` z+5VWYM=$&CxR@}yruv@r7XH07FJ@n5Wq#L#-1NJBeJ4()@*ni}_LiA{8X6jUp+q&< fRppZI@fiBJ_4BqRH3@~z|8eT57-hrCb$|Fbq Date: Mon, 7 Apr 2025 20:18:05 +0200 Subject: [PATCH 02/23] Define entry point --- .../UnityVersioningV1/unity-versioning.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts b/Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts index e69de29..f3cf4aa 100644 --- a/Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts +++ b/Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts @@ -0,0 +1,22 @@ +import path = require("path"); +import tl = require("azure-pipelines-task-lib/task"); + +function run() { + try { + // Configure localization. + tl.setResourcePath(path.join(__dirname, "task.json")); + + // Set task result succeeded. + tl.setResult(tl.TaskResult.Succeeded); + } catch (e) { + if (e instanceof Error) { + console.error(e.message); + tl.setResult(tl.TaskResult.Failed, e.message); + } else { + console.error(e); + tl.setResult(tl.TaskResult.Failed, `${e}`); + } + } +} + +run(); From 1be259abb9fa0de7ee2a14a9039e132a3c7da3ba Mon Sep 17 00:00:00 2001 From: Dino Fejzagic Date: Mon, 7 Apr 2025 20:24:09 +0200 Subject: [PATCH 03/23] Set up dependencies --- .../UnityVersioningV1/package-lock.json | 511 ++++++++++++++++++ .../UnityVersioningV1/package.json | 3 +- 2 files changed, 512 insertions(+), 2 deletions(-) create mode 100644 Tasks/UnityVersioning/UnityVersioningV1/package-lock.json diff --git a/Tasks/UnityVersioning/UnityVersioningV1/package-lock.json b/Tasks/UnityVersioning/UnityVersioningV1/package-lock.json new file mode 100644 index 0000000..579e544 --- /dev/null +++ b/Tasks/UnityVersioning/UnityVersioningV1/package-lock.json @@ -0,0 +1,511 @@ +{ + "name": "@dinomite-studios/unity-versioning-task", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@dinomite-studios/unity-versioning-task", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.0", + "@types/node": "^22.9.1", + "azure-pipelines-task-lib": "^5.1.0" + }, + "devDependencies": { + "typescript": "^5.6.2" + } + }, + "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.0.tgz", + "integrity": "sha512-AxAZe66+B9HqHCYNSrcNNndfSRQXhHpmXWbxOQ8BQG+06QxgD7LeXCZvUUI0f3+4G4iV2GAHLfOCatpTf8naQw==", + "license": "MIT", + "dependencies": { + "azure-pipelines-task-lib": "^4.17.3", + "sanitize-filename": "^1.6.3", + "semver": "^7.7.1", + "tail": "^2.2.6" + } + }, + "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/azure-pipelines-task-lib": { + "version": "4.17.3", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-4.17.3.tgz", + "integrity": "sha512-UxfH5pk3uOHTi9TtLtdDyugQVkFES5A836ZEePjcs3jYyxm3EJ6IlFYq6gbfd6mNBhrM9fxG2u/MFYIJ+Z0cxQ==", + "license": "MIT", + "dependencies": { + "adm-zip": "^0.5.10", + "minimatch": "3.0.5", + "nodejs-file-downloader": "^4.11.1", + "q": "^1.5.1", + "semver": "^5.7.2", + "shelljs": "^0.8.5", + "uuid": "^3.0.1" + } + }, + "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/azure-pipelines-task-lib/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/@types/node": { + "version": "22.14.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.0.tgz", + "integrity": "sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/adm-zip": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.16.tgz", + "integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==", + "license": "MIT", + "engines": { + "node": ">=12.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/azure-pipelines-task-lib": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-5.1.0.tgz", + "integrity": "sha512-uoIIAlN9piFEB6XD26iZecYdND1rhr1r05UpyesXvRzFJiuVUCwJfyD2wdfLIlGuVT9MYBLQ+8Xiou6WSrEFwA==", + "license": "MIT", + "dependencies": { + "adm-zip": "^0.5.10", + "minimatch": "3.0.5", + "nodejs-file-downloader": "^4.11.1", + "q": "^1.5.1", + "semver": "^5.7.2", + "shelljs": "^0.8.5", + "uuid": "^3.0.1" + } + }, + "node_modules/azure-pipelines-task-lib/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "license": "ISC" + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.5.tgz", + "integrity": "sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nodejs-file-downloader": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/nodejs-file-downloader/-/nodejs-file-downloader-4.13.0.tgz", + "integrity": "sha512-nI2fKnmJWWFZF6SgMPe1iBodKhfpztLKJTtCtNYGhm/9QXmWa/Pk9Sv00qHgzEvNLe1x7hjGDRor7gcm/ChaIQ==", + "license": "ISC", + "dependencies": { + "follow-redirects": "^1.15.6", + "https-proxy-agent": "^5.0.0", + "mime-types": "^2.1.27", + "sanitize-filename": "^1.6.3" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "license": "MIT" + }, + "node_modules/q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", + "deprecated": "You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.\n\n(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)", + "license": "MIT", + "engines": { + "node": ">=0.6.0", + "teleport": ">=0.2.0" + } + }, + "node_modules/rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==", + "dependencies": { + "resolve": "^1.1.6" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/sanitize-filename": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.3.tgz", + "integrity": "sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==", + "license": "WTFPL OR ISC", + "dependencies": { + "truncate-utf8-bytes": "^1.0.0" + } + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shelljs": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", + "integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==", + "license": "BSD-3-Clause", + "dependencies": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + }, + "bin": { + "shjs": "bin/shjs" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tail": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/tail/-/tail-2.2.6.tgz", + "integrity": "sha512-IQ6G4wK/t8VBauYiGPLx+d3fA5XjSVagjWV5SIYzvEvglbQjwEcukeYI68JOPpdydjxhZ9sIgzRlSmwSpphHyw==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/truncate-utf8-bytes": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz", + "integrity": "sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ==", + "license": "WTFPL", + "dependencies": { + "utf8-byte-length": "^1.0.1" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" + }, + "node_modules/utf8-byte-length": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.5.tgz", + "integrity": "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==", + "license": "(WTFPL OR MIT)" + }, + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "license": "MIT", + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + } + } +} diff --git a/Tasks/UnityVersioning/UnityVersioningV1/package.json b/Tasks/UnityVersioning/UnityVersioningV1/package.json index 8955a53..1f25db2 100644 --- a/Tasks/UnityVersioning/UnityVersioningV1/package.json +++ b/Tasks/UnityVersioning/UnityVersioningV1/package.json @@ -19,9 +19,8 @@ "license": "MIT", "dependencies": { "@types/node": "^22.9.1", - "@types/q": "^1.5.8", "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.0", - "azure-pipelines-task-lib": "^4.17.3" + "azure-pipelines-task-lib": "^5.1.0" }, "devDependencies": { "typescript": "^5.6.2" From 2406153384149a867f8ac3bb649643d29b6db2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 8 Apr 2025 15:56:18 +0200 Subject: [PATCH 04/23] Revert, this will actually be a configuraiton option of the build task --- .../UnityVersioningV1/CHANGELOG.md | 10 - .../UnityVersioningV1/README.md | 3 - .../UnityVersioningV1/icon.png | Bin 2596 -> 0 bytes .../UnityVersioningV1/package-lock.json | 511 ------------------ .../UnityVersioningV1/package.json | 28 - .../UnityVersioningV1/task.json | 32 -- .../UnityVersioningV1/tsconfig.json | 9 - .../UnityVersioningV1/unity-versioning.ts | 22 - 8 files changed, 615 deletions(-) delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/README.md delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/icon.png delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/package-lock.json delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/package.json delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/task.json delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/tsconfig.json delete mode 100644 Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts diff --git a/Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md b/Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md deleted file mode 100644 index fb12c29..0000000 --- a/Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md +++ /dev/null @@ -1,10 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [1.0.0] - -Initial release \ No newline at end of file diff --git a/Tasks/UnityVersioning/UnityVersioningV1/README.md b/Tasks/UnityVersioning/UnityVersioningV1/README.md deleted file mode 100644 index 7146e75..0000000 --- a/Tasks/UnityVersioning/UnityVersioningV1/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# About Unity Versioning V1 - -Please visit [https://unitydevops.com/docs/unity-versioning-task](https://unitydevops.com/docs/unity-versioning-task) for task documentation. \ No newline at end of file diff --git a/Tasks/UnityVersioning/UnityVersioningV1/icon.png b/Tasks/UnityVersioning/UnityVersioningV1/icon.png deleted file mode 100644 index 381641428e36fadbda042059eba6c1175d114e00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2596 zcmbVO3se->86JF#V3j~1n8IcNL!h%W`(PhqP;eLBwJhP)KoEknv$GG~-Pz0xPf3yD z2FdXeqKJZ)C;~?;C`Y6kBcjA(NsgFRniQ2yz3(@wAk|WDSS!o<0lnOuBG5DNKWDYzoR~ zQspvKLT*eVnY)3M>);j3d9P>VfWSg=1TWiSwz7D3I6TgagSB%Tg?Zx;ZbLX6=~T!| z*2MA@G(+(ud<-EmOvIDQ`2vYJOep;gPlyRIQ~>TUL?Fe*GF&9&O4Xaw+cd3}oeUEQ7@AGkPyruvx-<^dk<&O^24fyqt|L*(Oj#%^#{#Ti z8f!Ds9L*Z(XHZWc|4ac0twuAgPGES&PcI20572MVf2M{vad1nWp#Pcs$* z_-wKe1`4%V4KQyylDL94(+p4ytP?%CuU05x8Cq{Lg9A2x^-7*PN+A)*B@#r)7mS;$ z(co$;%Mn(RQY*t@5FftDq{HQUJtiac5=2IdBnTl8ixD{~(<3qosg+S8on9;fipG+*XkrvM55Kp!bAe8787Zwcf>EOw2(^Dewd>%~DW*I3!`U`b2 z0b^-BmqjpCqya?hc}fp`mi;V|`ODTnU;ch>{WDATxvUq0ih8nZCWJ^MVKq=-vZAol z8Pqw0Ch~&*cgn`ko|sota4-a&%jxM0KBnh4Wd+m>n9c!nJX0WOW|vwSnW!p0vzt(@ zH~3ui5Bf}28pECY_=Io4kvob=@2&Qw%u7|fBd=YsI*NRDe)OxtA3wsjuJQ34JnS{I z(Bn1ji*fP(gH5}5ht}1OPFl_OXfmy)t3Vn)HH z)JH#!CB0QpQBl#^KQcON=e29sHj6c6pvSq|l~s;Ko7%cs8yf`-ef;Zh^|Km|9?k#! zkGtP{Z%#)=VA0jyz;Em7LX^s;>wSl4o2|dBDdO}u4OCmo+O-0|9kupX;5F6pH#<8! zS1Ug~eq40rRZmyCa#lk_LuMlpQW_F!&dn_!UbbwRygYhoK#Hr4qN*$06GBRd`};pw z{GzK}7Ao{{W4J2Eu=tDhC;s(Saa&v4OOesHIs8LXQjx%w*T^IM;PY3mTsb{9HWpOl z8Rt3s%_Clc9`iT1bu|Sci{@>5`{-Nz+PNDUvY0$ z_dxdL2Dp7e_hF#owoTTuN_k^-Rb0r(VXSDymI$8eNOw<t)Q)kZ>oj<=a7)2j~0AFrDxVN(M z@xtT;o!GbXgs~|FY2UkduiEjAHS0$U(U?5vt1p_HoB!0h4*ScEq`4OaAU~lq}w(3Osi5{g3qF`bt7YZz{*uP&Pj7GU(#GWI)}H(RZ^Xp>Gc7Ic?3+nRg{!Ju z>?>WiZQB;RcI|?^<^F#D{*i$mCG~-xuIlQ0BYD3oEiLs%muvS#*Z6-;yFgh@UMNIR6s@K?Zt&Hm(pt86VBnoI7rz_%?7M*` z+5VWYM=$&CxR@}yruv@r7XH07FJ@n5Wq#L#-1NJBeJ4()@*ni}_LiA{8X6jUp+q&< fRppZI@fiBJ_4BqRH3@~z|8eT57-hrCb$|Fbq=12.0" - } - }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "license": "MIT", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/azure-pipelines-task-lib": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-5.1.0.tgz", - "integrity": "sha512-uoIIAlN9piFEB6XD26iZecYdND1rhr1r05UpyesXvRzFJiuVUCwJfyD2wdfLIlGuVT9MYBLQ+8Xiou6WSrEFwA==", - "license": "MIT", - "dependencies": { - "adm-zip": "^0.5.10", - "minimatch": "3.0.5", - "nodejs-file-downloader": "^4.11.1", - "q": "^1.5.1", - "semver": "^5.7.2", - "shelljs": "^0.8.5", - "uuid": "^3.0.1" - } - }, - "node_modules/azure-pipelines-task-lib/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "license": "ISC", - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "license": "MIT" - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "license": "MIT" - }, - "node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "license": "ISC" - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "license": "MIT", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", - "license": "ISC", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/interpret": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/is-core-module": { - "version": "2.16.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", - "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", - "license": "MIT", - "dependencies": { - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/minimatch": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.5.tgz", - "integrity": "sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/nodejs-file-downloader": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/nodejs-file-downloader/-/nodejs-file-downloader-4.13.0.tgz", - "integrity": "sha512-nI2fKnmJWWFZF6SgMPe1iBodKhfpztLKJTtCtNYGhm/9QXmWa/Pk9Sv00qHgzEvNLe1x7hjGDRor7gcm/ChaIQ==", - "license": "ISC", - "dependencies": { - "follow-redirects": "^1.15.6", - "https-proxy-agent": "^5.0.0", - "mime-types": "^2.1.27", - "sanitize-filename": "^1.6.3" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "license": "MIT" - }, - "node_modules/q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", - "deprecated": "You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.\n\n(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)", - "license": "MIT", - "engines": { - "node": ">=0.6.0", - "teleport": ">=0.2.0" - } - }, - "node_modules/rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==", - "dependencies": { - "resolve": "^1.1.6" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/resolve": { - "version": "1.22.10", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", - "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", - "license": "MIT", - "dependencies": { - "is-core-module": "^2.16.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/sanitize-filename": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.3.tgz", - "integrity": "sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==", - "license": "WTFPL OR ISC", - "dependencies": { - "truncate-utf8-bytes": "^1.0.0" - } - }, - "node_modules/semver": { - "version": "7.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", - "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/shelljs": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", - "integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==", - "license": "BSD-3-Clause", - "dependencies": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - }, - "bin": { - "shjs": "bin/shjs" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/tail": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/tail/-/tail-2.2.6.tgz", - "integrity": "sha512-IQ6G4wK/t8VBauYiGPLx+d3fA5XjSVagjWV5SIYzvEvglbQjwEcukeYI68JOPpdydjxhZ9sIgzRlSmwSpphHyw==", - "license": "MIT", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/truncate-utf8-bytes": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz", - "integrity": "sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ==", - "license": "WTFPL", - "dependencies": { - "utf8-byte-length": "^1.0.1" - } - }, - "node_modules/typescript": { - "version": "5.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", - "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "license": "MIT" - }, - "node_modules/utf8-byte-length": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.5.tgz", - "integrity": "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==", - "license": "(WTFPL OR MIT)" - }, - "node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "license": "MIT", - "bin": { - "uuid": "bin/uuid" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "license": "ISC" - } - } -} diff --git a/Tasks/UnityVersioning/UnityVersioningV1/package.json b/Tasks/UnityVersioning/UnityVersioningV1/package.json deleted file mode 100644 index 1f25db2..0000000 --- a/Tasks/UnityVersioning/UnityVersioningV1/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@dinomite-studios/unity-versioning-task", - "version": "1.0.0", - "description": "Azure Pipelines task to modify a Unity project's bundle version and build codes and check them back in to the project repository.", - "main": "unity-versioning.js", - "scripts": { - "build": "tsc", - "upload": "tfx build tasks upload --task-path ./", - "test": "nyc mocha test/_suite.js", - "dev-refresh": "npm run dev-delete && npm run dev-upload", - "dev-delete": "tfx build tasks delete --task-id 1fc2f58e-a8e5-4d5b-907d-467ca982ec76", - "dev-upload": "npm run build && npm run upload" - }, - "repository": { - "type": "git", - "url": "https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks" - }, - "author": "Dinomite", - "license": "MIT", - "dependencies": { - "@types/node": "^22.9.1", - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.0", - "azure-pipelines-task-lib": "^5.1.0" - }, - "devDependencies": { - "typescript": "^5.6.2" - } -} diff --git a/Tasks/UnityVersioning/UnityVersioningV1/task.json b/Tasks/UnityVersioning/UnityVersioningV1/task.json deleted file mode 100644 index 035cb34..0000000 --- a/Tasks/UnityVersioning/UnityVersioningV1/task.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "id": "1fc2f58e-a8e5-4d5b-907d-467ca982ec76", - "name": "UnityVersioningTask", - "friendlyName": "Unity Versioning", - "description": "Modifies a Unity project's bundle version and build codes and check them back in to the project repository.", - "helpMarkDown": "Use this task to update your project's version upon build. [More Information](https://unitydevops.com/docs/unity-versioning-task)", - "category": "Azure Pipelines", - "visibility": ["Build"], - "author": "Dinomite", - "version": { - "Major": 1, - "Minor": 0, - "Patch": 0 - }, - "releaseNotes": "[Full Changelog](https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/blob/master/Tasks/UnityVersioning/UnityVersioningV1/CHANGELOG.md)", - "minimumAgentVersion": "2.144.0", - "instanceNameFormat": "Unity Versioning", - "groups": [], - "inputs": [], - "outputVariables": [], - "execution": { - "Node10": { - "target": "unity-versioning.js", - "argumentFormat": "" - }, - "Node20_1": { - "target": "unity-versioning.js", - "argumentFormat": "" - } - }, - "messages": {} -} diff --git a/Tasks/UnityVersioning/UnityVersioningV1/tsconfig.json b/Tasks/UnityVersioning/UnityVersioningV1/tsconfig.json deleted file mode 100644 index 44c07d4..0000000 --- a/Tasks/UnityVersioning/UnityVersioningV1/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "target": "es6", - "module": "commonjs", - "strict": true, - "esModuleInterop": true - }, - "exclude": ["node_modules", "dist", "test"] -} diff --git a/Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts b/Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts deleted file mode 100644 index f3cf4aa..0000000 --- a/Tasks/UnityVersioning/UnityVersioningV1/unity-versioning.ts +++ /dev/null @@ -1,22 +0,0 @@ -import path = require("path"); -import tl = require("azure-pipelines-task-lib/task"); - -function run() { - try { - // Configure localization. - tl.setResourcePath(path.join(__dirname, "task.json")); - - // Set task result succeeded. - tl.setResult(tl.TaskResult.Succeeded); - } catch (e) { - if (e instanceof Error) { - console.error(e.message); - tl.setResult(tl.TaskResult.Failed, e.message); - } else { - console.error(e); - tl.setResult(tl.TaskResult.Failed, `${e}`); - } - } -} - -run(); From 896307ec2daad8bd9257221f269606d443bed9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 8 Apr 2025 18:13:03 +0200 Subject: [PATCH 05/23] Define inputs --- Tasks/UnityBuild/UnityBuildV3/CHANGELOG.md | 8 +- Tasks/UnityBuild/UnityBuildV3/package.json | 2 +- Tasks/UnityBuild/UnityBuildV3/task.json | 119 +++++- Tasks/UnityBuild/UnityBuildV3/unity-build.ts | 400 ++++++++++-------- .../UnityBuildV3/unity-versioning.ts | 5 + 5 files changed, 359 insertions(+), 175 deletions(-) create mode 100644 Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts diff --git a/Tasks/UnityBuild/UnityBuildV3/CHANGELOG.md b/Tasks/UnityBuild/UnityBuildV3/CHANGELOG.md index 66ca826..7a317f3 100644 --- a/Tasks/UnityBuild/UnityBuildV3/CHANGELOG.md +++ b/Tasks/UnityBuild/UnityBuildV3/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.4.0] + +### Added + +- Project versioning configuration to modify a project's bundle version and/or build code and commit the change to the repository as well as create a tag + ## [3.3.0] ### Added @@ -112,4 +118,4 @@ Maintenance release ### Removed - Removed build output path output variable. The build output path can now be set by the user as part of the build task configuration, hence output variable is not needed anymore -- Removed build log output variable. Whether to create a build log or not and where can be specified as part of the additional arguments setting \ No newline at end of file +- Removed build log output variable. Whether to create a build log or not and where can be specified as part of the additional arguments setting diff --git a/Tasks/UnityBuild/UnityBuildV3/package.json b/Tasks/UnityBuild/UnityBuildV3/package.json index e9732bc..03e13a6 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package.json +++ b/Tasks/UnityBuild/UnityBuildV3/package.json @@ -1,6 +1,6 @@ { "name": "@dinomite-studios/unity-build-task", - "version": "3.3.0", + "version": "3.4.0", "description": "An Azure Pipelines task to build Unity projects.", "main": "unity-build.js", "scripts": { diff --git a/Tasks/UnityBuild/UnityBuildV3/task.json b/Tasks/UnityBuild/UnityBuildV3/task.json index 0055cc8..f941c47 100644 --- a/Tasks/UnityBuild/UnityBuildV3/task.json +++ b/Tasks/UnityBuild/UnityBuildV3/task.json @@ -6,13 +6,11 @@ "helpMarkDown": "Use this task to build your Unity project and generate the target platform's output files. [More Information](https://unitydevops.com/docs/unity-build-task)", "category": "Azure Pipelines", "preview": false, - "visibility": [ - "Build" - ], + "visibility": ["Build"], "author": "Dinomite", "version": { "Major": 3, - "Minor": 3, + "Minor": 4, "Patch": 0 }, "releaseNotes": "[Full Changelog](https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/blob/master/Tasks/UnityBuild/UnityBuildV3/CHANGELOG.md)", @@ -24,6 +22,11 @@ "displayName": "General", "isExpanded": true }, + { + "name": "versioning", + "displayName": "Versioning", + "isExpanded": true + }, { "name": "build", "displayName": "Build", @@ -91,6 +94,109 @@ "required": false, "helpMarkDown": "(Optional) Enter the path to the Unity project within the repository. If no value is entered, the root of the repository will be used." }, + { + "name": "projectVersioningBundleVersionMode", + "type": "pickList", + "label": "Bundle versioning mode", + "defaultValue": "none", + "helpMarkDown": "Define if and how to modify the project's bundle version.", + "groupName": "versioning", + "options": { + "none": "None", + "increment": "Increment bundle version", + "set": "Set bundle version" + } + }, + { + "name": "projectVersioningBundleVersionMajor", + "type": "string", + "label": "Major (Increment by / Set to)", + "groupName": "versioning", + "helpMarkDown": "Either the new value for the bundle major version or the increment for the major version to apply.", + "visibleRule": "projectVersioningBundleVersionMode = increment || projectVersioningBundleVersionMode = set" + }, + { + "name": "projectVersioningBundleVersionMinor", + "type": "string", + "label": "Minor (Increment by / Set to)", + "groupName": "versioning", + "helpMarkDown": "Either the new value for the bundle minor version or the increment for the minor version to apply.", + "visibleRule": "projectVersioningBundleVersionMode = increment || projectVersioningBundleVersionMode = set" + }, + { + "name": "projectVersioningBundleVersionPatch", + "type": "string", + "label": "Patch (Increment by / Set to)", + "groupName": "versioning", + "helpMarkDown": "Either the new value for the bundle patch version or the increment for the patch version to apply.", + "visibleRule": "projectVersioningBundleVersionMode = increment || projectVersioningBundleVersionMode = set" + }, + { + "name": "projectVersioningBuildNumberMode", + "type": "pickList", + "label": "Build number mode", + "defaultValue": "none", + "helpMarkDown": "Define if and how to modify the project's build number.", + "groupName": "versioning", + "options": { + "none": "None", + "increment": "Increment build number", + "set": "Set build number" + } + }, + { + "name": "projectVersioningBuildNumber", + "type": "string", + "label": "Build number (Increment by / Set to)", + "groupName": "versioning", + "helpMarkDown": "Either the new value for the build number or the increment for the build number to apply.", + "visibleRule": "projectVersioningBuildNumberMode = increment || projectVersioningBuildNumberMode = set" + }, + { + "name": "projectVersioningCommitChanges", + "type": "boolean", + "label": "Commit changes to repository", + "defaultValue": true, + "groupName": "versioning", + "visibleRule": "projectVersioningBundleVersionMode != none || projectVersioningBuildNumberMode != none", + "helpMarkDown": "(Optional) Commit the updated bundle version / build number to the repository." + }, + { + "name": "projectVersioningCommitChangesUserName", + "type": "string", + "label": "git user name", + "groupName": "versioning", + "defaultValue": "Azure Pipelines", + "helpMarkDown": "The user name to use when commiting changes.", + "visibleRule": "projectVersioningCommitChanges = true" + }, + { + "name": "projectVersioningCommitChangesUserMail", + "type": "string", + "label": "git user mail", + "groupName": "versioning", + "defaultValue": "agent@dev.azure.com", + "helpMarkDown": "The user mail to use when commiting changes.", + "visibleRule": "projectVersioningCommitChanges = true" + }, + { + "name": "projectVersioningCreateTag", + "type": "boolean", + "label": "Create a git tag for the changes", + "defaultValue": true, + "groupName": "versioning", + "visibleRule": "projectVersioningCommitChanges = true", + "helpMarkDown": "(Optional) Creates a git tag for the changeset." + }, + { + "name": "projectVersioningCreateTagPattern", + "type": "string", + "label": "git tag pattern", + "groupName": "versioning", + "defaultValue": "v{{bundleVersion}}", + "helpMarkDown": "The pattern defines what the created git tag will look like. Valid placeholders are: {{bundleVersion}}, {{buildNumber}}", + "visibleRule": "projectVersioningCreateTag = true" + }, { "name": "buildFlow", "type": "radio", @@ -291,6 +397,7 @@ "warningAlphaBetaVersion": "You are using a Unity Alpha/Beta version. It may not be supported by the extension!", "projectPathInfo": "Determining Unity editor version for project at", "successGetUnityEditorVersion": "Success, Unity editor version found", - "failGetUnityEditorVersion": "Fail, Unity editor version not found" + "failGetUnityEditorVersion": "\nERROR: Fail, Unity editor version not found", + "taskResultFailedVersioning": "\nERROR: Failed during the project versioning process with exit code:" } -} \ No newline at end of file +} diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts index 2f11511..ca2bda9 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts @@ -1,190 +1,256 @@ -import path = require('path'); -import tl = require('azure-pipelines-task-lib/task'); -import fs = require('fs-extra'); +import path = require("path"); +import tl = require("azure-pipelines-task-lib/task"); +import fs = require("fs-extra"); import { - UnityToolRunner, - UnityPathTools, - UnityVersionInfoResult, - Utilities, - UnityVersionTools, - UnityPackageManagerTools -} from '@dinomite-studios/unity-azure-pipelines-tasks-lib'; + UnityToolRunner, + UnityPathTools, + UnityVersionInfoResult, + Utilities, + UnityVersionTools, + UnityPackageManagerTools, +} from "@dinomite-studios/unity-azure-pipelines-tasks-lib"; +import { UnityProjectVersioning } from "./unity-versioning"; // Input variables. -const outputFileNameInputVariableName = 'outputFileName'; -const buildTargetInputVariableName = 'buildTarget'; -const outputPathInputVariableName = 'outputPath'; -const unityProjectPathInputVariableName = 'unityProjectPath'; -const versionInputVariableName = 'version'; -const buildScriptTypeInputVariableName = 'buildScriptType'; -const unityEditorsPathModeInputVariableName = 'unityEditorsPathMode'; -const inlineBuildScriptInputVariableName = 'inlineBuildScript'; -const scriptExecuteMethodInputVariableName = 'scriptExecuteMethod'; -const additionalCmdArgsInputVariableName = 'additionalCmdArgs'; -const customUnityEditorsPathInputVariableName = 'customUnityEditorsPath'; -const cleanBuildInputVariableName = 'Build.Repository.Clean'; -const versionSelectionModeVariableName = 'versionSelectionMode'; -const signAppBundleInputVariableName = 'androidSignAppBundle'; -const keystoreNameInputVariableName = 'androidKeystoreName'; -const keystorePassInputVariableName = 'androidKeystorePass'; -const keystoreAliasNameInputVariableName = 'androidKeystoreAliasName'; -const keystoreAliasPassInputVariableName = 'androidKeystoreAliasPass'; -const buildAppBundleInputVariableName = 'androidBuildAppBundle'; -const buildFlowInputVariableName = 'buildFlow'; -const buildProfileInputVariableName = 'buildProfile'; +const outputFileNameInputVariableName = "outputFileName"; +const buildTargetInputVariableName = "buildTarget"; +const outputPathInputVariableName = "outputPath"; +const unityProjectPathInputVariableName = "unityProjectPath"; +const versionInputVariableName = "version"; +const buildScriptTypeInputVariableName = "buildScriptType"; +const unityEditorsPathModeInputVariableName = "unityEditorsPathMode"; +const inlineBuildScriptInputVariableName = "inlineBuildScript"; +const scriptExecuteMethodInputVariableName = "scriptExecuteMethod"; +const additionalCmdArgsInputVariableName = "additionalCmdArgs"; +const customUnityEditorsPathInputVariableName = "customUnityEditorsPath"; +const cleanBuildInputVariableName = "Build.Repository.Clean"; +const versionSelectionModeVariableName = "versionSelectionMode"; +const signAppBundleInputVariableName = "androidSignAppBundle"; +const keystoreNameInputVariableName = "androidKeystoreName"; +const keystorePassInputVariableName = "androidKeystorePass"; +const keystoreAliasNameInputVariableName = "androidKeystoreAliasName"; +const keystoreAliasPassInputVariableName = "androidKeystoreAliasPass"; +const buildAppBundleInputVariableName = "androidBuildAppBundle"; +const buildFlowInputVariableName = "buildFlow"; +const buildProfileInputVariableName = "buildProfile"; // Output variables. -const editorLogFilePathOutputVariableName = 'editorLogFilePath'; +const editorLogFilePathOutputVariableName = "editorLogFilePath"; async function run() { - try { - // Configure localization. - tl.setResourcePath(path.join(__dirname, 'task.json')); - - // Setup and read inputs. - const outputFileName = tl.getInput(outputFileNameInputVariableName) ?? 'drop'; - const projectPath = tl.getPathInput(unityProjectPathInputVariableName) ?? ''; - const versionSelectionMode = tl.getInput(versionSelectionModeVariableName, true)! - const outputPath = tl.getPathInput(outputPathInputVariableName) ?? ''; - const unityEditorsPath = UnityPathTools.getUnityEditorsPath( - tl.getInput(unityEditorsPathModeInputVariableName, true)!, - tl.getInput(customUnityEditorsPathInputVariableName)); - - let unityVersion: UnityVersionInfoResult; - if (versionSelectionMode === 'specify') { - let customVersion = tl.getInput(versionInputVariableName, true)!; - unityVersion = { - info: { - isAlpha: false, - isBeta: false, - version: customVersion, - revision: undefined - }, - error: undefined - } - } else { - unityVersion = getUnityEditorVersion(); - } + try { + // Configure localization. + tl.setResourcePath(path.join(__dirname, "task.json")); - const unityExecutablePath = UnityPathTools.getUnityExecutableFullPath(unityEditorsPath, unityVersion.info!); - const cleanBuild = tl.getVariable(cleanBuildInputVariableName); + const versioningResult = UnityProjectVersioning.run(); + if (versioningResult !== 0) { + const log = `${tl.loc("taskResultFailedVersioning")} ${versioningResult}`; + console.error(log); + tl.setResult(tl.TaskResult.Failed, log); + return; + } - // Set output variable values. - const logFilesDirectory = path.join(tl.getVariable('Agent.TempDirectory')!, 'Logs'); - const logFilePath = path.join(logFilesDirectory, `UnityBuildLog_${Utilities.getLogFileNameTimeStamp()}.log`); - tl.setVariable(editorLogFilePathOutputVariableName, logFilePath); + // Setup and read inputs. + const outputFileName = + tl.getInput(outputFileNameInputVariableName) ?? "drop"; + const projectPath = + tl.getPathInput(unityProjectPathInputVariableName) ?? ""; + const versionSelectionMode = tl.getInput( + versionSelectionModeVariableName, + true + )!; + const outputPath = tl.getPathInput(outputPathInputVariableName) ?? ""; + const unityEditorsPath = UnityPathTools.getUnityEditorsPath( + tl.getInput(unityEditorsPathModeInputVariableName, true)!, + tl.getInput(customUnityEditorsPathInputVariableName) + ); - // If clean was specified by the user, delete the existing output directory, if it exists - if (cleanBuild === 'true') { - fs.removeSync(outputPath); - } + let unityVersion: UnityVersionInfoResult; + if (versionSelectionMode === "specify") { + let customVersion = tl.getInput(versionInputVariableName, true)!; + unityVersion = { + info: { + isAlpha: false, + isBeta: false, + version: customVersion, + revision: undefined, + }, + error: undefined, + }; + } else { + unityVersion = getUnityEditorVersion(); + } - // No matter if clean build or not, make sure the output diretory exists - tl.mkdirP(outputPath); - tl.checkPath(outputPath, 'Build Output Directory'); - - // Execute Unity command line. - const buildFlow = tl.getInput(buildFlowInputVariableName) ?? 'platform'; - const unityCmd = tl.tool(unityExecutablePath) - .arg('-batchmode') - .arg(buildFlow === 'platform' ? '-buildTarget' : '-activeBuildProfile') - .arg(tl.getInput(buildFlow === 'platform' ? buildTargetInputVariableName : buildProfileInputVariableName, true)!) - .arg('-projectPath') - .arg(projectPath) - .arg('-logfile') - .arg(logFilePath); - - const additionalArgs = tl.getInput(additionalCmdArgsInputVariableName) ?? ''; - if (additionalArgs !== '') { - unityCmd.line(additionalArgs); - } + const unityExecutablePath = UnityPathTools.getUnityExecutableFullPath( + unityEditorsPath, + unityVersion.info! + ); + const cleanBuild = tl.getVariable(cleanBuildInputVariableName); - // Perform setup depending on build script type selected - const buildScriptType = tl.getInput(buildScriptTypeInputVariableName) ?? 'default'; - - if (buildScriptType === 'default') { - // When using default build scripts we rely on a Utility package being installed to the project via the Unity Package Manager. - // By adding it to the manifest before opening the project, Unity will load the package before trying to build the project. - UnityPackageManagerTools.addPackageToProject(projectPath, 'games.dinomite.azurepipelines', 'https://github.com/Dinomite-Studios/games.dinomite.azurepipelines.git#v1.0.14'); - unityCmd.arg('-executeMethod').arg('AzurePipelinesBuild.PerformBuild'); - unityCmd.arg('-outputFileName').arg(outputFileName); - unityCmd.arg('-outputPath').arg(outputPath); - - if (tl.getBoolInput(signAppBundleInputVariableName)) { - unityCmd.arg('-keystoreName').arg(tl.getPathInput(keystoreNameInputVariableName) ?? ''); - unityCmd.arg('-keystorePass').arg(tl.getInput(keystorePassInputVariableName) ?? ''); - unityCmd.arg('-keystoreAliasName').arg(tl.getInput(keystoreAliasNameInputVariableName) ?? ''); - - // The alias password is optional and should only be passed, if not empty or undefined. - const keystoreAliasPass = tl.getInput(keystoreAliasPassInputVariableName) ?? ''; - if (keystoreAliasPass) { - unityCmd.arg('-keystoreAliasPass').arg(keystoreAliasPass); - } - } - - if (tl.getBoolInput(buildAppBundleInputVariableName)) { - unityCmd.arg('-buildAppBundle'); - } - } else if (buildScriptType === 'inline') { - // Create a C# script file in a Editor folder at the root Assets directory level. Then write - // the default or the user's script into it. Unity will then compile it on launch and make sure it's available. - const projectAssetsEditorFolderPath = path.join(`${projectPath}`, 'Assets', 'Editor'); - tl.mkdirP(projectAssetsEditorFolderPath); - tl.cd(projectAssetsEditorFolderPath); - tl.writeFile('AzureDevOps.cs', tl.getInput(inlineBuildScriptInputVariableName)!); - tl.cd(projectPath); - - // Tell Unity which method to execute for build. - unityCmd.arg('-executeMethod').arg(tl.getInput(scriptExecuteMethodInputVariableName)!); - } else if (buildScriptType === 'existing') { - // If the user already has an existing build script we only need the method to execute. - unityCmd.arg('-executeMethod').arg(tl.getInput(scriptExecuteMethodInputVariableName)!).arg('-quit'); - } else { - throw `Unsupported build script type ${buildScriptType}` - } + // Set output variable values. + const logFilesDirectory = path.join( + tl.getVariable("Agent.TempDirectory")!, + "Logs" + ); + const logFilePath = path.join( + logFilesDirectory, + `UnityBuildLog_${Utilities.getLogFileNameTimeStamp()}.log` + ); + tl.setVariable(editorLogFilePathOutputVariableName, logFilePath); - const result = await UnityToolRunner.run(unityCmd, logFilePath); - - // Unity process has finished. Set task result. - if (result === 0) { - const buildSuccessLog = tl.loc('buildSuccess'); - console.log(buildSuccessLog); - tl.setResult(tl.TaskResult.Succeeded, buildSuccessLog); - } else { - const buildFailLog = `${tl.loc('buildFailed')} ${result}`; - console.log(buildFailLog); - tl.setResult(tl.TaskResult.Failed, buildFailLog); - } - } catch (e) { - if (e instanceof Error) { - console.error(e.message); - tl.setResult(tl.TaskResult.Failed, e.message); - } else { - console.error(e); - tl.setResult(tl.TaskResult.Failed, `${e}`); + // If clean was specified by the user, delete the existing output directory, if it exists + if (cleanBuild === "true") { + fs.removeSync(outputPath); + } + + // No matter if clean build or not, make sure the output diretory exists + tl.mkdirP(outputPath); + tl.checkPath(outputPath, "Build Output Directory"); + + // Execute Unity command line. + const buildFlow = tl.getInput(buildFlowInputVariableName) ?? "platform"; + const unityCmd = tl + .tool(unityExecutablePath) + .arg("-batchmode") + .arg(buildFlow === "platform" ? "-buildTarget" : "-activeBuildProfile") + .arg( + tl.getInput( + buildFlow === "platform" + ? buildTargetInputVariableName + : buildProfileInputVariableName, + true + )! + ) + .arg("-projectPath") + .arg(projectPath) + .arg("-logfile") + .arg(logFilePath); + + const additionalArgs = + tl.getInput(additionalCmdArgsInputVariableName) ?? ""; + if (additionalArgs !== "") { + unityCmd.line(additionalArgs); + } + + // Perform setup depending on build script type selected + const buildScriptType = + tl.getInput(buildScriptTypeInputVariableName) ?? "default"; + + if (buildScriptType === "default") { + // When using default build scripts we rely on a Utility package being installed to the project via the Unity Package Manager. + // By adding it to the manifest before opening the project, Unity will load the package before trying to build the project. + UnityPackageManagerTools.addPackageToProject( + projectPath, + "games.dinomite.azurepipelines", + "https://github.com/Dinomite-Studios/games.dinomite.azurepipelines.git#v1.0.14" + ); + unityCmd.arg("-executeMethod").arg("AzurePipelinesBuild.PerformBuild"); + unityCmd.arg("-outputFileName").arg(outputFileName); + unityCmd.arg("-outputPath").arg(outputPath); + + if (tl.getBoolInput(signAppBundleInputVariableName)) { + unityCmd + .arg("-keystoreName") + .arg(tl.getPathInput(keystoreNameInputVariableName) ?? ""); + unityCmd + .arg("-keystorePass") + .arg(tl.getInput(keystorePassInputVariableName) ?? ""); + unityCmd + .arg("-keystoreAliasName") + .arg(tl.getInput(keystoreAliasNameInputVariableName) ?? ""); + + // The alias password is optional and should only be passed, if not empty or undefined. + const keystoreAliasPass = + tl.getInput(keystoreAliasPassInputVariableName) ?? ""; + if (keystoreAliasPass) { + unityCmd.arg("-keystoreAliasPass").arg(keystoreAliasPass); } + } + + if (tl.getBoolInput(buildAppBundleInputVariableName)) { + unityCmd.arg("-buildAppBundle"); + } + } else if (buildScriptType === "inline") { + // Create a C# script file in a Editor folder at the root Assets directory level. Then write + // the default or the user's script into it. Unity will then compile it on launch and make sure it's available. + const projectAssetsEditorFolderPath = path.join( + `${projectPath}`, + "Assets", + "Editor" + ); + tl.mkdirP(projectAssetsEditorFolderPath); + tl.cd(projectAssetsEditorFolderPath); + tl.writeFile( + "AzureDevOps.cs", + tl.getInput(inlineBuildScriptInputVariableName)! + ); + tl.cd(projectPath); + + // Tell Unity which method to execute for build. + unityCmd + .arg("-executeMethod") + .arg(tl.getInput(scriptExecuteMethodInputVariableName)!); + } else if (buildScriptType === "existing") { + // If the user already has an existing build script we only need the method to execute. + unityCmd + .arg("-executeMethod") + .arg(tl.getInput(scriptExecuteMethodInputVariableName)!) + .arg("-quit"); + } else { + throw `Unsupported build script type ${buildScriptType}`; + } + + const result = await UnityToolRunner.run(unityCmd, logFilePath); + + // Unity process has finished. Set task result. + if (result === 0) { + const buildSuccessLog = tl.loc("buildSuccess"); + console.log(buildSuccessLog); + tl.setResult(tl.TaskResult.Succeeded, buildSuccessLog); + } else { + const buildFailLog = `${tl.loc("buildFailed")} ${result}`; + console.log(buildFailLog); + tl.setResult(tl.TaskResult.Failed, buildFailLog); + } + } catch (e) { + if (e instanceof Error) { + console.error(e.message); + tl.setResult(tl.TaskResult.Failed, e.message); + } else { + console.error(e); + tl.setResult(tl.TaskResult.Failed, `${e}`); } + } } function getUnityEditorVersion(): UnityVersionInfoResult { - const projectPath = tl.getPathInput('unityProjectPath') ?? ''; - console.log(`${tl.loc('projectPathInfo')} ${projectPath}`); - - const unityVersion = UnityVersionTools.determineProjectVersionFromFile(projectPath); - if (unityVersion.error) { - const error = `${tl.loc('failGetUnityEditorVersion')} | ${unityVersion.error}`; - console.error(error); - throw new Error(error); - } + const projectPath = tl.getPathInput("unityProjectPath") ?? ""; + console.log(`${tl.loc("projectPathInfo")} ${projectPath}`); - const successGetVersionLog = `${tl.loc('successGetUnityEditorVersion')} ${unityVersion.info!.version}${unityVersion.info!.revision ? `, revision=${unityVersion.info!.revision}` : ''}, alpha=${unityVersion.info!.isAlpha}, beta=${unityVersion.info!.isBeta}`; - console.log(successGetVersionLog); + const unityVersion = + UnityVersionTools.determineProjectVersionFromFile(projectPath); + if (unityVersion.error) { + const error = `${tl.loc("failGetUnityEditorVersion")} | ${ + unityVersion.error + }`; + console.error(error); + throw new Error(error); + } - if (unityVersion.info!.isAlpha || unityVersion.info!.isBeta) { - console.warn(tl.loc('warningAlphaBetaVersion')); - } + const successGetVersionLog = `${tl.loc("successGetUnityEditorVersion")} ${ + unityVersion.info!.version + }${ + unityVersion.info!.revision + ? `, revision=${unityVersion.info!.revision}` + : "" + }, alpha=${unityVersion.info!.isAlpha}, beta=${unityVersion.info!.isBeta}`; + console.log(successGetVersionLog); + + if (unityVersion.info!.isAlpha || unityVersion.info!.isBeta) { + console.warn(tl.loc("warningAlphaBetaVersion")); + } - return unityVersion; + return unityVersion; } -run(); \ No newline at end of file +run(); diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts new file mode 100644 index 0000000..b2c745d --- /dev/null +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -0,0 +1,5 @@ +export class UnityProjectVersioning { + public static run(): number { + return 0; + } +} From cf16d4c0d225ae02726e445cb110db6f1521cd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 9 Apr 2025 09:55:57 +0200 Subject: [PATCH 06/23] Implement versioninig step --- .../UnityBuild/UnityBuildV3/build-platform.ts | 21 ++ .../UnityBuild/UnityBuildV3/package-lock.json | 95 +++++++-- Tasks/UnityBuild/UnityBuildV3/package.json | 4 +- Tasks/UnityBuild/UnityBuildV3/task.json | 12 ++ Tasks/UnityBuild/UnityBuildV3/unity-build.ts | 50 ++--- .../UnityBuildV3/unity-versioning.ts | 199 +++++++++++++++++- Tasks/UnityBuild/UnityBuildV3/variables.ts | 44 ++++ Tasks/UnitySetup/UnitySetupV2/variables.ts | 3 - 8 files changed, 381 insertions(+), 47 deletions(-) create mode 100644 Tasks/UnityBuild/UnityBuildV3/build-platform.ts create mode 100644 Tasks/UnityBuild/UnityBuildV3/variables.ts diff --git a/Tasks/UnityBuild/UnityBuildV3/build-platform.ts b/Tasks/UnityBuild/UnityBuildV3/build-platform.ts new file mode 100644 index 0000000..5d7c73a --- /dev/null +++ b/Tasks/UnityBuild/UnityBuildV3/build-platform.ts @@ -0,0 +1,21 @@ +export enum BuildPlatform { + Standalone = "standalone", + Windows32 = "Win", + Windows64 = "Win64", + OSXUniversal = "OSXUniversal", + Linux = "Linux", + Linux64 = "Linux64", + LinuxUniversal = "LinuxUniversal", + IOS = "iOS", + Android = "Android", + Web = "Web", + WebStreamed = "WebStreamed", + WebGL = "WebGL", + XboxOne = "XboxOne", + PS4 = "PS4", + WindowsStoreApps = "WindowsStoreApps", + Switch = "Switch", + N3DS = "N3DS", + TVOS = "tvOS", + VisionOS = "visionos", +} diff --git a/Tasks/UnityBuild/UnityBuildV3/package-lock.json b/Tasks/UnityBuild/UnityBuildV3/package-lock.json index e44faa1..667b5e1 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package-lock.json +++ b/Tasks/UnityBuild/UnityBuildV3/package-lock.json @@ -1,19 +1,19 @@ { "name": "@dinomite-studios/unity-build-task", - "version": "3.2.3", + "version": "3.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@dinomite-studios/unity-build-task", - "version": "3.2.3", + "version": "3.4.0", "license": "MIT", "dependencies": { - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.0.11", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.0", "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", - "azure-pipelines-task-lib": "^4.17.3", + "azure-pipelines-task-lib": "^5.1.0", "fs-extra": "^8.1.0" }, "devDependencies": { @@ -21,15 +21,49 @@ } }, "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.0.11.tgz", - "integrity": "sha512-aK626w3jAbeg59Is9xjZs3/4a228w/C0xhY0KHEYSpHn224bdvM65KMb/ov4i5D7o6H57vY18KYI7FAk5pr/Zw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.0.tgz", + "integrity": "sha512-AxAZe66+B9HqHCYNSrcNNndfSRQXhHpmXWbxOQ8BQG+06QxgD7LeXCZvUUI0f3+4G4iV2GAHLfOCatpTf8naQw==", "dependencies": { "azure-pipelines-task-lib": "^4.17.3", "sanitize-filename": "^1.6.3", + "semver": "^7.7.1", "tail": "^2.2.6" } }, + "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/azure-pipelines-task-lib": { + "version": "4.17.3", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-4.17.3.tgz", + "integrity": "sha512-UxfH5pk3uOHTi9TtLtdDyugQVkFES5A836ZEePjcs3jYyxm3EJ6IlFYq6gbfd6mNBhrM9fxG2u/MFYIJ+Z0cxQ==", + "dependencies": { + "adm-zip": "^0.5.10", + "minimatch": "3.0.5", + "nodejs-file-downloader": "^4.11.1", + "q": "^1.5.1", + "semver": "^5.7.2", + "shelljs": "^0.8.5", + "uuid": "^3.0.1" + } + }, + "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/azure-pipelines-task-lib/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@types/fs-extra": { "version": "9.0.13", "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", @@ -71,9 +105,9 @@ } }, "node_modules/azure-pipelines-task-lib": { - "version": "4.17.3", - "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-4.17.3.tgz", - "integrity": "sha512-UxfH5pk3uOHTi9TtLtdDyugQVkFES5A836ZEePjcs3jYyxm3EJ6IlFYq6gbfd6mNBhrM9fxG2u/MFYIJ+Z0cxQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-5.1.0.tgz", + "integrity": "sha512-uoIIAlN9piFEB6XD26iZecYdND1rhr1r05UpyesXvRzFJiuVUCwJfyD2wdfLIlGuVT9MYBLQ+8Xiou6WSrEFwA==", "dependencies": { "adm-zip": "^0.5.10", "minimatch": "3.0.5", @@ -471,13 +505,42 @@ }, "dependencies": { "@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.0.11.tgz", - "integrity": "sha512-aK626w3jAbeg59Is9xjZs3/4a228w/C0xhY0KHEYSpHn224bdvM65KMb/ov4i5D7o6H57vY18KYI7FAk5pr/Zw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.0.tgz", + "integrity": "sha512-AxAZe66+B9HqHCYNSrcNNndfSRQXhHpmXWbxOQ8BQG+06QxgD7LeXCZvUUI0f3+4G4iV2GAHLfOCatpTf8naQw==", "requires": { "azure-pipelines-task-lib": "^4.17.3", "sanitize-filename": "^1.6.3", + "semver": "^7.7.1", "tail": "^2.2.6" + }, + "dependencies": { + "azure-pipelines-task-lib": { + "version": "4.17.3", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-4.17.3.tgz", + "integrity": "sha512-UxfH5pk3uOHTi9TtLtdDyugQVkFES5A836ZEePjcs3jYyxm3EJ6IlFYq6gbfd6mNBhrM9fxG2u/MFYIJ+Z0cxQ==", + "requires": { + "adm-zip": "^0.5.10", + "minimatch": "3.0.5", + "nodejs-file-downloader": "^4.11.1", + "q": "^1.5.1", + "semver": "^5.7.2", + "shelljs": "^0.8.5", + "uuid": "^3.0.1" + }, + "dependencies": { + "semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==" + } + } + }, + "semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==" + } } }, "@types/fs-extra": { @@ -515,9 +578,9 @@ } }, "azure-pipelines-task-lib": { - "version": "4.17.3", - "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-4.17.3.tgz", - "integrity": "sha512-UxfH5pk3uOHTi9TtLtdDyugQVkFES5A836ZEePjcs3jYyxm3EJ6IlFYq6gbfd6mNBhrM9fxG2u/MFYIJ+Z0cxQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-5.1.0.tgz", + "integrity": "sha512-uoIIAlN9piFEB6XD26iZecYdND1rhr1r05UpyesXvRzFJiuVUCwJfyD2wdfLIlGuVT9MYBLQ+8Xiou6WSrEFwA==", "requires": { "adm-zip": "^0.5.10", "minimatch": "3.0.5", diff --git a/Tasks/UnityBuild/UnityBuildV3/package.json b/Tasks/UnityBuild/UnityBuildV3/package.json index 03e13a6..fdf0901 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package.json +++ b/Tasks/UnityBuild/UnityBuildV3/package.json @@ -21,8 +21,8 @@ "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.0.11", - "azure-pipelines-task-lib": "^4.17.3", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.0", + "azure-pipelines-task-lib": "^5.1.0", "fs-extra": "^8.1.0" }, "devDependencies": { diff --git a/Tasks/UnityBuild/UnityBuildV3/task.json b/Tasks/UnityBuild/UnityBuildV3/task.json index f941c47..fe07ca9 100644 --- a/Tasks/UnityBuild/UnityBuildV3/task.json +++ b/Tasks/UnityBuild/UnityBuildV3/task.json @@ -379,6 +379,18 @@ { "name": "editorLogFilePath", "description": "Specifies the location of the editor log file generated." + }, + { + "name": "bundleVersion", + "description": "The bundle version of the Unity project after the build." + }, + { + "name": "buildNumber", + "description": "The build number of the Unity project after the build." + }, + { + "name": "gitTag", + "description": "The git tag created for the changeset." } ], "execution": { diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts index ca2bda9..9a7ece0 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts @@ -9,30 +9,30 @@ import { UnityVersionTools, UnityPackageManagerTools, } from "@dinomite-studios/unity-azure-pipelines-tasks-lib"; -import { UnityProjectVersioning } from "./unity-versioning"; - -// Input variables. -const outputFileNameInputVariableName = "outputFileName"; -const buildTargetInputVariableName = "buildTarget"; -const outputPathInputVariableName = "outputPath"; -const unityProjectPathInputVariableName = "unityProjectPath"; -const versionInputVariableName = "version"; -const buildScriptTypeInputVariableName = "buildScriptType"; -const unityEditorsPathModeInputVariableName = "unityEditorsPathMode"; -const inlineBuildScriptInputVariableName = "inlineBuildScript"; -const scriptExecuteMethodInputVariableName = "scriptExecuteMethod"; -const additionalCmdArgsInputVariableName = "additionalCmdArgs"; -const customUnityEditorsPathInputVariableName = "customUnityEditorsPath"; -const cleanBuildInputVariableName = "Build.Repository.Clean"; -const versionSelectionModeVariableName = "versionSelectionMode"; -const signAppBundleInputVariableName = "androidSignAppBundle"; -const keystoreNameInputVariableName = "androidKeystoreName"; -const keystorePassInputVariableName = "androidKeystorePass"; -const keystoreAliasNameInputVariableName = "androidKeystoreAliasName"; -const keystoreAliasPassInputVariableName = "androidKeystoreAliasPass"; -const buildAppBundleInputVariableName = "androidBuildAppBundle"; -const buildFlowInputVariableName = "buildFlow"; -const buildProfileInputVariableName = "buildProfile"; +import { UnityVersioning } from "./unity-versioning"; +import { + outputFileNameInputVariableName, + unityProjectPathInputVariableName, + versionSelectionModeVariableName, + outputPathInputVariableName, + unityEditorsPathModeInputVariableName, + customUnityEditorsPathInputVariableName, + versionInputVariableName, + cleanBuildInputVariableName, + buildFlowInputVariableName, + buildTargetInputVariableName, + buildProfileInputVariableName, + additionalCmdArgsInputVariableName, + buildScriptTypeInputVariableName, + signAppBundleInputVariableName, + keystoreNameInputVariableName, + keystorePassInputVariableName, + keystoreAliasNameInputVariableName, + keystoreAliasPassInputVariableName, + buildAppBundleInputVariableName, + inlineBuildScriptInputVariableName, + scriptExecuteMethodInputVariableName, +} from "./variables"; // Output variables. const editorLogFilePathOutputVariableName = "editorLogFilePath"; @@ -42,7 +42,7 @@ async function run() { // Configure localization. tl.setResourcePath(path.join(__dirname, "task.json")); - const versioningResult = UnityProjectVersioning.run(); + const versioningResult = UnityVersioning.run(); if (versioningResult !== 0) { const log = `${tl.loc("taskResultFailedVersioning")} ${versioningResult}`; console.error(log); diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index b2c745d..d1904c7 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -1,5 +1,202 @@ -export class UnityProjectVersioning { +import tl = require("azure-pipelines-task-lib/task"); +import { + buildTargetInputVariableName, + projectVersioningBuildNumberModeVariableName, + projectVersioningBuildNumberVariableName, + projectVersioningBundleVersionMajorVariableName, + projectVersioningBundleVersionMinorVariableName, + projectVersioningBundleVersionModeVariableName, + projectVersioningBundleVersionPatchVariableName, + projectVersioningCommitChangesUserMailVariableName, + projectVersioningCommitChangesUserNameVariableName, + projectVersioningCommitChangesVariableName, + projectVersioningCreateTagPatternVariableName, + projectVersioningCreateTagVariableName, + unityProjectPathInputVariableName, +} from "./variables"; +import { + SemanticVersion, + UnityVersioningTools, +} from "@dinomite-studios/unity-azure-pipelines-tasks-lib"; +import { BuildPlatform } from "./build-platform"; + +enum VersioningMode { + None = "none", + Increment = "increment", + Set = "set", +} + +export class UnityVersioning { public static run(): number { + const projectPath = + tl.getPathInput(unityProjectPathInputVariableName) ?? ""; + const buildPlatform = tl.getInput(buildTargetInputVariableName, true)!; + + const bundleVersionMode = tl.getInput( + projectVersioningBundleVersionModeVariableName, + true + )!; + + let bundleVersion: SemanticVersion = { + major: 0, + minor: 0, + patch: 0, + }; + + // Does the user want to modify the bundle version? + if (bundleVersionMode !== VersioningMode.None) { + // Read increments / values from the task inputs. + // The bundle version input is either an increment or a value to set. + bundleVersion.major = parseInt( + tl.getInput(projectVersioningBundleVersionMajorVariableName, true)!, + 10 + ); + bundleVersion.minor = parseInt( + tl.getInput(projectVersioningBundleVersionMinorVariableName, true)!, + 10 + ); + bundleVersion.patch = parseInt( + tl.getInput(projectVersioningBundleVersionPatchVariableName, true)!, + 10 + ); + + if (bundleVersionMode === VersioningMode.Increment) { + bundleVersion = UnityVersioningTools.incrementBundleVersion( + projectPath, + bundleVersion + ); + } else if (bundleVersionMode === VersioningMode.Set) { + throw new Error( + "Bundle version mode set is not implemented yet. Please use increment mode." + ); + } else { + throw new Error(`Invalid bundle version mode: ${bundleVersionMode}`); + } + } else { + // By passing 0 increments, we'll essentially just read the current version. + bundleVersion = UnityVersioningTools.incrementBundleVersion( + projectPath, + bundleVersion + ); + } + + const buildNumberMode = tl.getInput( + projectVersioningBuildNumberModeVariableName, + true + )!; + + let buildCode: number = 0; + + // Does the user want to modify the build number? + if (buildNumberMode !== VersioningMode.None) { + // The build number input is either an increment or a value to set. + const buildNumber = parseInt( + tl.getInput(projectVersioningBuildNumberVariableName, true)!, + 10 + ); + + if (buildNumberMode === VersioningMode.Increment) { + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.IOS && + buildPlatform !== BuildPlatform.TVOS && + buildPlatform !== BuildPlatform.Android + ) { + buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { + Standalone: buildNumber, + }).Standalone; + } else if (buildPlatform === BuildPlatform.Android) { + buildCode = UnityVersioningTools.incrementAndroidBundleVersionCode( + projectPath, + buildNumber + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { + VisionOS: buildNumber, + }).VisionOS; + } else if (buildPlatform === BuildPlatform.IOS) { + buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { + iPhone: buildNumber, + }).iPhone; + } else if (buildPlatform === BuildPlatform.TVOS) { + buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { + tvOS: buildNumber, + }).tvOS; + } else { + throw new Error(`Invalid build platform: ${buildPlatform}`); + } + } else if (buildNumberMode === VersioningMode.Set) { + throw new Error( + "Build number mode set is not implemented yet. Please use increment mode." + ); + } else { + throw new Error(`Invalid build number mode: ${buildNumberMode}`); + } + } else { + // By passing 0 increments, we'll essentially just read the current version. + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.IOS && + buildPlatform !== BuildPlatform.TVOS && + buildPlatform !== BuildPlatform.Android + ) { + buildCode = UnityVersioningTools.incrementBuildNumber( + projectPath, + {} + ).Standalone; + } else if (buildPlatform === BuildPlatform.Android) { + buildCode = UnityVersioningTools.incrementAndroidBundleVersionCode( + projectPath, + 0 + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + buildCode = UnityVersioningTools.incrementBuildNumber( + projectPath, + {} + ).VisionOS; + } else if (buildPlatform === BuildPlatform.IOS) { + buildCode = UnityVersioningTools.incrementBuildNumber( + projectPath, + {} + ).iPhone; + } else if (buildPlatform === BuildPlatform.TVOS) { + buildCode = UnityVersioningTools.incrementBuildNumber( + projectPath, + {} + ).tvOS; + } else { + throw new Error(`Invalid build platform: ${buildPlatform}`); + } + } + + const commitChanges = tl.getBoolInput( + projectVersioningCommitChangesVariableName, + true + )!; + + if (commitChanges) { + const commitChangesUserName = tl.getInput( + projectVersioningCommitChangesUserNameVariableName, + true + )!; + const commitChangesUserMail = tl.getInput( + projectVersioningCommitChangesUserMailVariableName, + true + )!; + } + + const createTag = tl.getBoolInput( + projectVersioningCreateTagVariableName, + true + )!; + + if (createTag) { + const createTagPattern = tl.getInput( + projectVersioningCreateTagPatternVariableName, + true + )!; + } + return 0; } } diff --git a/Tasks/UnityBuild/UnityBuildV3/variables.ts b/Tasks/UnityBuild/UnityBuildV3/variables.ts new file mode 100644 index 0000000..67a5863 --- /dev/null +++ b/Tasks/UnityBuild/UnityBuildV3/variables.ts @@ -0,0 +1,44 @@ +// Input variables. +export const outputFileNameInputVariableName = "outputFileName"; +export const buildTargetInputVariableName = "buildTarget"; +export const outputPathInputVariableName = "outputPath"; +export const unityProjectPathInputVariableName = "unityProjectPath"; +export const versionInputVariableName = "version"; +export const buildScriptTypeInputVariableName = "buildScriptType"; +export const unityEditorsPathModeInputVariableName = "unityEditorsPathMode"; +export const inlineBuildScriptInputVariableName = "inlineBuildScript"; +export const scriptExecuteMethodInputVariableName = "scriptExecuteMethod"; +export const additionalCmdArgsInputVariableName = "additionalCmdArgs"; +export const customUnityEditorsPathInputVariableName = "customUnityEditorsPath"; +export const cleanBuildInputVariableName = "Build.Repository.Clean"; +export const versionSelectionModeVariableName = "versionSelectionMode"; +export const signAppBundleInputVariableName = "androidSignAppBundle"; +export const keystoreNameInputVariableName = "androidKeystoreName"; +export const keystorePassInputVariableName = "androidKeystorePass"; +export const keystoreAliasNameInputVariableName = "androidKeystoreAliasName"; +export const keystoreAliasPassInputVariableName = "androidKeystoreAliasPass"; +export const buildAppBundleInputVariableName = "androidBuildAppBundle"; +export const buildFlowInputVariableName = "buildFlow"; +export const buildProfileInputVariableName = "buildProfile"; +export const projectVersioningBundleVersionModeVariableName = + "projectVersioningBundleVersionMode"; +export const projectVersioningBundleVersionMajorVariableName = + "projectVersioningBundleVersionMajor"; +export const projectVersioningBundleVersionMinorVariableName = + "projectVersioningBundleVersionMinor"; +export const projectVersioningBundleVersionPatchVariableName = + "projectVersioningBundleVersionPatch"; +export const projectVersioningBuildNumberModeVariableName = + "projectVersioningBuildNumberMode"; +export const projectVersioningBuildNumberVariableName = + "projectVersioningBuildNumber"; +export const projectVersioningCommitChangesVariableName = + "projectVersioningCommitChanges"; +export const projectVersioningCommitChangesUserNameVariableName = + "projectVersioningCommitChangesUserName"; +export const projectVersioningCommitChangesUserMailVariableName = + "projectVersioningCommitChangesUserMail"; +export const projectVersioningCreateTagVariableName = + "projectVersioningCreateTag"; +export const projectVersioningCreateTagPatternVariableName = + "projectVersioningCreateTagPattern"; diff --git a/Tasks/UnitySetup/UnitySetupV2/variables.ts b/Tasks/UnitySetup/UnitySetupV2/variables.ts index 2ac3253..ccc63a7 100644 --- a/Tasks/UnitySetup/UnitySetupV2/variables.ts +++ b/Tasks/UnitySetup/UnitySetupV2/variables.ts @@ -1,6 +1,3 @@ -import tl = require('azure-pipelines-task-lib/task'); - -// Input variables export const versionSelectionModeVariableName = "versionSelectionMode"; export const versionInputVariableName = 'version'; export const revisionInputVariableName = 'revision'; From 14868f3f632ad5d554427f99e11639320c67cdbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 9 Apr 2025 10:03:10 +0200 Subject: [PATCH 07/23] Set output variables and build tag based on pattern --- Tasks/UnityBuild/UnityBuildV3/unity-build.ts | 4 +-- .../UnityBuildV3/unity-versioning.ts | 31 +++++++++++++++++++ Tasks/UnityBuild/UnityBuildV3/variables.ts | 6 ++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts index 9a7ece0..51d327e 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts @@ -32,11 +32,9 @@ import { buildAppBundleInputVariableName, inlineBuildScriptInputVariableName, scriptExecuteMethodInputVariableName, + editorLogFilePathOutputVariableName, } from "./variables"; -// Output variables. -const editorLogFilePathOutputVariableName = "editorLogFilePath"; - async function run() { try { // Configure localization. diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index d1904c7..98a44b3 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -1,6 +1,9 @@ import tl = require("azure-pipelines-task-lib/task"); import { + buildNumberOutputVariableName, buildTargetInputVariableName, + bundleVersionOutputVariableName, + gitTagOutputVariableName, projectVersioningBuildNumberModeVariableName, projectVersioningBuildNumberVariableName, projectVersioningBundleVersionMajorVariableName, @@ -174,6 +177,9 @@ export class UnityVersioning { true )!; + let gitTag: string | "" = ""; + + // Does the user want to commit changes to the repositoryß if (commitChanges) { const commitChangesUserName = tl.getInput( projectVersioningCommitChangesUserNameVariableName, @@ -190,13 +196,38 @@ export class UnityVersioning { true )!; + // Since we pushed to the repository, does the user also want to create a tag? if (createTag) { const createTagPattern = tl.getInput( projectVersioningCreateTagPatternVariableName, true )!; + + gitTag = createTagPattern.replace( + "{{bundleVersion}}", + `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` + ); + + gitTag = createTagPattern.replace( + "{{buildNumber}}", + buildCode.toString() + ); } + tl.setVariable( + bundleVersionOutputVariableName, + `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`, + false, + true + ); + tl.setVariable( + buildNumberOutputVariableName, + buildCode.toString(), + false, + true + ); + tl.setVariable(gitTagOutputVariableName, gitTag, false, true); + return 0; } } diff --git a/Tasks/UnityBuild/UnityBuildV3/variables.ts b/Tasks/UnityBuild/UnityBuildV3/variables.ts index 67a5863..42e7d3a 100644 --- a/Tasks/UnityBuild/UnityBuildV3/variables.ts +++ b/Tasks/UnityBuild/UnityBuildV3/variables.ts @@ -42,3 +42,9 @@ export const projectVersioningCreateTagVariableName = "projectVersioningCreateTag"; export const projectVersioningCreateTagPatternVariableName = "projectVersioningCreateTagPattern"; + +// Output variables. +export const editorLogFilePathOutputVariableName = "editorLogFilePath"; +export const bundleVersionOutputVariableName = "bundleVersion"; +export const buildNumberOutputVariableName = "buildNumber"; +export const gitTagOutputVariableName = "gitTag"; From ab0ee976dec87067cbd5ef4f0870b15595b97fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 9 Apr 2025 10:07:55 +0200 Subject: [PATCH 08/23] Update lib dependency --- .../UnityBuild/UnityBuildV3/package-lock.json | 61 +++---------------- Tasks/UnityBuild/UnityBuildV3/package.json | 2 +- 2 files changed, 10 insertions(+), 53 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/package-lock.json b/Tasks/UnityBuild/UnityBuildV3/package-lock.json index 667b5e1..215dd15 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package-lock.json +++ b/Tasks/UnityBuild/UnityBuildV3/package-lock.json @@ -9,7 +9,7 @@ "version": "3.4.0", "license": "MIT", "dependencies": { - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.0", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.1", "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", @@ -21,38 +21,16 @@ } }, "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.0.tgz", - "integrity": "sha512-AxAZe66+B9HqHCYNSrcNNndfSRQXhHpmXWbxOQ8BQG+06QxgD7LeXCZvUUI0f3+4G4iV2GAHLfOCatpTf8naQw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.1.tgz", + "integrity": "sha512-u3ue6KZYl8bVPN6v3SkTnSV6QwUYtTLVkZgWIp4bDpx7/oF7NKRkHmRlFrypBT6UNGKdeHm5LX3TxGKQZBxoBg==", "dependencies": { - "azure-pipelines-task-lib": "^4.17.3", + "azure-pipelines-task-lib": "^5.1.0", "sanitize-filename": "^1.6.3", "semver": "^7.7.1", "tail": "^2.2.6" } }, - "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/azure-pipelines-task-lib": { - "version": "4.17.3", - "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-4.17.3.tgz", - "integrity": "sha512-UxfH5pk3uOHTi9TtLtdDyugQVkFES5A836ZEePjcs3jYyxm3EJ6IlFYq6gbfd6mNBhrM9fxG2u/MFYIJ+Z0cxQ==", - "dependencies": { - "adm-zip": "^0.5.10", - "minimatch": "3.0.5", - "nodejs-file-downloader": "^4.11.1", - "q": "^1.5.1", - "semver": "^5.7.2", - "shelljs": "^0.8.5", - "uuid": "^3.0.1" - } - }, - "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/azure-pipelines-task-lib/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "bin": { - "semver": "bin/semver" - } - }, "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib/node_modules/semver": { "version": "7.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", @@ -505,37 +483,16 @@ }, "dependencies": { "@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.0.tgz", - "integrity": "sha512-AxAZe66+B9HqHCYNSrcNNndfSRQXhHpmXWbxOQ8BQG+06QxgD7LeXCZvUUI0f3+4G4iV2GAHLfOCatpTf8naQw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.1.tgz", + "integrity": "sha512-u3ue6KZYl8bVPN6v3SkTnSV6QwUYtTLVkZgWIp4bDpx7/oF7NKRkHmRlFrypBT6UNGKdeHm5LX3TxGKQZBxoBg==", "requires": { - "azure-pipelines-task-lib": "^4.17.3", + "azure-pipelines-task-lib": "^5.1.0", "sanitize-filename": "^1.6.3", "semver": "^7.7.1", "tail": "^2.2.6" }, "dependencies": { - "azure-pipelines-task-lib": { - "version": "4.17.3", - "resolved": "https://registry.npmjs.org/azure-pipelines-task-lib/-/azure-pipelines-task-lib-4.17.3.tgz", - "integrity": "sha512-UxfH5pk3uOHTi9TtLtdDyugQVkFES5A836ZEePjcs3jYyxm3EJ6IlFYq6gbfd6mNBhrM9fxG2u/MFYIJ+Z0cxQ==", - "requires": { - "adm-zip": "^0.5.10", - "minimatch": "3.0.5", - "nodejs-file-downloader": "^4.11.1", - "q": "^1.5.1", - "semver": "^5.7.2", - "shelljs": "^0.8.5", - "uuid": "^3.0.1" - }, - "dependencies": { - "semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==" - } - } - }, "semver": { "version": "7.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", diff --git a/Tasks/UnityBuild/UnityBuildV3/package.json b/Tasks/UnityBuild/UnityBuildV3/package.json index fdf0901..662a552 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package.json +++ b/Tasks/UnityBuild/UnityBuildV3/package.json @@ -21,7 +21,7 @@ "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.0", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.1", "azure-pipelines-task-lib": "^5.1.0", "fs-extra": "^8.1.0" }, From 38f43a95b98e19941ab8a9c3dad69a5e8bb4f266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 9 Apr 2025 11:48:53 +0200 Subject: [PATCH 09/23] Implement versioning --- .../UnityBuild/UnityBuildV3/package-lock.json | 14 ++-- Tasks/UnityBuild/UnityBuildV3/package.json | 2 +- .../UnityBuildV3/unity-versioning.ts | 81 ++++++++++++++++--- 3 files changed, 79 insertions(+), 18 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/package-lock.json b/Tasks/UnityBuild/UnityBuildV3/package-lock.json index 215dd15..4cf154c 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package-lock.json +++ b/Tasks/UnityBuild/UnityBuildV3/package-lock.json @@ -9,7 +9,7 @@ "version": "3.4.0", "license": "MIT", "dependencies": { - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.1", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.2", "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", @@ -21,9 +21,9 @@ } }, "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.1.tgz", - "integrity": "sha512-u3ue6KZYl8bVPN6v3SkTnSV6QwUYtTLVkZgWIp4bDpx7/oF7NKRkHmRlFrypBT6UNGKdeHm5LX3TxGKQZBxoBg==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.2.tgz", + "integrity": "sha512-28TtluLQMWVcpk2OM7oXxuY61yYuUr+aTCKJnmQqrA/F+PtQOf0PuhbeZZAR5bjAmg31ioFyy1qcgPZGGnkgYg==", "dependencies": { "azure-pipelines-task-lib": "^5.1.0", "sanitize-filename": "^1.6.3", @@ -483,9 +483,9 @@ }, "dependencies": { "@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.1.tgz", - "integrity": "sha512-u3ue6KZYl8bVPN6v3SkTnSV6QwUYtTLVkZgWIp4bDpx7/oF7NKRkHmRlFrypBT6UNGKdeHm5LX3TxGKQZBxoBg==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.2.tgz", + "integrity": "sha512-28TtluLQMWVcpk2OM7oXxuY61yYuUr+aTCKJnmQqrA/F+PtQOf0PuhbeZZAR5bjAmg31ioFyy1qcgPZGGnkgYg==", "requires": { "azure-pipelines-task-lib": "^5.1.0", "sanitize-filename": "^1.6.3", diff --git a/Tasks/UnityBuild/UnityBuildV3/package.json b/Tasks/UnityBuild/UnityBuildV3/package.json index 662a552..f3c30c7 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package.json +++ b/Tasks/UnityBuild/UnityBuildV3/package.json @@ -21,7 +21,7 @@ "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.1", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.2", "azure-pipelines-task-lib": "^5.1.0", "fs-extra": "^8.1.0" }, diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 98a44b3..eb13553 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -64,14 +64,49 @@ export class UnityVersioning { ); if (bundleVersionMode === VersioningMode.Increment) { - bundleVersion = UnityVersioningTools.incrementBundleVersion( - projectPath, - bundleVersion - ); + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.TVOS + ) { + bundleVersion = UnityVersioningTools.incrementBundleVersion( + projectPath, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + bundleVersion = UnityVersioningTools.incrementVisionOSBundleVersion( + projectPath, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.TVOS) { + bundleVersion = UnityVersioningTools.incrementTvOSBundleVersion( + projectPath, + bundleVersion + ); + } else { + throw new Error(`Invalid build platform: ${buildPlatform}`); + } } else if (bundleVersionMode === VersioningMode.Set) { - throw new Error( - "Bundle version mode set is not implemented yet. Please use increment mode." - ); + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.TVOS + ) { + bundleVersion = UnityVersioningTools.setBundleVersion( + projectPath, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + bundleVersion = UnityVersioningTools.setVisionOSBundleVersion( + projectPath, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.TVOS) { + bundleVersion = UnityVersioningTools.setTvOSBundleVersion( + projectPath, + bundleVersion + ); + } else { + throw new Error(`Invalid build platform: ${buildPlatform}`); + } } else { throw new Error(`Invalid bundle version mode: ${bundleVersionMode}`); } @@ -129,9 +164,35 @@ export class UnityVersioning { throw new Error(`Invalid build platform: ${buildPlatform}`); } } else if (buildNumberMode === VersioningMode.Set) { - throw new Error( - "Build number mode set is not implemented yet. Please use increment mode." - ); + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.IOS && + buildPlatform !== BuildPlatform.TVOS && + buildPlatform !== BuildPlatform.Android + ) { + buildCode = UnityVersioningTools.setBuildNumber(projectPath, { + Standalone: buildNumber, + }).Standalone; + } else if (buildPlatform === BuildPlatform.Android) { + buildCode = UnityVersioningTools.setAndroidBundleVersionCode( + projectPath, + buildNumber + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + buildCode = UnityVersioningTools.setBuildNumber(projectPath, { + VisionOS: buildNumber, + }).VisionOS; + } else if (buildPlatform === BuildPlatform.IOS) { + buildCode = UnityVersioningTools.setBuildNumber(projectPath, { + iPhone: buildNumber, + }).iPhone; + } else if (buildPlatform === BuildPlatform.TVOS) { + buildCode = UnityVersioningTools.setBuildNumber(projectPath, { + tvOS: buildNumber, + }).tvOS; + } else { + throw new Error(`Invalid build platform: ${buildPlatform}`); + } } else { throw new Error(`Invalid build number mode: ${buildNumberMode}`); } From 6ca5690e4ca09df3fc96a2756cd7bcd591d7efc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 9 Apr 2025 11:53:05 +0200 Subject: [PATCH 10/23] Only create tag if commit was made --- .../UnityBuildV3/unity-versioning.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index eb13553..8a836c5 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -250,29 +250,29 @@ export class UnityVersioning { projectVersioningCommitChangesUserMailVariableName, true )!; - } - const createTag = tl.getBoolInput( - projectVersioningCreateTagVariableName, - true - )!; - - // Since we pushed to the repository, does the user also want to create a tag? - if (createTag) { - const createTagPattern = tl.getInput( - projectVersioningCreateTagPatternVariableName, + const createTag = tl.getBoolInput( + projectVersioningCreateTagVariableName, true )!; - gitTag = createTagPattern.replace( - "{{bundleVersion}}", - `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` - ); + // Since we pushed to the repository, does the user also want to create a tag? + if (createTag) { + const createTagPattern = tl.getInput( + projectVersioningCreateTagPatternVariableName, + true + )!; - gitTag = createTagPattern.replace( - "{{buildNumber}}", - buildCode.toString() - ); + gitTag = createTagPattern.replace( + "{{bundleVersion}}", + `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` + ); + + gitTag = createTagPattern.replace( + "{{buildNumber}}", + buildCode.toString() + ); + } } tl.setVariable( From 3a81688d29c428a876ddee8ff2b35921cd1c2778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 9 Apr 2025 13:04:25 +0200 Subject: [PATCH 11/23] Add git operations --- Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 8a836c5..395c027 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -256,6 +256,11 @@ export class UnityVersioning { true )!; + tl.execSync("git", ["config", "user.name", commitChangesUserName]); + tl.execSync("git", ["config", "user.email", commitChangesUserMail]); + tl.execSync("git", ["add", "."]); + tl.execSync("git", ["commit", "-m Azure Pipelines Build"]); + // Since we pushed to the repository, does the user also want to create a tag? if (createTag) { const createTagPattern = tl.getInput( @@ -272,6 +277,13 @@ export class UnityVersioning { "{{buildNumber}}", buildCode.toString() ); + + tl.execSync("git", ["tag", gitTag]); + } + + tl.execSync("git", ["push", "origin HEAD"]); + if (createTag) { + tl.execSync("git", ["push", "origin", gitTag]); } } From cda0e15b7a9b7606b927b9886d9387e51c3ae63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 9 Apr 2025 18:29:51 +0200 Subject: [PATCH 12/23] Make commit message an input variable --- Tasks/UnityBuild/UnityBuildV3/task.json | 9 +++++++++ .../UnityBuild/UnityBuildV3/unity-versioning.ts | 17 ++++++++++++++++- Tasks/UnityBuild/UnityBuildV3/variables.ts | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/task.json b/Tasks/UnityBuild/UnityBuildV3/task.json index fe07ca9..3434e03 100644 --- a/Tasks/UnityBuild/UnityBuildV3/task.json +++ b/Tasks/UnityBuild/UnityBuildV3/task.json @@ -179,6 +179,15 @@ "helpMarkDown": "The user mail to use when commiting changes.", "visibleRule": "projectVersioningCommitChanges = true" }, + { + "name": "projectVersioningCommitChangesMessage", + "type": "string", + "label": "Commit message", + "groupName": "versioning", + "defaultValue": "Azure Pipelines Build - {{bundleVersion}}", + "helpMarkDown": "The commit message. Valid placeholders are: {{bundleVersion}}, {{buildNumber}}", + "visibleRule": "projectVersioningCommitChanges = true" + }, { "name": "projectVersioningCreateTag", "type": "boolean", diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 395c027..d615f3a 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -10,6 +10,7 @@ import { projectVersioningBundleVersionMinorVariableName, projectVersioningBundleVersionModeVariableName, projectVersioningBundleVersionPatchVariableName, + projectVersioningCommitChangesMessageVariableName, projectVersioningCommitChangesUserMailVariableName, projectVersioningCommitChangesUserNameVariableName, projectVersioningCommitChangesVariableName, @@ -256,10 +257,24 @@ export class UnityVersioning { true )!; + let commitMessage = tl.getInput( + projectVersioningCommitChangesMessageVariableName + )!; + + commitMessage = commitMessage.replace( + "{{bundleVersion}}", + `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` + ); + + commitMessage = commitMessage.replace( + "{{buildNumber}}", + buildCode.toString() + ); + tl.execSync("git", ["config", "user.name", commitChangesUserName]); tl.execSync("git", ["config", "user.email", commitChangesUserMail]); tl.execSync("git", ["add", "."]); - tl.execSync("git", ["commit", "-m Azure Pipelines Build"]); + tl.execSync("git", ["commit", `-m ${commitMessage}`]); // Since we pushed to the repository, does the user also want to create a tag? if (createTag) { diff --git a/Tasks/UnityBuild/UnityBuildV3/variables.ts b/Tasks/UnityBuild/UnityBuildV3/variables.ts index 42e7d3a..6121b9e 100644 --- a/Tasks/UnityBuild/UnityBuildV3/variables.ts +++ b/Tasks/UnityBuild/UnityBuildV3/variables.ts @@ -38,6 +38,8 @@ export const projectVersioningCommitChangesUserNameVariableName = "projectVersioningCommitChangesUserName"; export const projectVersioningCommitChangesUserMailVariableName = "projectVersioningCommitChangesUserMail"; +export const projectVersioningCommitChangesMessageVariableName = + "projectVersioningCommitChangesMessage"; export const projectVersioningCreateTagVariableName = "projectVersioningCreateTag"; export const projectVersioningCreateTagPatternVariableName = From 088982b5ba9d05b090233fa1a8492c9129691bb8 Mon Sep 17 00:00:00 2001 From: Dino Fejzagic Date: Wed, 9 Apr 2025 20:06:54 +0200 Subject: [PATCH 13/23] Use regex to replace placeholders in commit message and git tag --- .../UnityBuildV3/unity-versioning.ts | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index d615f3a..db75b0f 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -261,15 +261,12 @@ export class UnityVersioning { projectVersioningCommitChangesMessageVariableName )!; - commitMessage = commitMessage.replace( - "{{bundleVersion}}", - `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` - ); - - commitMessage = commitMessage.replace( - "{{buildNumber}}", - buildCode.toString() - ); + commitMessage = commitMessage + .replace( + /{{bundleVersion}}/g, + `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` + ) + .replace(/{{buildNumber}}/g, buildCode.toString()); tl.execSync("git", ["config", "user.name", commitChangesUserName]); tl.execSync("git", ["config", "user.email", commitChangesUserMail]); @@ -283,15 +280,12 @@ export class UnityVersioning { true )!; - gitTag = createTagPattern.replace( - "{{bundleVersion}}", - `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` - ); - - gitTag = createTagPattern.replace( - "{{buildNumber}}", - buildCode.toString() - ); + gitTag = createTagPattern + .replace( + /{{bundleVersion}}/g, + `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` + ) + .replace(/{{buildNumber}}/g, buildCode.toString()); tl.execSync("git", ["tag", gitTag]); } From cd5a9ad187705bbf8092e13169d12a7d6bb4c5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 10 Apr 2025 12:10:17 +0200 Subject: [PATCH 14/23] Adjust default commit message to include build number --- Tasks/UnityBuild/UnityBuildV3/task.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/task.json b/Tasks/UnityBuild/UnityBuildV3/task.json index 3434e03..35c5439 100644 --- a/Tasks/UnityBuild/UnityBuildV3/task.json +++ b/Tasks/UnityBuild/UnityBuildV3/task.json @@ -184,7 +184,7 @@ "type": "string", "label": "Commit message", "groupName": "versioning", - "defaultValue": "Azure Pipelines Build - {{bundleVersion}}", + "defaultValue": "Azure Pipelines Build - v{{bundleVersion}} ({{buildNumber}})", "helpMarkDown": "The commit message. Valid placeholders are: {{bundleVersion}}, {{buildNumber}}", "visibleRule": "projectVersioningCommitChanges = true" }, From 168c5e4cd93382ca489cc07f810a8465abc602b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 10 Apr 2025 12:52:42 +0200 Subject: [PATCH 15/23] Split pre and post build steps --- .../UnityBuild/UnityBuildV3/package-lock.json | 14 +- Tasks/UnityBuild/UnityBuildV3/package.json | 2 +- Tasks/UnityBuild/UnityBuildV3/unity-build.ts | 22 +- .../UnityBuildV3/unity-versioning.ts | 280 +++++++++--------- 4 files changed, 172 insertions(+), 146 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/package-lock.json b/Tasks/UnityBuild/UnityBuildV3/package-lock.json index 4cf154c..adc1a0d 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package-lock.json +++ b/Tasks/UnityBuild/UnityBuildV3/package-lock.json @@ -9,7 +9,7 @@ "version": "3.4.0", "license": "MIT", "dependencies": { - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.2", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.3", "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", @@ -21,9 +21,9 @@ } }, "node_modules/@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.2.tgz", - "integrity": "sha512-28TtluLQMWVcpk2OM7oXxuY61yYuUr+aTCKJnmQqrA/F+PtQOf0PuhbeZZAR5bjAmg31ioFyy1qcgPZGGnkgYg==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.3.tgz", + "integrity": "sha512-m8Yazek76eS22cSj/+XvrkcXNz7A+sr0eIHk7FJQEy75bReJ1fU7LQmtYbLnFukuE9/5l+ghXdP6CuNR+ExheA==", "dependencies": { "azure-pipelines-task-lib": "^5.1.0", "sanitize-filename": "^1.6.3", @@ -483,9 +483,9 @@ }, "dependencies": { "@dinomite-studios/unity-azure-pipelines-tasks-lib": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.2.tgz", - "integrity": "sha512-28TtluLQMWVcpk2OM7oXxuY61yYuUr+aTCKJnmQqrA/F+PtQOf0PuhbeZZAR5bjAmg31ioFyy1qcgPZGGnkgYg==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@dinomite-studios/unity-azure-pipelines-tasks-lib/-/unity-azure-pipelines-tasks-lib-1.1.3.tgz", + "integrity": "sha512-m8Yazek76eS22cSj/+XvrkcXNz7A+sr0eIHk7FJQEy75bReJ1fU7LQmtYbLnFukuE9/5l+ghXdP6CuNR+ExheA==", "requires": { "azure-pipelines-task-lib": "^5.1.0", "sanitize-filename": "^1.6.3", diff --git a/Tasks/UnityBuild/UnityBuildV3/package.json b/Tasks/UnityBuild/UnityBuildV3/package.json index f3c30c7..44fcc46 100644 --- a/Tasks/UnityBuild/UnityBuildV3/package.json +++ b/Tasks/UnityBuild/UnityBuildV3/package.json @@ -21,7 +21,7 @@ "@types/fs-extra": "^9.0.6", "@types/node": "^22.9.1", "@types/q": "^1.5.8", - "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.2", + "@dinomite-studios/unity-azure-pipelines-tasks-lib": "^1.1.3", "azure-pipelines-task-lib": "^5.1.0", "fs-extra": "^8.1.0" }, diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts index 51d327e..4256efe 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts @@ -40,9 +40,11 @@ async function run() { // Configure localization. tl.setResourcePath(path.join(__dirname, "task.json")); - const versioningResult = UnityVersioning.run(); - if (versioningResult !== 0) { - const log = `${tl.loc("taskResultFailedVersioning")} ${versioningResult}`; + const versioningPreBuildResult = UnityVersioning.runPreBuild(); + if (versioningPreBuildResult !== 0) { + const log = `${tl.loc( + "taskResultFailedVersioning" + )} ${versioningPreBuildResult}`; console.error(log); tl.setResult(tl.TaskResult.Failed, log); return; @@ -200,6 +202,20 @@ async function run() { const result = await UnityToolRunner.run(unityCmd, logFilePath); + // Only if the project was built successfully, run the post build + // steps of the versioning tool. + if (result === 0) { + const versioningPostBuildResult = UnityVersioning.runPostBuild(); + if (versioningPostBuildResult !== 0) { + const log = `${tl.loc( + "taskResultFailedVersioning" + )} ${versioningPostBuildResult}`; + console.error(log); + tl.setResult(tl.TaskResult.Failed, log); + return; + } + } + // Unity process has finished. Set task result. if (result === 0) { const buildSuccessLog = tl.loc("buildSuccess"); diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index db75b0f..124d944 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -31,7 +31,7 @@ enum VersioningMode { } export class UnityVersioning { - public static run(): number { + public static runPreBuild(): number { const projectPath = tl.getPathInput(unityProjectPathInputVariableName) ?? ""; const buildPlatform = tl.getInput(buildTargetInputVariableName, true)!; @@ -41,14 +41,14 @@ export class UnityVersioning { true )!; - let bundleVersion: SemanticVersion = { - major: 0, - minor: 0, - patch: 0, - }; - // Does the user want to modify the bundle version? if (bundleVersionMode !== VersioningMode.None) { + let bundleVersion: SemanticVersion = { + major: 0, + minor: 0, + patch: 0, + }; + // Read increments / values from the task inputs. // The bundle version input is either an increment or a value to set. bundleVersion.major = parseInt( @@ -64,59 +64,30 @@ export class UnityVersioning { 10 ); - if (bundleVersionMode === VersioningMode.Increment) { - if ( - buildPlatform !== BuildPlatform.VisionOS && - buildPlatform !== BuildPlatform.TVOS - ) { - bundleVersion = UnityVersioningTools.incrementBundleVersion( - projectPath, - bundleVersion - ); - } else if (buildPlatform === BuildPlatform.VisionOS) { - bundleVersion = UnityVersioningTools.incrementVisionOSBundleVersion( - projectPath, - bundleVersion - ); - } else if (buildPlatform === BuildPlatform.TVOS) { - bundleVersion = UnityVersioningTools.incrementTvOSBundleVersion( - projectPath, - bundleVersion - ); - } else { - throw new Error(`Invalid build platform: ${buildPlatform}`); - } - } else if (bundleVersionMode === VersioningMode.Set) { - if ( - buildPlatform !== BuildPlatform.VisionOS && - buildPlatform !== BuildPlatform.TVOS - ) { - bundleVersion = UnityVersioningTools.setBundleVersion( - projectPath, - bundleVersion - ); - } else if (buildPlatform === BuildPlatform.VisionOS) { - bundleVersion = UnityVersioningTools.setVisionOSBundleVersion( - projectPath, - bundleVersion - ); - } else if (buildPlatform === BuildPlatform.TVOS) { - bundleVersion = UnityVersioningTools.setTvOSBundleVersion( - projectPath, - bundleVersion - ); - } else { - throw new Error(`Invalid build platform: ${buildPlatform}`); - } + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.TVOS + ) { + bundleVersion = UnityVersioningTools.updateBundleVersion( + projectPath, + bundleVersionMode === VersioningMode.Increment, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + bundleVersion = UnityVersioningTools.updateVisionOSBundleVersion( + projectPath, + bundleVersionMode === VersioningMode.Increment, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.TVOS) { + bundleVersion = UnityVersioningTools.updateTvOSBundleVersion( + projectPath, + bundleVersionMode === VersioningMode.Increment, + bundleVersion + ); } else { - throw new Error(`Invalid bundle version mode: ${bundleVersionMode}`); + throw new Error(`Invalid build platform: ${buildPlatform}`); } - } else { - // By passing 0 increments, we'll essentially just read the current version. - bundleVersion = UnityVersioningTools.incrementBundleVersion( - projectPath, - bundleVersion - ); } const buildNumberMode = tl.getInput( @@ -124,8 +95,6 @@ export class UnityVersioning { true )!; - let buildCode: number = 0; - // Does the user want to modify the build number? if (buildNumberMode !== VersioningMode.None) { // The build number input is either an increment or a value to set. @@ -134,106 +103,147 @@ export class UnityVersioning { 10 ); - if (buildNumberMode === VersioningMode.Increment) { - if ( - buildPlatform !== BuildPlatform.VisionOS && - buildPlatform !== BuildPlatform.IOS && - buildPlatform !== BuildPlatform.TVOS && - buildPlatform !== BuildPlatform.Android - ) { - buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { - Standalone: buildNumber, - }).Standalone; - } else if (buildPlatform === BuildPlatform.Android) { - buildCode = UnityVersioningTools.incrementAndroidBundleVersionCode( - projectPath, - buildNumber - ); - } else if (buildPlatform === BuildPlatform.VisionOS) { - buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { - VisionOS: buildNumber, - }).VisionOS; - } else if (buildPlatform === BuildPlatform.IOS) { - buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { - iPhone: buildNumber, - }).iPhone; - } else if (buildPlatform === BuildPlatform.TVOS) { - buildCode = UnityVersioningTools.incrementBuildNumber(projectPath, { - tvOS: buildNumber, - }).tvOS; - } else { - throw new Error(`Invalid build platform: ${buildPlatform}`); - } - } else if (buildNumberMode === VersioningMode.Set) { - if ( - buildPlatform !== BuildPlatform.VisionOS && - buildPlatform !== BuildPlatform.IOS && - buildPlatform !== BuildPlatform.TVOS && - buildPlatform !== BuildPlatform.Android - ) { - buildCode = UnityVersioningTools.setBuildNumber(projectPath, { - Standalone: buildNumber, - }).Standalone; - } else if (buildPlatform === BuildPlatform.Android) { - buildCode = UnityVersioningTools.setAndroidBundleVersionCode( - projectPath, - buildNumber - ); - } else if (buildPlatform === BuildPlatform.VisionOS) { - buildCode = UnityVersioningTools.setBuildNumber(projectPath, { - VisionOS: buildNumber, - }).VisionOS; - } else if (buildPlatform === BuildPlatform.IOS) { - buildCode = UnityVersioningTools.setBuildNumber(projectPath, { - iPhone: buildNumber, - }).iPhone; - } else if (buildPlatform === BuildPlatform.TVOS) { - buildCode = UnityVersioningTools.setBuildNumber(projectPath, { - tvOS: buildNumber, - }).tvOS; - } else { - throw new Error(`Invalid build platform: ${buildPlatform}`); - } - } else { - throw new Error(`Invalid build number mode: ${buildNumberMode}`); - } - } else { - // By passing 0 increments, we'll essentially just read the current version. if ( buildPlatform !== BuildPlatform.VisionOS && buildPlatform !== BuildPlatform.IOS && buildPlatform !== BuildPlatform.TVOS && buildPlatform !== BuildPlatform.Android ) { - buildCode = UnityVersioningTools.incrementBuildNumber( + UnityVersioningTools.updateBuildNumber( projectPath, - {} + buildNumberMode === VersioningMode.Increment, + { + Standalone: buildNumber, + } ).Standalone; } else if (buildPlatform === BuildPlatform.Android) { - buildCode = UnityVersioningTools.incrementAndroidBundleVersionCode( + UnityVersioningTools.updateAndroidBundleVersionCode( projectPath, - 0 + buildNumberMode === VersioningMode.Increment, + buildNumber ); } else if (buildPlatform === BuildPlatform.VisionOS) { - buildCode = UnityVersioningTools.incrementBuildNumber( + UnityVersioningTools.updateBuildNumber( projectPath, - {} + buildNumberMode === VersioningMode.Increment, + { + VisionOS: buildNumber, + } ).VisionOS; } else if (buildPlatform === BuildPlatform.IOS) { - buildCode = UnityVersioningTools.incrementBuildNumber( + UnityVersioningTools.updateBuildNumber( projectPath, - {} + buildNumberMode === VersioningMode.Increment, + { + iPhone: buildNumber, + } ).iPhone; } else if (buildPlatform === BuildPlatform.TVOS) { - buildCode = UnityVersioningTools.incrementBuildNumber( + UnityVersioningTools.updateBuildNumber( projectPath, - {} + buildNumberMode === VersioningMode.Increment, + { + tvOS: buildNumber, + } ).tvOS; } else { throw new Error(`Invalid build platform: ${buildPlatform}`); } } + return 0; + } + + public static runPostBuild(): number { + const projectPath = + tl.getPathInput(unityProjectPathInputVariableName) ?? ""; + const buildPlatform = tl.getInput(buildTargetInputVariableName, true)!; + + const bundleVersionMode = tl.getInput( + projectVersioningBundleVersionModeVariableName, + true + )!; + + const buildNumberMode = tl.getInput( + projectVersioningBuildNumberModeVariableName, + true + )!; + + // We did neither update the bundle version nor the build number in this run, + // so we can stop here and consider things a success. + if ( + bundleVersionMode === VersioningMode.None && + buildNumberMode === VersioningMode.None + ) { + return 0; + } + + let bundleVersion: SemanticVersion = { + major: 0, + minor: 0, + patch: 0, + }; + + // By passing 0 increment, we'll essentially just read the current version. + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.TVOS + ) { + bundleVersion = UnityVersioningTools.updateBundleVersion( + projectPath, + true, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + bundleVersion = UnityVersioningTools.updateVisionOSBundleVersion( + projectPath, + true, + bundleVersion + ); + } else if (buildPlatform === BuildPlatform.TVOS) { + bundleVersion = UnityVersioningTools.updateTvOSBundleVersion( + projectPath, + true, + bundleVersion + ); + } else { + throw new Error(`Invalid build platform: ${buildPlatform}`); + } + + let buildCode: number = 0; + + // By passing 0 increment, we'll essentially just read the current build number. + if ( + buildPlatform !== BuildPlatform.VisionOS && + buildPlatform !== BuildPlatform.IOS && + buildPlatform !== BuildPlatform.TVOS && + buildPlatform !== BuildPlatform.Android + ) { + buildCode = UnityVersioningTools.updateBuildNumber(projectPath, true, { + Standalone: 0, + }).Standalone; + } else if (buildPlatform === BuildPlatform.Android) { + buildCode = UnityVersioningTools.updateAndroidBundleVersionCode( + projectPath, + true, + 0 + ); + } else if (buildPlatform === BuildPlatform.VisionOS) { + buildCode = UnityVersioningTools.updateBuildNumber(projectPath, true, { + VisionOS: 0, + }).VisionOS; + } else if (buildPlatform === BuildPlatform.IOS) { + buildCode = UnityVersioningTools.updateBuildNumber(projectPath, true, { + iPhone: 0, + }).iPhone; + } else if (buildPlatform === BuildPlatform.TVOS) { + buildCode = UnityVersioningTools.updateBuildNumber(projectPath, true, { + tvOS: 0, + }).tvOS; + } else { + throw new Error(`Invalid build platform: ${buildPlatform}`); + } + const commitChanges = tl.getBoolInput( projectVersioningCommitChangesVariableName, true From 739ac648c9e838e5cc477ab72dd9ecdace885794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 10 Apr 2025 12:55:35 +0200 Subject: [PATCH 16/23] Remove duplciate code --- .../UnityBuildV3/unity-versioning.ts | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 124d944..59e2675 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -271,12 +271,11 @@ export class UnityVersioning { projectVersioningCommitChangesMessageVariableName )!; - commitMessage = commitMessage - .replace( - /{{bundleVersion}}/g, - `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` - ) - .replace(/{{buildNumber}}/g, buildCode.toString()); + commitMessage = this.replacePlaceholders( + commitMessage, + bundleVersion, + buildCode + ); tl.execSync("git", ["config", "user.name", commitChangesUserName]); tl.execSync("git", ["config", "user.email", commitChangesUserMail]); @@ -290,12 +289,11 @@ export class UnityVersioning { true )!; - gitTag = createTagPattern - .replace( - /{{bundleVersion}}/g, - `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` - ) - .replace(/{{buildNumber}}/g, buildCode.toString()); + gitTag = this.replacePlaceholders( + createTagPattern, + bundleVersion, + buildCode + ); tl.execSync("git", ["tag", gitTag]); } @@ -322,4 +320,17 @@ export class UnityVersioning { return 0; } + + private static replacePlaceholders( + input: string, + bundleVersion: SemanticVersion, + buildCode: number + ): string { + return input + .replace( + /{{bundleVersion}}/g, + `${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}` + ) + .replace(/{{buildNumber}}/g, buildCode.toString()); + } } From c501370c921769ba93b478290240ed0d87b9a149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 10 Apr 2025 13:36:39 +0200 Subject: [PATCH 17/23] Make sure to push to source branch and not empty HEAD --- Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 59e2675..bbdfd61 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -277,6 +277,14 @@ export class UnityVersioning { buildCode ); + // Since Azure Pipelines will by default to a shallow clone + // we must first explicitly switch to the source branch prior to commiting + // changes and pushing. + const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; + tl.execSync("git", ["fetch", `origin ${sourceBranchName}`]); + tl.execSync("git", ["checkout", sourceBranchName]); + + // Now we can commit the changes. tl.execSync("git", ["config", "user.name", commitChangesUserName]); tl.execSync("git", ["config", "user.email", commitChangesUserMail]); tl.execSync("git", ["add", "."]); @@ -298,6 +306,7 @@ export class UnityVersioning { tl.execSync("git", ["tag", gitTag]); } + // Finally push the changeset and tag, if created. tl.execSync("git", ["push", "origin HEAD"]); if (createTag) { tl.execSync("git", ["push", "origin", gitTag]); From ceda8280767abb0bd314f07643ffeb431c81fa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 10 Apr 2025 15:23:35 +0200 Subject: [PATCH 18/23] Fix git command args --- Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index bbdfd61..14509b4 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -281,7 +281,7 @@ export class UnityVersioning { // we must first explicitly switch to the source branch prior to commiting // changes and pushing. const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; - tl.execSync("git", ["fetch", `origin ${sourceBranchName}`]); + tl.execSync("git", ["fetch", "origin", sourceBranchName]); tl.execSync("git", ["checkout", sourceBranchName]); // Now we can commit the changes. @@ -307,7 +307,7 @@ export class UnityVersioning { } // Finally push the changeset and tag, if created. - tl.execSync("git", ["push", "origin HEAD"]); + tl.execSync("git", ["push", "origin", sourceBranchName]); if (createTag) { tl.execSync("git", ["push", "origin", gitTag]); } From 4a556b49a7e7beefd9e143b62128c76bc70f453a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 10 Apr 2025 17:16:08 +0200 Subject: [PATCH 19/23] Use switch command instead of fetch + checkout --- Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 14509b4..3a4afc5 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -251,7 +251,7 @@ export class UnityVersioning { let gitTag: string | "" = ""; - // Does the user want to commit changes to the repositoryß + // Does the user want to commit changes to the repository? if (commitChanges) { const commitChangesUserName = tl.getInput( projectVersioningCommitChangesUserNameVariableName, @@ -277,12 +277,11 @@ export class UnityVersioning { buildCode ); - // Since Azure Pipelines will by default to a shallow clone + // Since Azure Pipelines will by default do a shallow clone // we must first explicitly switch to the source branch prior to commiting // changes and pushing. const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; - tl.execSync("git", ["fetch", "origin", sourceBranchName]); - tl.execSync("git", ["checkout", sourceBranchName]); + tl.execSync("git", ["switch", sourceBranchName]); // Now we can commit the changes. tl.execSync("git", ["config", "user.name", commitChangesUserName]); From 696d21f44645b2ade9ba915092a3dc2528d140a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Thu, 10 Apr 2025 22:24:04 +0200 Subject: [PATCH 20/23] Make sure to swtitch branch before making changes --- .../UnityBuildV3/unity-build-project.ts | 222 +++++++++++++++++ Tasks/UnityBuild/UnityBuildV3/unity-build.ts | 223 +----------------- .../UnityBuildV3/unity-versioning.ts | 31 ++- 3 files changed, 248 insertions(+), 228 deletions(-) create mode 100644 Tasks/UnityBuild/UnityBuildV3/unity-build-project.ts diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-build-project.ts b/Tasks/UnityBuild/UnityBuildV3/unity-build-project.ts new file mode 100644 index 0000000..86d9b42 --- /dev/null +++ b/Tasks/UnityBuild/UnityBuildV3/unity-build-project.ts @@ -0,0 +1,222 @@ +import { + UnityToolRunner, + UnityPathTools, + UnityVersionInfoResult, + Utilities, + UnityPackageManagerTools, + UnityVersionTools, +} from "@dinomite-studios/unity-azure-pipelines-tasks-lib"; +import fs = require("fs-extra"); +import tl = require("azure-pipelines-task-lib/task"); +import path = require("path"); +import { + outputFileNameInputVariableName, + unityProjectPathInputVariableName, + versionSelectionModeVariableName, + outputPathInputVariableName, + unityEditorsPathModeInputVariableName, + customUnityEditorsPathInputVariableName, + versionInputVariableName, + cleanBuildInputVariableName, + buildFlowInputVariableName, + buildTargetInputVariableName, + buildProfileInputVariableName, + additionalCmdArgsInputVariableName, + buildScriptTypeInputVariableName, + signAppBundleInputVariableName, + keystoreNameInputVariableName, + keystorePassInputVariableName, + keystoreAliasNameInputVariableName, + keystoreAliasPassInputVariableName, + buildAppBundleInputVariableName, + inlineBuildScriptInputVariableName, + scriptExecuteMethodInputVariableName, + editorLogFilePathOutputVariableName, +} from "./variables"; + +export class UnityBuildProject { + public static async run(): Promise { + // Setup and read inputs. + const outputFileName = + tl.getInput(outputFileNameInputVariableName) ?? "drop"; + const projectPath = + tl.getPathInput(unityProjectPathInputVariableName) ?? ""; + const versionSelectionMode = tl.getInput( + versionSelectionModeVariableName, + true + )!; + const outputPath = tl.getPathInput(outputPathInputVariableName) ?? ""; + const unityEditorsPath = UnityPathTools.getUnityEditorsPath( + tl.getInput(unityEditorsPathModeInputVariableName, true)!, + tl.getInput(customUnityEditorsPathInputVariableName) + ); + + let unityVersion: UnityVersionInfoResult; + if (versionSelectionMode === "specify") { + let customVersion = tl.getInput(versionInputVariableName, true)!; + unityVersion = { + info: { + isAlpha: false, + isBeta: false, + version: customVersion, + revision: undefined, + }, + error: undefined, + }; + } else { + unityVersion = getUnityEditorVersion(); + } + + const unityExecutablePath = UnityPathTools.getUnityExecutableFullPath( + unityEditorsPath, + unityVersion.info! + ); + const cleanBuild = tl.getVariable(cleanBuildInputVariableName); + + // Set output variable values. + const logFilesDirectory = path.join( + tl.getVariable("Agent.TempDirectory")!, + "Logs" + ); + const logFilePath = path.join( + logFilesDirectory, + `UnityBuildLog_${Utilities.getLogFileNameTimeStamp()}.log` + ); + tl.setVariable(editorLogFilePathOutputVariableName, logFilePath); + + // If clean was specified by the user, delete the existing output directory, if it exists + if (cleanBuild === "true") { + fs.removeSync(outputPath); + } + + // No matter if clean build or not, make sure the output diretory exists + tl.mkdirP(outputPath); + tl.checkPath(outputPath, "Build Output Directory"); + + // Execute Unity command line. + const buildFlow = tl.getInput(buildFlowInputVariableName) ?? "platform"; + const unityCmd = tl + .tool(unityExecutablePath) + .arg("-batchmode") + .arg(buildFlow === "platform" ? "-buildTarget" : "-activeBuildProfile") + .arg( + tl.getInput( + buildFlow === "platform" + ? buildTargetInputVariableName + : buildProfileInputVariableName, + true + )! + ) + .arg("-projectPath") + .arg(projectPath) + .arg("-logfile") + .arg(logFilePath); + + const additionalArgs = + tl.getInput(additionalCmdArgsInputVariableName) ?? ""; + if (additionalArgs !== "") { + unityCmd.line(additionalArgs); + } + + // Perform setup depending on build script type selected + const buildScriptType = + tl.getInput(buildScriptTypeInputVariableName) ?? "default"; + + if (buildScriptType === "default") { + // When using default build scripts we rely on a Utility package being installed to the project via the Unity Package Manager. + // By adding it to the manifest before opening the project, Unity will load the package before trying to build the project. + UnityPackageManagerTools.addPackageToProject( + projectPath, + "games.dinomite.azurepipelines", + "https://github.com/Dinomite-Studios/games.dinomite.azurepipelines.git#v1.0.14" + ); + unityCmd.arg("-executeMethod").arg("AzurePipelinesBuild.PerformBuild"); + unityCmd.arg("-outputFileName").arg(outputFileName); + unityCmd.arg("-outputPath").arg(outputPath); + + if (tl.getBoolInput(signAppBundleInputVariableName)) { + unityCmd + .arg("-keystoreName") + .arg(tl.getPathInput(keystoreNameInputVariableName) ?? ""); + unityCmd + .arg("-keystorePass") + .arg(tl.getInput(keystorePassInputVariableName) ?? ""); + unityCmd + .arg("-keystoreAliasName") + .arg(tl.getInput(keystoreAliasNameInputVariableName) ?? ""); + + // The alias password is optional and should only be passed, if not empty or undefined. + const keystoreAliasPass = + tl.getInput(keystoreAliasPassInputVariableName) ?? ""; + if (keystoreAliasPass) { + unityCmd.arg("-keystoreAliasPass").arg(keystoreAliasPass); + } + } + + if (tl.getBoolInput(buildAppBundleInputVariableName)) { + unityCmd.arg("-buildAppBundle"); + } + } else if (buildScriptType === "inline") { + // Create a C# script file in a Editor folder at the root Assets directory level. Then write + // the default or the user's script into it. Unity will then compile it on launch and make sure it's available. + const projectAssetsEditorFolderPath = path.join( + `${projectPath}`, + "Assets", + "Editor" + ); + tl.mkdirP(projectAssetsEditorFolderPath); + tl.cd(projectAssetsEditorFolderPath); + tl.writeFile( + "AzureDevOps.cs", + tl.getInput(inlineBuildScriptInputVariableName)! + ); + tl.cd(projectPath); + + // Tell Unity which method to execute for build. + unityCmd + .arg("-executeMethod") + .arg(tl.getInput(scriptExecuteMethodInputVariableName)!); + } else if (buildScriptType === "existing") { + // If the user already has an existing build script we only need the method to execute. + unityCmd + .arg("-executeMethod") + .arg(tl.getInput(scriptExecuteMethodInputVariableName)!) + .arg("-quit"); + } else { + throw `Unsupported build script type ${buildScriptType}`; + } + + const result = await UnityToolRunner.run(unityCmd, logFilePath); + return result; + } +} + +function getUnityEditorVersion(): UnityVersionInfoResult { + const projectPath = tl.getPathInput("unityProjectPath") ?? ""; + console.log(`${tl.loc("projectPathInfo")} ${projectPath}`); + + const unityVersion = + UnityVersionTools.determineProjectVersionFromFile(projectPath); + if (unityVersion.error) { + const error = `${tl.loc("failGetUnityEditorVersion")} | ${ + unityVersion.error + }`; + console.error(error); + throw new Error(error); + } + + const successGetVersionLog = `${tl.loc("successGetUnityEditorVersion")} ${ + unityVersion.info!.version + }${ + unityVersion.info!.revision + ? `, revision=${unityVersion.info!.revision}` + : "" + }, alpha=${unityVersion.info!.isAlpha}, beta=${unityVersion.info!.isBeta}`; + console.log(successGetVersionLog); + + if (unityVersion.info!.isAlpha || unityVersion.info!.isBeta) { + console.warn(tl.loc("warningAlphaBetaVersion")); + } + + return unityVersion; +} diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts index 4256efe..34ba77c 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts @@ -1,39 +1,7 @@ import path = require("path"); import tl = require("azure-pipelines-task-lib/task"); -import fs = require("fs-extra"); -import { - UnityToolRunner, - UnityPathTools, - UnityVersionInfoResult, - Utilities, - UnityVersionTools, - UnityPackageManagerTools, -} from "@dinomite-studios/unity-azure-pipelines-tasks-lib"; import { UnityVersioning } from "./unity-versioning"; -import { - outputFileNameInputVariableName, - unityProjectPathInputVariableName, - versionSelectionModeVariableName, - outputPathInputVariableName, - unityEditorsPathModeInputVariableName, - customUnityEditorsPathInputVariableName, - versionInputVariableName, - cleanBuildInputVariableName, - buildFlowInputVariableName, - buildTargetInputVariableName, - buildProfileInputVariableName, - additionalCmdArgsInputVariableName, - buildScriptTypeInputVariableName, - signAppBundleInputVariableName, - keystoreNameInputVariableName, - keystorePassInputVariableName, - keystoreAliasNameInputVariableName, - keystoreAliasPassInputVariableName, - buildAppBundleInputVariableName, - inlineBuildScriptInputVariableName, - scriptExecuteMethodInputVariableName, - editorLogFilePathOutputVariableName, -} from "./variables"; +import { UnityBuildProject } from "./unity-build-project"; async function run() { try { @@ -50,161 +18,12 @@ async function run() { return; } - // Setup and read inputs. - const outputFileName = - tl.getInput(outputFileNameInputVariableName) ?? "drop"; - const projectPath = - tl.getPathInput(unityProjectPathInputVariableName) ?? ""; - const versionSelectionMode = tl.getInput( - versionSelectionModeVariableName, - true - )!; - const outputPath = tl.getPathInput(outputPathInputVariableName) ?? ""; - const unityEditorsPath = UnityPathTools.getUnityEditorsPath( - tl.getInput(unityEditorsPathModeInputVariableName, true)!, - tl.getInput(customUnityEditorsPathInputVariableName) - ); - - let unityVersion: UnityVersionInfoResult; - if (versionSelectionMode === "specify") { - let customVersion = tl.getInput(versionInputVariableName, true)!; - unityVersion = { - info: { - isAlpha: false, - isBeta: false, - version: customVersion, - revision: undefined, - }, - error: undefined, - }; - } else { - unityVersion = getUnityEditorVersion(); - } - - const unityExecutablePath = UnityPathTools.getUnityExecutableFullPath( - unityEditorsPath, - unityVersion.info! - ); - const cleanBuild = tl.getVariable(cleanBuildInputVariableName); - - // Set output variable values. - const logFilesDirectory = path.join( - tl.getVariable("Agent.TempDirectory")!, - "Logs" - ); - const logFilePath = path.join( - logFilesDirectory, - `UnityBuildLog_${Utilities.getLogFileNameTimeStamp()}.log` - ); - tl.setVariable(editorLogFilePathOutputVariableName, logFilePath); - - // If clean was specified by the user, delete the existing output directory, if it exists - if (cleanBuild === "true") { - fs.removeSync(outputPath); - } - - // No matter if clean build or not, make sure the output diretory exists - tl.mkdirP(outputPath); - tl.checkPath(outputPath, "Build Output Directory"); - - // Execute Unity command line. - const buildFlow = tl.getInput(buildFlowInputVariableName) ?? "platform"; - const unityCmd = tl - .tool(unityExecutablePath) - .arg("-batchmode") - .arg(buildFlow === "platform" ? "-buildTarget" : "-activeBuildProfile") - .arg( - tl.getInput( - buildFlow === "platform" - ? buildTargetInputVariableName - : buildProfileInputVariableName, - true - )! - ) - .arg("-projectPath") - .arg(projectPath) - .arg("-logfile") - .arg(logFilePath); - - const additionalArgs = - tl.getInput(additionalCmdArgsInputVariableName) ?? ""; - if (additionalArgs !== "") { - unityCmd.line(additionalArgs); - } - - // Perform setup depending on build script type selected - const buildScriptType = - tl.getInput(buildScriptTypeInputVariableName) ?? "default"; - - if (buildScriptType === "default") { - // When using default build scripts we rely on a Utility package being installed to the project via the Unity Package Manager. - // By adding it to the manifest before opening the project, Unity will load the package before trying to build the project. - UnityPackageManagerTools.addPackageToProject( - projectPath, - "games.dinomite.azurepipelines", - "https://github.com/Dinomite-Studios/games.dinomite.azurepipelines.git#v1.0.14" - ); - unityCmd.arg("-executeMethod").arg("AzurePipelinesBuild.PerformBuild"); - unityCmd.arg("-outputFileName").arg(outputFileName); - unityCmd.arg("-outputPath").arg(outputPath); - - if (tl.getBoolInput(signAppBundleInputVariableName)) { - unityCmd - .arg("-keystoreName") - .arg(tl.getPathInput(keystoreNameInputVariableName) ?? ""); - unityCmd - .arg("-keystorePass") - .arg(tl.getInput(keystorePassInputVariableName) ?? ""); - unityCmd - .arg("-keystoreAliasName") - .arg(tl.getInput(keystoreAliasNameInputVariableName) ?? ""); - - // The alias password is optional and should only be passed, if not empty or undefined. - const keystoreAliasPass = - tl.getInput(keystoreAliasPassInputVariableName) ?? ""; - if (keystoreAliasPass) { - unityCmd.arg("-keystoreAliasPass").arg(keystoreAliasPass); - } - } - - if (tl.getBoolInput(buildAppBundleInputVariableName)) { - unityCmd.arg("-buildAppBundle"); - } - } else if (buildScriptType === "inline") { - // Create a C# script file in a Editor folder at the root Assets directory level. Then write - // the default or the user's script into it. Unity will then compile it on launch and make sure it's available. - const projectAssetsEditorFolderPath = path.join( - `${projectPath}`, - "Assets", - "Editor" - ); - tl.mkdirP(projectAssetsEditorFolderPath); - tl.cd(projectAssetsEditorFolderPath); - tl.writeFile( - "AzureDevOps.cs", - tl.getInput(inlineBuildScriptInputVariableName)! - ); - tl.cd(projectPath); - - // Tell Unity which method to execute for build. - unityCmd - .arg("-executeMethod") - .arg(tl.getInput(scriptExecuteMethodInputVariableName)!); - } else if (buildScriptType === "existing") { - // If the user already has an existing build script we only need the method to execute. - unityCmd - .arg("-executeMethod") - .arg(tl.getInput(scriptExecuteMethodInputVariableName)!) - .arg("-quit"); - } else { - throw `Unsupported build script type ${buildScriptType}`; - } - - const result = await UnityToolRunner.run(unityCmd, logFilePath); + // const buildProjectResult = await UnityBuildProject.run(); + const buildProjectResult = 0; // Only if the project was built successfully, run the post build // steps of the versioning tool. - if (result === 0) { + if (buildProjectResult === 0) { const versioningPostBuildResult = UnityVersioning.runPostBuild(); if (versioningPostBuildResult !== 0) { const log = `${tl.loc( @@ -217,12 +36,12 @@ async function run() { } // Unity process has finished. Set task result. - if (result === 0) { + if (buildProjectResult === 0) { const buildSuccessLog = tl.loc("buildSuccess"); console.log(buildSuccessLog); tl.setResult(tl.TaskResult.Succeeded, buildSuccessLog); } else { - const buildFailLog = `${tl.loc("buildFailed")} ${result}`; + const buildFailLog = `${tl.loc("buildFailed")} ${buildProjectResult}`; console.log(buildFailLog); tl.setResult(tl.TaskResult.Failed, buildFailLog); } @@ -237,34 +56,4 @@ async function run() { } } -function getUnityEditorVersion(): UnityVersionInfoResult { - const projectPath = tl.getPathInput("unityProjectPath") ?? ""; - console.log(`${tl.loc("projectPathInfo")} ${projectPath}`); - - const unityVersion = - UnityVersionTools.determineProjectVersionFromFile(projectPath); - if (unityVersion.error) { - const error = `${tl.loc("failGetUnityEditorVersion")} | ${ - unityVersion.error - }`; - console.error(error); - throw new Error(error); - } - - const successGetVersionLog = `${tl.loc("successGetUnityEditorVersion")} ${ - unityVersion.info!.version - }${ - unityVersion.info!.revision - ? `, revision=${unityVersion.info!.revision}` - : "" - }, alpha=${unityVersion.info!.isAlpha}, beta=${unityVersion.info!.isBeta}`; - console.log(successGetVersionLog); - - if (unityVersion.info!.isAlpha || unityVersion.info!.isBeta) { - console.warn(tl.loc("warningAlphaBetaVersion")); - } - - return unityVersion; -} - run(); diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 3a4afc5..4e9c8f3 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -41,6 +41,25 @@ export class UnityVersioning { true )!; + const buildNumberMode = tl.getInput( + projectVersioningBuildNumberModeVariableName, + true + )!; + + // Are we going to modify anything at all? + if ( + bundleVersionMode !== VersioningMode.None || + buildNumberMode !== VersioningMode.None + ) { + // ... if yes, then we must make sure the git checkout + // is in the right state to handle our changes. Azure Pipelines + // will be default do a shallow clone and leave us with an unattached + // HEAD state. So we must make sure to switch to the source branch before + // making any changes to the repository. + const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; + tl.execSync("git", ["switch", sourceBranchName]); + } + // Does the user want to modify the bundle version? if (bundleVersionMode !== VersioningMode.None) { let bundleVersion: SemanticVersion = { @@ -90,11 +109,6 @@ export class UnityVersioning { } } - const buildNumberMode = tl.getInput( - projectVersioningBuildNumberModeVariableName, - true - )!; - // Does the user want to modify the build number? if (buildNumberMode !== VersioningMode.None) { // The build number input is either an increment or a value to set. @@ -277,12 +291,6 @@ export class UnityVersioning { buildCode ); - // Since Azure Pipelines will by default do a shallow clone - // we must first explicitly switch to the source branch prior to commiting - // changes and pushing. - const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; - tl.execSync("git", ["switch", sourceBranchName]); - // Now we can commit the changes. tl.execSync("git", ["config", "user.name", commitChangesUserName]); tl.execSync("git", ["config", "user.email", commitChangesUserMail]); @@ -306,6 +314,7 @@ export class UnityVersioning { } // Finally push the changeset and tag, if created. + const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; tl.execSync("git", ["push", "origin", sourceBranchName]); if (createTag) { tl.execSync("git", ["push", "origin", gitTag]); From c03b6d4094dfdcee6de397aadb7ff930f16d2144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Fri, 11 Apr 2025 06:47:19 +0200 Subject: [PATCH 21/23] Fix missing -c arg on switch, only commit changes to project settings --- Tasks/UnityBuild/UnityBuildV3/unity-build.ts | 3 +-- Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts index 34ba77c..e41514a 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-build.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-build.ts @@ -18,8 +18,7 @@ async function run() { return; } - // const buildProjectResult = await UnityBuildProject.run(); - const buildProjectResult = 0; + const buildProjectResult = await UnityBuildProject.run(); // Only if the project was built successfully, run the post build // steps of the versioning tool. diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 4e9c8f3..8684f1f 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -23,6 +23,7 @@ import { UnityVersioningTools, } from "@dinomite-studios/unity-azure-pipelines-tasks-lib"; import { BuildPlatform } from "./build-platform"; +import path = require("path"); enum VersioningMode { None = "none", @@ -57,7 +58,7 @@ export class UnityVersioning { // HEAD state. So we must make sure to switch to the source branch before // making any changes to the repository. const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; - tl.execSync("git", ["switch", sourceBranchName]); + tl.execSync("git", ["switch", "-c", sourceBranchName]); } // Does the user want to modify the bundle version? @@ -294,7 +295,10 @@ export class UnityVersioning { // Now we can commit the changes. tl.execSync("git", ["config", "user.name", commitChangesUserName]); tl.execSync("git", ["config", "user.email", commitChangesUserMail]); - tl.execSync("git", ["add", "."]); + tl.execSync("git", [ + "add", + path.join(projectPath, "ProjectSettings", "ProjectSettings.asset"), + ]); tl.execSync("git", ["commit", `-m ${commitMessage}`]); // Since we pushed to the repository, does the user also want to create a tag? From c57b60d2b9ae3a7d55f501b27cfec0166acd1f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Fri, 11 Apr 2025 07:50:19 +0200 Subject: [PATCH 22/23] Feature complete --- Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index 8684f1f..d35d038 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -58,7 +58,8 @@ export class UnityVersioning { // HEAD state. So we must make sure to switch to the source branch before // making any changes to the repository. const sourceBranchName = tl.getVariable("Build.SourceBranchName")!; - tl.execSync("git", ["switch", "-c", sourceBranchName]); + tl.execSync("git", ["branch", "-f", sourceBranchName]); + tl.execSync("git", ["switch", sourceBranchName]); } // Does the user want to modify the bundle version? From 4bb5ad5dbd4f18ddf09d0267167a0778ae1abc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Fri, 11 Apr 2025 09:28:21 +0200 Subject: [PATCH 23/23] Ensure we add the skip ci flag when creating a commit --- .../UnityBuildV3/unity-versioning.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts index d35d038..32b42e6 100644 --- a/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts +++ b/Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts @@ -292,6 +292,7 @@ export class UnityVersioning { bundleVersion, buildCode ); + commitMessage = this.ensureSkipCIFlag(commitMessage); // Now we can commit the changes. tl.execSync("git", ["config", "user.name", commitChangesUserName]); @@ -355,4 +356,25 @@ export class UnityVersioning { ) .replace(/{{buildNumber}}/g, buildCode.toString()); } + + private static ensureSkipCIFlag(commitMessage: string): string { + const skipPatterns = [ + /\[skip ci\]/i, + /\[ci skip\]/i, + /skip-checks:\s*true/i, + /\[skip azurepipelines\]/i, + /\[azurepipelines skip\]/i, + /\[skip azpipelines\]/i, + /\[azpipelines skip\]/i, + /\[skip azp\]/i, + /\[azp skip\]/i, + /\*\*\*NO_CI\*\*\*/i, + ]; + + if (skipPatterns.some((pattern) => pattern.test(commitMessage))) { + return commitMessage; + } + + return `${commitMessage} [skip ci]`; + } }