4 Commits

Author SHA1 Message Date
Artur Stolear
4bda6b5eba renamed gitversion-tool and gitreleasemanager-tool to just tool 2020-02-09 00:30:13 +02:00
Artur Stolear
edd278e744 use the targetDirectory based on repo root
use the targetDirectory based on repo root
2020-02-09 00:28:20 +02:00
Artur Stolear
c7eb02e614 compiled discard action 2020-02-08 21:32:40 +02:00
Artur Stolear
6cbe5073c3 added GRM discard action 2020-02-08 21:32:22 +02:00
28 changed files with 40419 additions and 1007 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,46 @@
{
"messages": {
"LIB_UnhandledEx": "Unhandled: %s",
"LIB_FailOnCode": "Failure return code: %d",
"LIB_MkdirFailed": "Unable to create directory '%s'. %s",
"LIB_MkdirFailedFileExists": "Unable to create directory '%s'. Conflicting file exists: '%s'",
"LIB_MkdirFailedInvalidDriveRoot": "Unable to create directory '%s'. Root directory does not exist: '%s'",
"LIB_MkdirFailedInvalidShare": "Unable to create directory '%s'. Unable to verify the directory exists: '%s'. If directory is a file share, please verify the share name is correct, the share is online, and the current process has permission to access the share.",
"LIB_MultilineSecret": "Secrets cannot contain multiple lines",
"LIB_ProcessError": "There was an error when attempting to execute the process '%s'. This may indicate the process failed to start. Error: %s",
"LIB_ProcessExitCode": "The process '%s' failed with exit code %s",
"LIB_ProcessStderr": "The process '%s' failed because one or more lines were written to the STDERR stream",
"LIB_ReturnCode": "Return code: %d",
"LIB_ResourceFileNotExist": "Resource file doesn\\'t exist: %s",
"LIB_ResourceFileAlreadySet": "Resource file has already set to: %s",
"LIB_ResourceFileNotSet": "Resource file haven\\'t set, can\\'t find loc string for key: %s",
"LIB_StdioNotClosed": "The STDIO streams did not close within %s seconds of the exit event from process '%s'. This may indicate a child process inherited the STDIO streams and has not yet exited.",
"LIB_WhichNotFound_Linux": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.",
"LIB_WhichNotFound_Win": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.",
"LIB_LocStringNotFound": "Can\\'t find loc string for key: %s",
"LIB_ParameterIsRequired": "%s not supplied",
"LIB_InputRequired": "Input required: %s",
"LIB_InvalidPattern": "Invalid pattern: '%s'",
"LIB_EndpointNotExist": "Endpoint not present: %s",
"LIB_EndpointDataNotExist": "Endpoint data parameter %s not present: %s",
"LIB_EndpointAuthNotExist": "Endpoint auth data not present: %s",
"LIB_InvalidEndpointAuth": "Invalid endpoint auth: %s",
"LIB_InvalidSecureFilesInput": "Invalid secure file input: %s",
"LIB_PathNotFound": "Not found %s: %s",
"LIB_PathHasNullByte": "Path cannot contain null bytes",
"LIB_OperationFailed": "Failed %s: %s",
"LIB_UseFirstGlobMatch": "Multiple workspace matches. using first.",
"LIB_MergeTestResultNotSupported": "Merging test results from multiple files to one test run is not supported on this version of build agent for OSX/Linux, each test result file will be published as a separate test run in VSO/TFS.",
"LIB_PlatformNotSupported": "Platform not supported: %s",
"TOOL_LIB_CachingTool": "Caching tool: %s %s %s",
"_TOOL_LIB_CachingTool.comment": "This informational log message indicates that a tool, that was just downloaded, is being copied into the cache directory. %s %s %s represent the tool name, version information, and processor architecture.",
"TOOL_LIB_Downloading": "Downloading: %s",
"_TOOL_LIB_Downloading.comment": "This information log message indicates that a file is being downloaded. %s represents the URL being downloaded.",
"TOOL_LIB_ExtractingArchive": "Extracting archive",
"_TOOL_LIB_ExtractingArchive.comment": "This informational log message indicates that an archive file is being extracted. For example, a .zip file, .7z file, or .tar.gz file.",
"TOOL_LIB_FoundInCache": "Found tool in cache: %s %s %s",
"_TOOL_LIB_FoundInCache.comment": "This informational log message indicates that the request tool is already cached, and does not need to be downloaded again. %s %s %s represent the tool name, version information, and processor architecture.",
"TOOL_LIB_PrependPath": "Prepending PATH environment variable with directory: %s",
"_TOOL_LIB_PrependPath.comment": "This informational log message indicates that a directory is being prepended to the front of the PATH environment variable. The directories specified by the PATH environment variable are used to resolve the location of command line tools."
}
}

View File

@@ -0,0 +1,60 @@
{
"id": "9ae78b66-6100-4522-8106-b7ae00bbfcdf",
"name": "gitreleasemanager/discard",
"friendlyName": "Discard GitReleaseManager Task",
"description": "Tool for creating and exporting releases for software applications hosted on GitHub",
"author": "GitTools Contributors",
"helpMarkDown": "See the [documentation](https://gittools.github.io/GitReleaseManager/docs/) for help",
"category": "Build",
"demands": [],
"version": {
"Major": "1",
"Minor": "0",
"Patch": "0"
},
"minimumAgentVersion": "2.115.0",
"execution": {
"Node": {
"target": "bundle.js",
"argumentFormat": "",
"workingDirectory": "."
}
},
"instanceNameFormat": "gitreleasemanager/discard",
"inputs": [{
"name": "owner",
"type": "string",
"label": "The owner of the repository",
"defaultValue": "",
"required": true,
"helpMarkDown": "The owner of the repository"
}, {
"name": "repository",
"type": "string",
"label": "The name of the repository",
"defaultValue": "",
"required": true,
"helpMarkDown": "The name of the repository"
}, {
"name": "token",
"type": "string",
"label": "The access token to access GitHub with",
"defaultValue": "",
"required": true,
"helpMarkDown": "The access token to access GitHub with"
}, {
"name": "milestone",
"type": "string",
"label": "The milestone to use",
"defaultValue": "",
"required": true,
"helpMarkDown": "The milestone to use"
}, {
"name": "targetDirectory",
"type": "string",
"label": "The directory on which GitReleaseManager should be executed. Defaults to current directory",
"defaultValue": "",
"required": false,
"helpMarkDown": "The directory on which GitReleaseManager should be executed. Defaults to current directory"
}]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -14,7 +14,8 @@
{ "path": "gitversion/setup" }, { "path": "gitversion/setup" },
{ "path": "gitversion/execute" }, { "path": "gitversion/execute" },
{ "path": "gitreleasemanager/setup" }, { "path": "gitreleasemanager/setup" },
{ "path": "gitreleasemanager/create" } { "path": "gitreleasemanager/create" },
{ "path": "gitreleasemanager/discard" }
], ],
"categories": [ "categories": [
"Azure Pipelines" "Azure Pipelines"
@@ -97,5 +98,14 @@
"properties": { "properties": {
"name": "gitreleasemanager/create" "name": "gitreleasemanager/create"
} }
}, {
"id": "discard-gitreleasemanager-task",
"type": "ms.vss-distributed-task.task",
"targets": [
"ms.vss-distributed-task.tasks"
],
"properties": {
"name": "gitreleasemanager/discard"
}
}] }]
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,30 @@
name: gitreleasemanager-discard
description: GitHub Action for creating and exporting releases for software applications hosted on GitHub. Discards a release
author: GitTools
branding:
color: gray-dark
icon: git-pull-request
runs:
using: node12
main: ../../dist/github/gitreleasemanager/discard/bundle.js
inputs:
owner:
description: The owner of the repository
required: true
default: ''
repository:
description: The name of the repository
required: true
default: ''
token:
description: The access token to access GitHub with
required: true
default: ''
milestone:
description: The milestone to use
required: true
default: ''
targetDirectory:
description: The directory on which GitReleaseManager should be executed. Defaults to current directory
required: false
default: ''

View File

@@ -0,0 +1,4 @@
import "reflect-metadata";
import { discard } from "./main";
discard();

View File

@@ -1,5 +1,5 @@
import { IBuildAgent, TYPES, SetupFields } from "../../core/models"; import { IBuildAgent, TYPES, SetupFields } from "../../core/models";
import { IGitReleaseManagerTool, GitReleaseManagerTool } from "../../tools/gitreleasemanager/gitreleasemanager-tool"; import { IGitReleaseManagerTool, GitReleaseManagerTool } from "../../tools/gitreleasemanager/tool";
import { Settings as CommonSettings } from "../../core/settings"; import { Settings as CommonSettings } from "../../core/settings";
import { Settings } from "../../tools/gitreleasemanager/settings"; import { Settings } from "../../tools/gitreleasemanager/settings";
@@ -38,4 +38,19 @@ export async function create() {
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true);
} }
}
export async function discard() {
try {
gitReleaseManagerTool.disableTelemetry();
const settings = Settings.getDiscardSettings(buildAgent);
await gitReleaseManagerTool.discard(settings);
buildAgent.setSucceeded("GitVersionManager discarded release successfully", true);
} catch (error) {
buildAgent.setFailed(error.message, true);
}
} }

View File

@@ -1,7 +1,7 @@
import { IBuildAgent, TYPES, SetupFields } from "../../core/models"; import { IBuildAgent, TYPES, SetupFields } from "../../core/models";
import { Settings as CommonSettings } from "../../core/settings"; import { Settings as CommonSettings } from "../../core/settings";
import { Settings } from "../../tools/gitversion/settings"; import { Settings } from "../../tools/gitversion/settings";
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/gitversion-tool"; import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/tool";
import { GitVersionSettings, GitVersionOutput } from "../../tools/gitversion/models"; import { GitVersionSettings, GitVersionOutput } from "../../tools/gitversion/models";
import container from "../../core/ioc"; import container from "../../core/ioc";

View File

@@ -14,6 +14,11 @@ export enum CreateFields {
assets = "assets", assets = "assets",
} }
export enum DiscardFields {
milestone = "milestone",
targetDirectory = "targetDirectory",
}
export interface GitReleaseManagerSettings { export interface GitReleaseManagerSettings {
[CommonFields.repository]: string; [CommonFields.repository]: string;
[CommonFields.owner]: string; [CommonFields.owner]: string;
@@ -28,4 +33,9 @@ export interface GitReleaseManagerCreateSettings extends GitReleaseManagerSettin
[CreateFields.commit]: string; [CreateFields.commit]: string;
[CreateFields.targetDirectory]: string; [CreateFields.targetDirectory]: string;
[CreateFields.assets]?: string[]; [CreateFields.assets]?: string[];
}
export interface GitReleaseManagerDiscardSettings extends GitReleaseManagerSettings {
[DiscardFields.milestone]: string;
[DiscardFields.targetDirectory]: string;
} }

View File

@@ -1,5 +1,5 @@
import { IBuildAgent } from "../../core/models"; import { IBuildAgent } from "../../core/models";
import { GitReleaseManagerSettings, CommonFields, CreateFields, GitReleaseManagerCreateSettings } from "./models"; import { GitReleaseManagerSettings, CommonFields, CreateFields, GitReleaseManagerCreateSettings, DiscardFields, GitReleaseManagerDiscardSettings } from "./models";
export class Settings { export class Settings {
@@ -25,6 +25,18 @@ export class Settings {
} }
} }
public static getDiscardSettings(buildAgent: IBuildAgent) : GitReleaseManagerDiscardSettings {
const milestone = buildAgent.getInput(DiscardFields.milestone);
const targetDirectory = buildAgent.getInput(CreateFields.targetDirectory);
const commonSettings = Settings.getCommonSettings(buildAgent);
return {
...commonSettings,
milestone,
targetDirectory,
}
}
private static getCommonSettings(buildAgent: IBuildAgent): GitReleaseManagerSettings { private static getCommonSettings(buildAgent: IBuildAgent): GitReleaseManagerSettings {
const owner = buildAgent.getInput(CommonFields.owner, true); const owner = buildAgent.getInput(CommonFields.owner, true);
const repository = buildAgent.getInput(CommonFields.repository, true); const repository = buildAgent.getInput(CommonFields.repository, true);

View File

@@ -3,12 +3,18 @@ import path = require("path");
import { TYPES, IBuildAgent, IExecResult } from "../../core/models"; import { TYPES, IBuildAgent, IExecResult } from "../../core/models";
import { injectable, inject } from "inversify"; import { injectable, inject } from "inversify";
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool"; import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
import { GitReleaseManagerCreateSettings, GitReleaseManagerSettings, CreateFields, CommonFields } from "./models";
import { IVersionManager } from "../../core/versionManager"; import { IVersionManager } from "../../core/versionManager";
import {
GitReleaseManagerSettings,
GitReleaseManagerCreateSettings,
GitReleaseManagerDiscardSettings
} from "./models";
export interface IGitReleaseManagerTool extends IDotnetTool { export interface IGitReleaseManagerTool extends IDotnetTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>; install(versionSpec: string, includePrerelease: boolean): Promise<void>;
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>; create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>;
discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult>;
} }
@injectable() @injectable()
@@ -31,6 +37,12 @@ export class GitReleaseManagerTool extends DotnetTool implements IGitReleaseMana
return this.execute("dotnet-gitreleasemanager", args); return this.execute("dotnet-gitreleasemanager", args);
} }
public discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult> {
const args = this.getDiscardArguments(settings);
return this.execute("dotnet-gitreleasemanager", args);
}
getCommonArguments(settings: GitReleaseManagerSettings): string[] { getCommonArguments(settings: GitReleaseManagerSettings): string[] {
const args: string[] = []; const args: string[] = [];
@@ -41,6 +53,19 @@ export class GitReleaseManagerTool extends DotnetTool implements IGitReleaseMana
return args; return args;
} }
getDiscardArguments(settings: GitReleaseManagerDiscardSettings): string[] {
const args: string[] = ['discard', ...this.getCommonArguments(settings)];
if (settings.milestone) {
args.push("--milestone", settings.milestone);
}
settings.targetDirectory = this.getRepoDir(settings.targetDirectory);
args.push("--targetDirectory", settings.targetDirectory);
return args;
}
getCreateArguments(settings: GitReleaseManagerCreateSettings): string[] { getCreateArguments(settings: GitReleaseManagerCreateSettings): string[] {
const args: string[] = ['create', ...this.getCommonArguments(settings)]; const args: string[] = ['create', ...this.getCommonArguments(settings)];
@@ -53,9 +78,11 @@ export class GitReleaseManagerTool extends DotnetTool implements IGitReleaseMana
if (settings.commit) { if (settings.commit) {
args.push("--targetcommitish", settings.commit); args.push("--targetcommitish", settings.commit);
} }
if (settings.targetDirectory) {
args.push("--targetDirectory", settings.targetDirectory); settings.targetDirectory = this.getRepoDir(settings.targetDirectory);
}
args.push("--targetDirectory", settings.targetDirectory);
if (settings.inputFileName) { if (settings.inputFileName) {
if (this.buildAgent.fileExists(settings.inputFileName)) { if (this.buildAgent.fileExists(settings.inputFileName)) {
args.push("--inputFilePath", settings.inputFileName); args.push("--inputFilePath", settings.inputFileName);
@@ -67,9 +94,28 @@ export class GitReleaseManagerTool extends DotnetTool implements IGitReleaseMana
args.push("--pre"); args.push("--pre");
} }
if (settings.assets && settings.assets.length > 0) { if (settings.assets && settings.assets.length > 0) {
settings.assets = settings.assets.map(asset => {
return path.join(settings.targetDirectory, asset)
})
args.push("--assets", settings.assets.join(",")); args.push("--assets", settings.assets.join(","));
} }
return args; return args;
} }
private getRepoDir(targetPath: string): string {
let workDir: string;
const srcDir = this.buildAgent.getSourceDir();
if (!targetPath) {
workDir = srcDir;
} else {
if (this.buildAgent.directoryExists(targetPath)) {
workDir = path.join(srcDir, targetPath);
} else {
throw new Error("Directory not found at " + targetPath);
}
}
return workDir.replace(/\\/g, "/");
}
} }

View File

@@ -1,4 +1,5 @@
import path = require("path"); import path = require("path");
import { injectable, inject } from "inversify"; import { injectable, inject } from "inversify";
import { IExecResult, IBuildAgent, TYPES } from "../../core/models"; import { IExecResult, IBuildAgent, TYPES } from "../../core/models";
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool"; import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";

View File

@@ -12,6 +12,7 @@ module.exports = (env) => {
'gitversion/execute': path.resolve(__dirname, 'src/tasks/gitversion/execute.ts'), 'gitversion/execute': path.resolve(__dirname, 'src/tasks/gitversion/execute.ts'),
'gitreleasemanager/setup': path.resolve(__dirname, 'src/tasks/gitreleasemanager/setup.ts'), 'gitreleasemanager/setup': path.resolve(__dirname, 'src/tasks/gitreleasemanager/setup.ts'),
'gitreleasemanager/create': path.resolve(__dirname, 'src/tasks/gitreleasemanager/create.ts'), 'gitreleasemanager/create': path.resolve(__dirname, 'src/tasks/gitreleasemanager/create.ts'),
'gitreleasemanager/discard': path.resolve(__dirname, 'src/tasks/gitreleasemanager/discard.ts'),
}, },
target: 'node', target: 'node',
mode: mode, mode: mode,