Skip to content

Commit

Permalink
Merge pull request #380 from Inxton/379-packages-should-be-only-publi…
Browse files Browse the repository at this point in the history
…shed-on-demand

packages should be only published on demand
  • Loading branch information
PTKu authored Jan 28, 2025
2 parents a732929 + 66b176e commit 9f2238d
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 21 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: dev

on:
push:
branches: [ "dev" ]
paths:
- 'src/**'
- 'cake/**'
- '.github/**'
# push:
# branches: [ "dev" ]
# paths:
# - 'src/**'
# - 'cake/**'
# - '.github/**'
workflow_dispatch:

inputs:
publish:
type: boolean
required: false
default: false
description: "Set to 'true' to publish packages"
jobs:
build:
strategy:
Expand All @@ -29,12 +34,17 @@ jobs:
- name: "Run build script"
env:
GH_TOKEN : ${{ secrets.GH_TOKEN }}
run: dotnet run --project cake/Build.csproj --do-test true --do-pack true --test-level 2 --do-publish true --framework net9.0
run: dotnet run --project cake/Build.csproj --do-test --do-pack --test-level 2 --framework net9.0
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test report
path: 'TestResults/*.xml'
reporter: dotnet-trx

- name: "Publish packages"
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true' }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_USER: ${{ secrets.GH_USER }}
run: dotnet run --project cake/Build.csproj --do-publish-only --do-publish --do-publish-release --framework net9.0
2 changes: 1 addition & 1 deletion cake/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void CleaUpAllBinsAndObjs()
}

public void CheckLicenseComplianceInArtifacts()
{
{
//var licensedFiles = Directory.EnumerateFiles(Path.Combine(context.RootDir, "apax", ".apax", "packages"),
var licensedFiles = Directory.EnumerateFiles(Path.Combine(this.ScrDir, "apax", "stc"),
"AX.*.*",
Expand Down
3 changes: 3 additions & 0 deletions cake/BuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ public class BuildParameters

[Option('r', "do-publish-release", Required = false, Default = false, HelpText = "Publishes release on GH")]
public bool DoPublishRelease { get; set; }

[Option('o', "do-publish-only", Required = false, Default = false, HelpText = "Perfoms only publishing tasks from previously created artefacts.")]
public bool DoPublishOnly { get; set; }
}
5 changes: 5 additions & 0 deletions cake/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ internal class Helpers
public static readonly IEnumerable<string> PublishInternal = new List<string>() { "dev", "main", "master", "release" };
public static readonly IEnumerable<string> PublishExternal = new List<string>() { "main", "master", "release" };

public static bool CanReleaseOnDemand()
{
return true;
}

public static bool CanReleaseInternal()
{
return PublishInternal.Any(predicate =>
Expand Down
44 changes: 34 additions & 10 deletions cake/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,19 @@ public static int Main(string[] args)

[TaskName("CleanUp")]
public sealed class CleanUpTask : FrostingTask<BuildContext>
{



{
public override void Run(BuildContext context)
{
if(context.BuildParameters.DoPublishOnly)
{
context.Log.Warning($"Skipping. Preforming publish only");
return;
}

context.DotNetClean(Path.Combine(context.ScrDir, "AXSharp.sln"), new DotNetCleanSettings() { Verbosity = context.BuildParameters.Verbosity });
context.CleaUpAllBinsAndObjs();
context.CleanDirectory(context.Artifacts);
context.CleanDirectory(context.TestResults);


context.CleanDirectory(context.TestResults);
}
}

Expand All @@ -83,6 +84,12 @@ public sealed class ProvisionTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
if (context.BuildParameters.DoPublishOnly)
{
context.Log.Warning($"Skipping. Preforming publish only");
return;
}

context.DotNetBuildSettings.MSBuildSettings.Properties.Add("NoWarn", new List<string>()
{ "1234;2345;8602;10012;8618;0162;8605;1416;3270;1504;8600;8618;" +
"CS0618;CS1591;BL0007;BL0005;CA1416;CA2200;CS0105;CS0108;CS0109;CS0162;CS0168;CS0169;CS219;CS0414;CS0436;CS0472;CS0618;CS1591;CS1998;CS8604;" +
Expand Down Expand Up @@ -125,7 +132,13 @@ public sealed class BuildTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{


if (context.BuildParameters.DoPublishOnly)
{
context.Log.Warning($"Skipping. Preforming publish only");
return;
}

context.DotNetBuild(Path.Combine(context.ScrDir, "AXSharp.compiler\\src\\ixc\\AXSharp.ixc.csproj"), context.DotNetBuildSettings);

var axprojects = new List<string>()
Expand Down Expand Up @@ -160,6 +173,11 @@ public sealed class TestsTask : FrostingTask<BuildContext>
// Tasks can be asynchronous
public override void Run(BuildContext context)
{
if (context.BuildParameters.DoPublishOnly)
{
context.Log.Warning($"Skipping. Preforming publish only");
return;
}

if (!context.BuildParameters.DoTest)
{
Expand Down Expand Up @@ -223,7 +241,13 @@ public sealed class CreateArtifactsTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
if (!context.BuildParameters.DoPublish)
if (context.BuildParameters.DoPublishOnly)
{
context.Log.Warning($"Skipping. Preforming publish only");
return;
}

if (!context.BuildParameters.DoPack)
{
context.Log.Warning($"Skipping packaging.");
return;
Expand Down Expand Up @@ -272,7 +296,7 @@ public override void Run(BuildContext context)
public sealed class LicenseComplianceCheckTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
{
context.CheckLicenseComplianceInArtifacts();
}
}
Expand Down
13 changes: 13 additions & 0 deletions cake/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"profiles": {
"WSL": {
"commandName": "WSL2",
"distributionName": ""
},
"PublishOnly": {
"commandName": "Project",
"commandLineArgs": "--do-publish-only --do-publish --do-publish-release",
"workingDirectory": "C:\\W\\Develop\\gh\\inxton\\ax\\axsharp\\cake"
}
}
}
2 changes: 1 addition & 1 deletion pack-only.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# run build

dotnet run --project cake/Build.csproj --do-pack --test-level 1
dotnet run --project cake/Build.csproj --do-pack --test-level 1 --framework net9.0
exit $LASTEXITCODE;

0 comments on commit 9f2238d

Please sign in to comment.