diff --git a/dist/index.js b/dist/index.js index 6fca057a..67ec6174 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3523,22 +3523,21 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.NuGetPackageBuilder = void 0; var zipUtils_1 = __nccwpck_require__(7273); var fs_1 = __importDefault(__nccwpck_require__(7147)); -var os_1 = __importDefault(__nccwpck_require__(2037)); var path_1 = __importDefault(__nccwpck_require__(1017)); var NuGetPackageBuilder = /** @class */ (function () { function NuGetPackageBuilder() { } NuGetPackageBuilder.prototype.pack = function (args) { return __awaiter(this, void 0, void 0, function () { - var archiveFilename, tmpFolder, inputFilePatterns, nuspecFile; + var archiveFilename, inputFilePatterns, nuspecFilename, nuspecFile; return __generator(this, function (_a) { switch (_a.label) { case 0: archiveFilename = "".concat(args.packageId, ".").concat(args.version, ".nupkg"); - tmpFolder = os_1.default.tmpdir(); inputFilePatterns = args.inputFilePatterns; if (args.nuspecArgs) { - nuspecFile = path_1.default.join(tmpFolder, "".concat(args.packageId, ".nuspec")); + nuspecFilename = "".concat(args.packageId, ".nuspec"); + nuspecFile = path_1.default.join(args.basePath, nuspecFilename); fs_1.default.writeFileSync(nuspecFile, '\n'); fs_1.default.appendFileSync(nuspecFile, '\n'); fs_1.default.appendFileSync(nuspecFile, " \n"); @@ -3552,9 +3551,9 @@ var NuGetPackageBuilder = /** @class */ (function () { fs_1.default.appendFileSync(nuspecFile, " \n"); fs_1.default.appendFileSync(nuspecFile, "\n"); // include the nuspec into the package - inputFilePatterns.push(nuspecFile); + inputFilePatterns.push(nuspecFilename); } - return [4 /*yield*/, (0, zipUtils_1.doZip)(inputFilePatterns, args.outputFolder, archiveFilename, args.logger, 8, args.overwrite)]; + return [4 /*yield*/, (0, zipUtils_1.doZip)(args.basePath, inputFilePatterns, args.outputFolder, archiveFilename, args.logger, 8, args.overwrite)]; case 1: _a.sent(); return [2 /*return*/, archiveFilename]; @@ -3633,7 +3632,7 @@ var ZipPackageBuilder = /** @class */ (function () { switch (_a.label) { case 0: archiveFilename = "".concat(args.packageId, ".").concat(args.version, ".zip"); - return [4 /*yield*/, (0, zipUtils_1.doZip)(args.inputFilePatterns, args.outputFolder, archiveFilename, args.logger, args.compressionLevel, args.overwrite)]; + return [4 /*yield*/, (0, zipUtils_1.doZip)(args.basePath, args.inputFilePatterns, args.outputFolder, archiveFilename, args.logger, args.compressionLevel, args.overwrite)]; case 1: _a.sent(); return [2 /*return*/, archiveFilename]; @@ -3706,20 +3705,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.doZip = void 0; var adm_zip_1 = __importDefault(__nccwpck_require__(6761)); +var fs_1 = __importDefault(__nccwpck_require__(7147)); var glob_1 = __nccwpck_require__(1957); var path_1 = __importDefault(__nccwpck_require__(1017)); var util_1 = __nccwpck_require__(3837); var globp = (0, util_1.promisify)(glob_1.glob); -function doZip(inputFilePatterns, outputFolder, zipFilename, logger, compressionLevel, overwrite) { +/** + * Creates a Zip file with a given filename from the inputFilePatterns. + * + * @param {string} basePath The base path for the input files. + * @param {string[]} inputFilePatterns Array of input file patterns, relative to the basePath. Specific files and globbing patterns are both supported. + * @param {string} outputFolder The folder to write the resulting Zip file to. + * @param {string} zipFilename The name of the Zip file to create. + * @param {Logger} logger Logger implementation for writing debug and info messages + * @param {number} compressionLevel Optional override for the compression level. Defaults to 8 if not specified. + * @param {boolean} overwrite Whether to overwrite the Zip file if it already exists. Defaults to true if not specified. + */ +function doZip(basePath, inputFilePatterns, outputFolder, zipFilename, logger, compressionLevel, overwrite) { var _a, _b, _c; return __awaiter(this, void 0, void 0, function () { - var archivePath, zip, files, files_1, files_1_1, file; + var archivePath, initialWorkingDirectory, zip, files, files_1, files_1_1, file, dirName; var e_1, _d; return __generator(this, function (_e) { switch (_e.label) { case 0: archivePath = path_1.default.resolve(outputFolder, zipFilename); (_a = logger.info) === null || _a === void 0 ? void 0 : _a.call(logger, "Writing to package: ".concat(archivePath, "...")); + initialWorkingDirectory = process.cwd(); + process.chdir(path_1.default.resolve(initialWorkingDirectory, basePath)); zip = new adm_zip_1.default(); return [4 /*yield*/, expandGlobs(inputFilePatterns)]; case 1: @@ -3728,7 +3741,13 @@ function doZip(inputFilePatterns, outputFolder, zipFilename, logger, compression for (files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) { file = files_1_1.value; (_b = logger.debug) === null || _b === void 0 ? void 0 : _b.call(logger, "Adding file: ".concat(file, "...")); - zip.addLocalFile(file); + if (fs_1.default.lstatSync(file).isDirectory()) { + zip.addFile("".concat(file, "/"), Buffer.from([0x00])); + } + else { + dirName = path_1.default.dirname(file); + zip.addLocalFile(file, dirName === "." ? "" : dirName); + } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } @@ -3742,7 +3761,8 @@ function doZip(inputFilePatterns, outputFolder, zipFilename, logger, compression (_c = logger.info) === null || _c === void 0 ? void 0 : _c.call(logger, "Overriding compression level: ".concat(compressionLevel)); } setCompressionLevel(zip, compressionLevel || 8); - return [4 /*yield*/, zip.writeZipPromise(archivePath, { overwrite: overwrite })]; + process.chdir(initialWorkingDirectory); + return [4 /*yield*/, zip.writeZipPromise(archivePath, { overwrite: overwrite || true })]; case 2: _e.sent(); return [2 /*return*/]; @@ -41501,33 +41521,33 @@ function wrappy (fn, cb) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.waitForTask = void 0; -const api_client_1 = __nccwpck_require__(586); -function waitForTask(client, parameters) { - return __awaiter(this, void 0, void 0, function* () { - const spaceId = yield (0, api_client_1.resolveSpaceId)(client, parameters.space); - client.info(`🐙 waiting for task ${parameters.server}/app#/${spaceId}/tasks/${parameters.serverTaskId} in Octopus Deploy...`); - const waiter = new api_client_1.ServerTaskWaiter(client, parameters.space); - const serverTask = yield waiter.waitForServerTaskToComplete(parameters.serverTaskId, parameters.pollingInterval * 1000, parameters.timeout * 1000, (serverTaskDetails) => { - if (parameters.hideProgress !== true) { - client.info(`waiting for task ${serverTaskDetails.Task.Id}. Status: ${serverTaskDetails.Task.State}. Progress: ${serverTaskDetails.Progress.ProgressPercentage}%`); - } - }); - return serverTask === null || serverTask === void 0 ? void 0 : serverTask.State; - }); -} -exports.waitForTask = waitForTask; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.waitForTask = void 0; +const api_client_1 = __nccwpck_require__(586); +function waitForTask(client, parameters) { + return __awaiter(this, void 0, void 0, function* () { + const spaceId = yield (0, api_client_1.resolveSpaceId)(client, parameters.space); + client.info(`🐙 waiting for task ${parameters.server}/app#/${spaceId}/tasks/${parameters.serverTaskId} in Octopus Deploy...`); + const waiter = new api_client_1.ServerTaskWaiter(client, parameters.space); + const serverTask = yield waiter.waitForServerTaskToComplete(parameters.serverTaskId, parameters.pollingInterval * 1000, parameters.timeout * 1000, (serverTaskDetails) => { + if (parameters.hideProgress !== true) { + client.info(`waiting for task ${serverTaskDetails.Task.Id}. Status: ${serverTaskDetails.Task.State}. Progress: ${serverTaskDetails.Progress.ProgressPercentage}%`); + } + }); + return serverTask === null || serverTask === void 0 ? void 0 : serverTask.State; + }); +} +exports.waitForTask = waitForTask; /***/ }), @@ -41536,73 +41556,73 @@ exports.waitForTask = waitForTask; /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const input_parameters_1 = __nccwpck_require__(9519); -const core_1 = __nccwpck_require__(2186); -const fs_1 = __nccwpck_require__(7147); -const api_client_1 = __nccwpck_require__(586); -const api_wrapper_1 = __nccwpck_require__(4636); -(() => __awaiter(void 0, void 0, void 0, function* () { - try { - const logger = { - debug: message => { - if ((0, core_1.isDebug)()) { - (0, core_1.debug)(message); - } - }, - info: message => (0, core_1.info)(message), - warn: message => (0, core_1.warning)(message), - error: (message, err) => { - if (err !== undefined) { - (0, core_1.error)(err.message); - } - else { - (0, core_1.error)(message); - } - } - }; - const parameters = (0, input_parameters_1.getInputParameters)(); - const config = { - userAgentApp: 'GitHubActions await-task-action', - instanceURL: parameters.server, - apiKey: parameters.apiKey, - logging: logger - }; - const client = yield api_client_1.Client.create(config); - const taskState = yield (0, api_wrapper_1.waitForTask)(client, parameters); - (0, core_1.setOutput)('task_state', taskState); - const stepSummaryFile = process.env.GITHUB_STEP_SUMMARY; - if (stepSummaryFile) { - (0, fs_1.writeFileSync)(stepSummaryFile, `🐙 Octopus Deploy task ${taskState === api_client_1.TaskState.Success ? 'completed successfully' : 'did not complete successfully'}.`); - } - if (taskState !== api_client_1.TaskState.Success) { - if (taskState) { - (0, core_1.setFailed)(`🐙 Octopus Deploy task did not complete successfully (state: ${taskState})`); - } - else { - (0, core_1.setFailed)('🐙 Could not determine Octopus Deploy task state'); - } - } - } - catch (e) { - if (e instanceof Error) { - (0, core_1.setFailed)(e); - } - else { - (0, core_1.setFailed)(`Unknown error: ${e}`); - } - } -}))(); + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const input_parameters_1 = __nccwpck_require__(9519); +const core_1 = __nccwpck_require__(2186); +const fs_1 = __nccwpck_require__(7147); +const api_client_1 = __nccwpck_require__(586); +const api_wrapper_1 = __nccwpck_require__(4636); +(() => __awaiter(void 0, void 0, void 0, function* () { + try { + const logger = { + debug: message => { + if ((0, core_1.isDebug)()) { + (0, core_1.debug)(message); + } + }, + info: message => (0, core_1.info)(message), + warn: message => (0, core_1.warning)(message), + error: (message, err) => { + if (err !== undefined) { + (0, core_1.error)(err.message); + } + else { + (0, core_1.error)(message); + } + } + }; + const parameters = (0, input_parameters_1.getInputParameters)(); + const config = { + userAgentApp: 'GitHubActions await-task-action', + instanceURL: parameters.server, + apiKey: parameters.apiKey, + logging: logger + }; + const client = yield api_client_1.Client.create(config); + const taskState = yield (0, api_wrapper_1.waitForTask)(client, parameters); + (0, core_1.setOutput)('task_state', taskState); + const stepSummaryFile = process.env.GITHUB_STEP_SUMMARY; + if (stepSummaryFile) { + (0, fs_1.writeFileSync)(stepSummaryFile, `🐙 Octopus Deploy task ${taskState === api_client_1.TaskState.Success ? 'completed successfully' : 'did not complete successfully'}.`); + } + if (taskState !== api_client_1.TaskState.Success) { + if (taskState) { + (0, core_1.setFailed)(`🐙 Octopus Deploy task did not complete successfully (state: ${taskState})`); + } + else { + (0, core_1.setFailed)('🐙 Could not determine Octopus Deploy task state'); + } + } + } + catch (e) { + if (e instanceof Error) { + (0, core_1.setFailed)(e); + } + else { + (0, core_1.setFailed)(`Unknown error: ${e}`); + } + } +}))(); /***/ }), @@ -41611,60 +41631,60 @@ const api_wrapper_1 = __nccwpck_require__(4636); /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getInputParameters = void 0; -const core_1 = __nccwpck_require__(2186); -const EnvironmentVariables = { - URL: 'OCTOPUS_URL', - ApiKey: 'OCTOPUS_API_KEY', - Space: 'OCTOPUS_SPACE' -}; -function getInputParameters() { - let variablesMap = undefined; - const variables = (0, core_1.getMultilineInput)('variables').map(p => p.trim()) || undefined; - if (variables) { - variablesMap = new Map(); - for (const variable of variables) { - const variableMap = variable.split(':').map(x => x.trim()); - variablesMap === null || variablesMap === void 0 ? void 0 : variablesMap.set(variableMap[0], variableMap[1]); - } - } - let pollingInterval = 10; - const intervalInput = (0, core_1.getInput)('polling_interval'); - if (intervalInput) { - pollingInterval = parseInt(intervalInput); - } - let timeout = 600; - const timeoutInput = (0, core_1.getInput)('timeout'); - if (timeoutInput) { - timeout = parseInt(timeoutInput); - } - const parameters = { - server: (0, core_1.getInput)('server') || process.env[EnvironmentVariables.URL] || '', - apiKey: (0, core_1.getInput)('api_key') || process.env[EnvironmentVariables.ApiKey] || '', - space: (0, core_1.getInput)('space') || process.env[EnvironmentVariables.Space] || '', - serverTaskId: (0, core_1.getInput)('server_task_id', { required: true }), - pollingInterval, - timeout, - hideProgress: (0, core_1.getBooleanInput)('hide_progress') || false - }; - const errors = []; - if (!parameters.server) { - errors.push("The Octopus instance URL is required, please specify explictly through the 'server' input or set the OCTOPUS_URL environment variable."); - } - if (!parameters.apiKey) { - errors.push("The Octopus API Key is required, please specify explictly through the 'api_key' input or set the OCTOPUS_API_KEY environment variable."); - } - if (!parameters.space) { - errors.push("The Octopus space name is required, please specify explictly through the 'space' input or set the OCTOPUS_SPACE environment variable."); - } - if (errors.length > 0) { - throw new Error(errors.join('\n')); - } - return parameters; -} -exports.getInputParameters = getInputParameters; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getInputParameters = void 0; +const core_1 = __nccwpck_require__(2186); +const EnvironmentVariables = { + URL: 'OCTOPUS_URL', + ApiKey: 'OCTOPUS_API_KEY', + Space: 'OCTOPUS_SPACE' +}; +function getInputParameters() { + let variablesMap = undefined; + const variables = (0, core_1.getMultilineInput)('variables').map(p => p.trim()) || undefined; + if (variables) { + variablesMap = new Map(); + for (const variable of variables) { + const variableMap = variable.split(':').map(x => x.trim()); + variablesMap === null || variablesMap === void 0 ? void 0 : variablesMap.set(variableMap[0], variableMap[1]); + } + } + let pollingInterval = 10; + const intervalInput = (0, core_1.getInput)('polling_interval'); + if (intervalInput) { + pollingInterval = parseInt(intervalInput); + } + let timeout = 600; + const timeoutInput = (0, core_1.getInput)('timeout'); + if (timeoutInput) { + timeout = parseInt(timeoutInput); + } + const parameters = { + server: (0, core_1.getInput)('server') || process.env[EnvironmentVariables.URL] || '', + apiKey: (0, core_1.getInput)('api_key') || process.env[EnvironmentVariables.ApiKey] || '', + space: (0, core_1.getInput)('space') || process.env[EnvironmentVariables.Space] || '', + serverTaskId: (0, core_1.getInput)('server_task_id', { required: true }), + pollingInterval, + timeout, + hideProgress: (0, core_1.getBooleanInput)('hide_progress') || false + }; + const errors = []; + if (!parameters.server) { + errors.push("The Octopus instance URL is required, please specify explictly through the 'server' input or set the OCTOPUS_URL environment variable."); + } + if (!parameters.apiKey) { + errors.push("The Octopus API Key is required, please specify explictly through the 'api_key' input or set the OCTOPUS_API_KEY environment variable."); + } + if (!parameters.space) { + errors.push("The Octopus space name is required, please specify explictly through the 'space' input or set the OCTOPUS_SPACE environment variable."); + } + if (errors.length > 0) { + throw new Error(errors.join('\n')); + } + return parameters; +} +exports.getInputParameters = getInputParameters; /***/ }),