private static void PackageTest(BuildContextBase context, string packageToTest)
    {
        if (context.Version == null)
        {
            return;
        }

        var outputDirectory = Paths.Packages.Combine("test");

        context.NuGetInstall(packageToTest, new NuGetInstallSettings
        {
            Source = new[]
            {
                context.MakeAbsolute(Paths.Nuget).FullPath
            },
            ExcludeVersion  = true,
            Prerelease      = true,
            OutputDirectory = outputDirectory
        });

        var settings = new GitVersionSettings
        {
            OutputTypes = new HashSet <GitVersionOutput>
            {
                GitVersionOutput.Json
            },
            ToolPath = outputDirectory.Combine(packageToTest).Combine("tools").CombineWithFilePath("gitversion.exe").FullPath
        };
        var gitVersion = context.GitVersion(settings);

        Assert.Equal(context.Version.GitVersion.FullSemVer, gitVersion.FullSemVer);
    }
Example #2
0
    private static void PackageUsingNuspec(BuildContextBase context)
    {
        var cmdlineNuspecFile = Paths.Nuspec.CombineWithFilePath("GitVersion.CommandLine.nuspec");

        if (!context.FileExists(cmdlineNuspecFile))
        {
            return;
        }

        var artifactPath  = context.MakeAbsolute(Paths.ArtifactsBinCmdline).FullPath;
        var version       = context.Version;
        var gitVersion    = version?.GitVersion;
        var nugetSettings = new NuGetPackSettings
        {
            // KeepTemporaryNuSpecFile = true,
            Version           = version?.NugetVersion,
            NoPackageAnalysis = true,
            OutputDirectory   = Paths.Nuget,
            Repository        = new NuGetRepository
            {
                Branch = gitVersion?.BranchName,
                Commit = gitVersion?.Sha
            },
            Files = context.GetFiles(artifactPath + "/**/*.*")
                    .Select(file => new NuSpecContent {
                Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "")
            })
                    .Concat(context.GetFiles("docs/**/package_icon.png").Select(file => new NuSpecContent {
                Source = file.FullPath, Target = "package_icon.png"
            }))
                    .Concat(context.GetFiles("build/nuspec/README.md").Select(file => new NuSpecContent {
                Source = file.FullPath, Target = "README.md"
            }))
                    .ToArray()
        };

        context.NuGetPack(cmdlineNuspecFile, nugetSettings);
    }
Example #3
0
    private static DockerContainerRunSettings GetDockerRunSettings(this BuildContextBase context, Architecture arch)
    {
        var currentDir = context.MakeAbsolute(context.Directory("."));
        var root       = string.Empty;
        var settings   = new DockerContainerRunSettings
        {
            Rm     = true,
            Volume = new[]
            {
                $"{currentDir}:{root}/repo",
                $"{currentDir}/tests/scripts:{root}/scripts",
                $"{currentDir}/artifacts/packages/nuget:{root}/nuget",
                $"{currentDir}/artifacts/packages/native:{root}/native",
            },
            Platform = $"linux/{arch.ToString().ToLower()}"
        };

        if (context.IsAzurePipelineBuild)
        {
            settings.Env = new[]
            {
                "TF_BUILD=true",
                $"BUILD_SOURCEBRANCH={context.EnvironmentVariable("BUILD_SOURCEBRANCH")}"
            };
        }
        if (context.IsGitHubActionsBuild)
        {
            settings.Env = new[]
            {
                "GITHUB_ACTIONS=true",
                $"GITHUB_REF={context.EnvironmentVariable("GITHUB_REF")}"
            };
        }

        return(settings);
    }