public static void PushStagingBranch() { var versionInfo = GitVersioningAliases.FetchVersion(); var stageBranchName = string.Format(StagingBranchPattern, versionInfo.MajorMinorPatch); if (!string.IsNullOrEmpty(PushTarget)) { Context.Log.Information("Publishing staging branch to public source repository."); GitAlias.Push(Context, PushTarget, stageBranchName); } }
public static void ShowVersion() { if (State == null) { throw new ArgumentNullException("state"); } var versionInfo = GitVersioningAliases.FetchVersion(); Context.Log.Information("Computed Version: " + versionInfo.FullSemVer); Context.Log.Information("- Current branch: " + State.StartingBranch); Context.Log.Information("- Staging-Branch: " + State.StagingBranch); }
public static void PrepareStagingBranch() { if (State == null) { throw new ArgumentNullException("state"); } var versionInfo = GitVersioningAliases.FetchVersion(); if (versionInfo.BranchName == ReleaseTargetBranch) { throw new Exception( "Cannot initiate a release from the release-target branch. Switch to a develop or release-xxx branch. \n" + "Based on the current version information I expect to be on branch '" + State.StagingBranch + "', but detected branch '" + versionInfo.BranchName + "' instead"); } // if on development branch, create a release branch. // if you work in a support-xx branch, treat it as your develop-branch. var stageBranchName = State.StagingBranch; if (versionInfo.BranchName == DevelopBranch) { if (GitAlias.CheckBranchExists(Context, stageBranchName)) { Context.Log.Information("Switching to staging branch from " + versionInfo.BranchName + " as branch " + stageBranchName); GitAlias.Checkout(Context, stageBranchName); } else { Context.Log.Information("Creating new staging branch from " + versionInfo.BranchName + " as branch " + stageBranchName); GitAlias.Branch(Context, stageBranchName); // We created a new branch, and that branch may be a long living branch. So lets change the version number // information once for our developers. UpdateVersionNumbers("staging"); } } else { if (versionInfo.BranchName != stageBranchName) { throw new Exception( "This command must be exist run from the development branch or an active release branch.\n " + "Based on the current version information I expect to be on branch '" + State.StagingBranch + "', but detected branch '" + versionInfo.BranchName + "' instead"); } } }
public static void UpdateVersionNumbers(string target) { var versionInfo = GitVersioningAliases.FetchVersion(); ApplyVersionNumbers(target, versionInfo.AssemblySemVer); if (!GitAlias.CheckUncommitedChanges(Context)) { GitAlias.Commit(Context, "Updating version info for " + target + " branch " + versionInfo.SemVer, true); } else { Context.Log.Information("No files have changed during version number update. Skipping commit."); } }
public static void EnsureOnReleaseBranch() { if (State == null) { throw new ArgumentNullException("state"); } Context.Log.Verbose("Validating that the build is on the release branch."); var versionInfo = GitVersioningAliases.FetchVersion(); if (versionInfo.BranchName != State.StagingBranch) { throw new Exception( "Not on the release branch. Based on the current version information I expect to be on branch '" + State.StagingBranch + "', but detected branch '" + versionInfo.BranchName + "' instead"); } }
public BuildState() { Version = GitVersioningAliases.FetchVersion(); StartingBranch = Version.BranchName; ProcessTag = "before-release-" + Guid.NewGuid(); }