@@ -31663,19 +31663,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
3166331663};
3166431664Object.defineProperty(exports, "__esModule", ({ value: true }));
3166531665const core = __importStar(__nccwpck_require__(2186));
31666- const maybe_create_temporary_branch_1 = __nccwpck_require__(5330);
31667- const maybe_remove_temporary_tags_1 = __nccwpck_require__(624);
3166831666const artifacts_1 = __nccwpck_require__(1870);
3166931667const tags_1 = __nccwpck_require__(7816);
3167031668const create_git_1 = __nccwpck_require__(6704);
31669+ const temporary_branch_1 = __nccwpck_require__(2786);
3167131670async function main() {
3167231671 const git = (0, create_git_1.createGit)();
3167331672 const tags = new tags_1.Tags();
3167431673 const artifacts = new artifacts_1.Artifacts(git, tags);
31674+ const temporaryBranch = new temporary_branch_1.TemporaryBranch(git);
3167531675 Promise.resolve()
31676- .then(maybe_create_temporary_branch_1.maybeCreateTemporaryBranch )
31676+ .then(() => temporaryBranch.create() )
3167731677 .then(() => artifacts.update())
31678- .then(maybe_remove_temporary_tags_1.maybeRemoveTemporaryBranch )
31678+ .then(() => temporaryBranch.delete() )
3167931679 .catch((error) => core.setFailed(`Failed to create and push artifacts: ${error}`));
3168031680}
3168131681exports["default"] = main;
@@ -31728,27 +31728,40 @@ class Artifacts {
3172831728 core.startGroup("📦 Creating artifacts");
3172931729 try {
3173031730 await this.compile();
31731- await this.push ();
31731+ await this.deploy ();
3173231732 }
3173331733 catch (error) {
31734- core.warning(`Failed creating artifacts: ${error}`);
3173531734 core.endGroup();
31736- throw error;
31735+ throw new Error(`Failed creating artifacts: ${ error}`) ;
3173731736 }
3173831737 }
3173931738 async compile() {
3174031739 const result = await exec.exec(Artifacts.COMMAND);
3174131740 if (result !== 0) {
31742- throw new Error("Failed to compile artifacts. Process exited with non-zero code.");
31741+ throw new Error("Failing to compile artifacts. Process exited with non-zero code.");
3174331742 }
3174431743 }
31745- async push() {
31744+ async deploy() {
31745+ await this.add();
3174631746 await this.tags.collect();
31747- await exec.exec(`git add -f ${Artifacts.TARGET_DIR}/*`);
31747+ await this.commit();
31748+ await this.push();
31749+ await this.tags.move();
31750+ }
31751+ async add() {
31752+ const result = await exec.exec(`git add -f ${Artifacts.TARGET_DIR}/*`);
31753+ if (result !== 0) {
31754+ throw new Error("Failing to git-add the artifacts build. Process exited with non-zero code.");
31755+ }
31756+ }
31757+ async commit() {
3174831758 const commitResult = await this.git.commit("🚀 Build Artifacts");
31749- const pushingResult = await this.git.push();
3175031759 core.info(`Committed changes: ${commitResult.summary.changes}`);
31751- await this.tags.move();
31760+ core.info(`Committed insertions: ${commitResult.summary.insertions}`);
31761+ core.info(`Committed deletions: ${commitResult.summary.deletions}`);
31762+ }
31763+ async push() {
31764+ const pushingResult = await this.git.push();
3175231765 const messages = pushingResult?.remoteMessages.all.join("\n");
3175331766 messages && core.info(`Pushed artifacts with messages: ${messages}`);
3175431767 }
@@ -31759,44 +31772,6 @@ exports.Artifacts = Artifacts;
3175931772/***/ }),
3176031773
3176131774/***/ 7816:
31762- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
31763-
31764- "use strict";
31765-
31766- Object.defineProperty(exports, "__esModule", ({ value: true }));
31767- exports.Tags = void 0;
31768- const create_git_1 = __nccwpck_require__(6704);
31769- class Tags {
31770- tags = [];
31771- git = (0, create_git_1.createGit)();
31772- async collect() {
31773- this.tags = (await this.git.tags(["--contains"])).all;
31774- }
31775- async move() {
31776- await this.remove();
31777- await this.create();
31778- }
31779- toString() {
31780- if (!this.tags.length) {
31781- return "";
31782- }
31783- return [...this.tags].join(", ");
31784- }
31785- async remove() {
31786- await this.git.tag(["-d", ...this.tags]);
31787- await this.git.push(["--delete", "origin", ...this.tags]);
31788- }
31789- async create() {
31790- await Promise.all(this.tags.map(async (tag) => this.git.addTag(tag)));
31791- await this.git.pushTags();
31792- }
31793- }
31794- exports.Tags = Tags;
31795-
31796-
31797- /***/ }),
31798-
31799- /***/ 5330:
3180031775/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3180131776
3180231777"use strict";
@@ -31825,31 +31800,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
3182531800 return result;
3182631801};
3182731802Object.defineProperty(exports, "__esModule", ({ value: true }));
31828- exports.maybeCreateTemporaryBranch = void 0;
31803+ exports.Tags = void 0;
3182931804const create_git_1 = __nccwpck_require__(6704);
3183031805const core = __importStar(__nccwpck_require__(2186));
31831- async function maybeCreateTemporaryBranch() {
31832- const git = (0, create_git_1.createGit)();
31833- const _isDetached = await isDetached();
31834- if (!_isDetached) {
31835- return;
31806+ class Tags {
31807+ tags = [];
31808+ git = (0, create_git_1.createGit)();
31809+ async collect() {
31810+ this.tags = (await this.git.tags(["--contains"])).all;
31811+ core.info(`Collecting tags: ${this.toString()}`);
31812+ }
31813+ async move() {
31814+ core.info(`Moving tags: ${this.toString()}`);
31815+ await this.remove();
31816+ await this.create();
31817+ }
31818+ async remove() {
31819+ await this.git.tag(["-d", ...this.tags]);
31820+ const pushResult = await this.git.push([
31821+ "--delete",
31822+ "origin",
31823+ ...this.tags,
31824+ ]);
31825+ this.pushInfo(pushResult, "Removed tags with messages");
31826+ }
31827+ async create() {
31828+ await Promise.all(this.tags.map(async (tag) => this.git.addTag(tag)));
31829+ const pushResult = await this.git.pushTags();
31830+ this.pushInfo(pushResult, "Pushed tags with messages");
31831+ }
31832+ toString() {
31833+ if (!this.tags.length) {
31834+ return "";
31835+ }
31836+ return [...this.tags].join(", ");
31837+ }
31838+ pushInfo(result, message) {
31839+ const messages = result?.remoteMessages.all.join("\n");
31840+ messages && core.info(`${message}: ${messages}`);
3183631841 }
31837- const currentHash = await git.revparse(["--short", "HEAD"]);
31838- const temporaryBranchName = `ci-tag-${currentHash}`;
31839- await git.checkoutLocalBranch(temporaryBranchName);
31840- core.info(`Temporary branch ${temporaryBranchName} created successfully.`);
31841- await git.push(["-u", "origin", temporaryBranchName]);
31842- }
31843- exports.maybeCreateTemporaryBranch = maybeCreateTemporaryBranch;
31844- async function isDetached() {
31845- const branchName = await (0, create_git_1.createGit)().revparse(["--abbrev-ref", "HEAD"]);
31846- return branchName === "HEAD";
3184731842}
31843+ exports.Tags = Tags;
3184831844
3184931845
3185031846/***/ }),
3185131847
31852- /***/ 624 :
31848+ /***/ 2786 :
3185331849/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3185431850
3185531851"use strict";
@@ -31878,25 +31874,61 @@ var __importStar = (this && this.__importStar) || function (mod) {
3187831874 return result;
3187931875};
3188031876Object.defineProperty(exports, "__esModule", ({ value: true }));
31881- exports.maybeRemoveTemporaryBranch = void 0;
31882- const create_git_1 = __nccwpck_require__(6704);
31877+ exports.TemporaryBranch = void 0;
3188331878const core = __importStar(__nccwpck_require__(2186));
31884- async function maybeRemoveTemporaryBranch() {
31885- const git = (0, create_git_1.createGit)();
31886- const _temporaryBranch = await temporaryBranch();
31887- if (!_temporaryBranch) {
31888- return;
31879+ class TemporaryBranch {
31880+ git;
31881+ constructor(git) {
31882+ this.git = git;
3188931883 }
31890- await git.checkout("--detach");
31891- await git.deleteLocalBranch(_temporaryBranch);
31892- await git.push(["--delete", "origin", _temporaryBranch]);
31893- core.info(`Temporary branch ${_temporaryBranch} removed successfully.`);
31894- }
31895- exports.maybeRemoveTemporaryBranch = maybeRemoveTemporaryBranch;
31896- async function temporaryBranch() {
31897- const branchName = await (0, create_git_1.createGit)().revparse(["--abbrev-ref", "HEAD"]);
31898- return branchName.startsWith("ci-tag-") ? branchName : "";
31899- }
31884+ async create() {
31885+ const _isDetached = await this.isDetached();
31886+ if (!_isDetached) {
31887+ return;
31888+ }
31889+ const currentHash = await this.git.revparse(["--short", "HEAD"]);
31890+ const temporaryBranchName = `ci-tag-${currentHash}`;
31891+ await this.git.checkoutLocalBranch(temporaryBranchName);
31892+ const pushResult = await this.git.push([
31893+ "-u",
31894+ "origin",
31895+ temporaryBranchName,
31896+ ]);
31897+ this.pushInfo(pushResult, "Created temporary branch with messages");
31898+ core.info(`Temporary branch ${temporaryBranchName} created successfully.`);
31899+ }
31900+ async delete() {
31901+ const _temporaryBranch = await this.branchName();
31902+ if (!_temporaryBranch) {
31903+ return;
31904+ }
31905+ await this.git.checkout("--detach");
31906+ const deleteResult = await this.git.deleteLocalBranch(_temporaryBranch);
31907+ core.info(deleteResult.success
31908+ ? `Temporary branch ${_temporaryBranch} deleted successfully.`
31909+ : `Failed to delete temporary branch ${_temporaryBranch}.`);
31910+ const pushResult = await this.git.push([
31911+ "--delete",
31912+ "origin",
31913+ _temporaryBranch,
31914+ ]);
31915+ this.pushInfo(pushResult, "Removed temporary branch with messages");
31916+ core.info(`Temporary branch ${_temporaryBranch} removed successfully.`);
31917+ }
31918+ async isDetached() {
31919+ const branchName = await this.git.revparse(["--abbrev-ref", "HEAD"]);
31920+ return branchName === "HEAD";
31921+ }
31922+ async branchName() {
31923+ const branchName = await this.git.revparse(["--abbrev-ref", "HEAD"]);
31924+ return branchName.startsWith("ci-tag-") ? branchName : "";
31925+ }
31926+ pushInfo(result, message) {
31927+ const messages = result?.remoteMessages.all.join("\n");
31928+ messages && core.info(`${message}: ${messages}`);
31929+ }
31930+ }
31931+ exports.TemporaryBranch = TemporaryBranch;
3190031932
3190131933
3190231934/***/ }),
0 commit comments