Add ability to generate more complex workflows with multiple stages/jobs
Description
The existing Workflow/Job attributes are extremely limiting. As implemented to produce more than one job per triggered workflow in GitHubActions you would need to add multiple OS Images... One problem with this is that it assumes you want to run the same exact target each time.
A far better scenario is one in which I can create 1-N GitHub Workflows each of which could have 1-N Jobs, Jobs may define relationships such as a particular Job needs other jobs to pass before it can start, and Jobs may need to download artifacts from other jobs. This is currently implemented in the Nuke.Maui repo. You'll notice that the sample generates 2 workflows, one for CI each time the master branch is updated, and on for PRs. There are several jobs defined including one to publish the library which is excluded from the PRs while the other jobs are declared once and reused across multiple workflows.
Usage Example
[GitHubWorkflow("ci",
FetchDepth = 0,
AutoGenerate = true,
OnPushBranches = new[] { MasterBranch },
JobNames = new[] { "android-build", "ios-build", "compile-lib", "publish-internal" } )]
[GitHubWorkflow("pr",
OnPullRequestBranches = new[] { MasterBranch },
FetchDepth = 0,
AutoGenerate = true,
JobNames = new[] { "android-build", "ios-build", "compile-lib" } )]
[WorkflowJob(
Name = "android-build",
//ArtifactName = "android",
Image = GitHubActionsImage.WindowsLatest,
InvokedTargets = new[] { nameof(IHazAndroidBuild.CompileAndroid) },
ImportSecrets = new[]
{
nameof(IHazAndroidKeystore.AndroidKeystoreName),
nameof(IHazAndroidKeystore.AndroidKeystoreB64),
nameof(IHazAndroidKeystore.AndroidKeystorePassword)
})]
[WorkflowJob(
Name = "ios-build",
//ArtifactName = "ios",
Image = GitHubActionsImage.MacOsLatest,
InvokedTargets = new[] { nameof(IHazIOSBuild.CompileIos) },
ImportSecrets = new[]
{
nameof(IHazAppleCertificate.P12B64),
nameof(IHazAppleCertificate.P12Password),
nameof(IRestoreAppleProvisioningProfile.AppleIssuerId),
nameof(IRestoreAppleProvisioningProfile.AppleKeyId),
nameof(IRestoreAppleProvisioningProfile.AppleAuthKeyP8),
nameof(IRestoreAppleProvisioningProfile.AppleProfileId)
})]
[WorkflowJob(
Name = "compile-lib",
ArtifactName = "nuget",
InvokedTargets = new[] { nameof(ICompileLibrary.CompileLib), "--solution AvantiPoint.Nuke.Maui.sln" } )]
[WorkflowJob(
Name = "publish-internal",
Needs = new[] { "compile-lib", "android-build", "ios-build" },
DownloadArtifacts = new[] { "nuget" },
ImportSecrets = new[]
{
nameof(IPublishInternal.InHouseNugetFeed),
nameof(IPublishInternal.InHouseApiKey),
$"{nameof(ICodeSignNuget.CodeSignCertificate)}=CODESIGNCERTIFICATE",
$"{nameof(ICodeSignNuget.CodeSignClientId)}=CODESIGNCLIENTID",
$"{nameof(ICodeSignNuget.CodeSignClientSecret)}=CODESIGNCLIENTSECRET",
$"{nameof(ICodeSignNuget.CodeSignKeyVault)}=CODESIGNKEYVAULT",
$"{nameof(ICodeSignNuget.CodeSignTenantId)}=CODESIGNTENANTID"
},
InvokedTargets = new[] { nameof(IPublishInternal.PublishNuGet) })]
class Build : MauiBuild, ICompileLibrary, IPublishInternal, ICodeSignNuget
{
public static int Main () => Execute<Build>();
const string MasterBranch = "master";
public GitHubActions GitHubActions => GitHubActions.Instance;
[NerdbankGitVersioning]
readonly NerdbankGitVersioning NerdbankVersioning;
public override string ApplicationDisplayVersion => NerdbankVersioning.NuGetPackageVersion;
public override long ApplicationVersion => IsLocalBuild ? DateTimeOffset.Now.ToUnixTimeSeconds() / 60 : GitHubActions.RunId;
}
Alternative
Currently multiple YAML files need to be generated. To bring these into a single file is a manual process.