Skip to content

Commit 088982b

Browse files
committed
Use regex to replace placeholders in commit message and git tag
1 parent cda0e15 commit 088982b

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,12 @@ export class UnityVersioning {
261261
projectVersioningCommitChangesMessageVariableName
262262
)!;
263263

264-
commitMessage = commitMessage.replace(
265-
"{{bundleVersion}}",
266-
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
267-
);
268-
269-
commitMessage = commitMessage.replace(
270-
"{{buildNumber}}",
271-
buildCode.toString()
272-
);
264+
commitMessage = commitMessage
265+
.replace(
266+
/{{bundleVersion}}/g,
267+
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
268+
)
269+
.replace(/{{buildNumber}}/g, buildCode.toString());
273270

274271
tl.execSync("git", ["config", "user.name", commitChangesUserName]);
275272
tl.execSync("git", ["config", "user.email", commitChangesUserMail]);
@@ -283,15 +280,12 @@ export class UnityVersioning {
283280
true
284281
)!;
285282

286-
gitTag = createTagPattern.replace(
287-
"{{bundleVersion}}",
288-
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
289-
);
290-
291-
gitTag = createTagPattern.replace(
292-
"{{buildNumber}}",
293-
buildCode.toString()
294-
);
283+
gitTag = createTagPattern
284+
.replace(
285+
/{{bundleVersion}}/g,
286+
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
287+
)
288+
.replace(/{{buildNumber}}/g, buildCode.toString());
295289

296290
tl.execSync("git", ["tag", gitTag]);
297291
}

0 commit comments

Comments
 (0)