]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Add CI
authorjs6pak <kubastaron@hotmail.com>
Sun, 18 Dec 2022 18:43:40 +0000 (19:43 +0100)
committerjs6pak <kubastaron@hotmail.com>
Sun, 18 Dec 2022 19:08:26 +0000 (20:08 +0100)
.github/workflows/main.yml [new file with mode: 0644]
Directory.Build.props [new file with mode: 0644]
Hazel/Hazel.csproj
Impostor.Hazel.Abstractions/Impostor.Hazel.Abstractions.csproj
build.cake [new file with mode: 0644]

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644 (file)
index 0000000..3593f34
--- /dev/null
@@ -0,0 +1,32 @@
+name: CI
+
+on: [ "push", "pull_request" ]
+
+jobs:
+  build:
+    runs-on: ubuntu-20.04
+
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          submodules: true
+
+      - name: Setup .NET
+        uses: actions/setup-dotnet@v3
+        with:
+          dotnet-version: 7.x
+
+      - name: Run the Cake script
+        uses: cake-build/cake-action@94fa55b4f83cee90f2621654eba6a056ae71df90
+        with:
+          verbosity: Diagnostic
+
+      - uses: actions/upload-artifact@v3
+        with:
+          name: nuget packages
+          path: ./*/bin/Release*/*.nupkg
+
+      - name: Push NuGet package
+        if: github.ref_type == 'tag'
+        run: |
+          dotnet nuget push ./{Hazel,Impostor.Hazel.Abstractions}/bin/Release/*.nupkg --source ${{ secrets.NUGET_SOURCE }} --api-key ${{ secrets.NUGET_KEY }}
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644 (file)
index 0000000..3c32f7e
--- /dev/null
@@ -0,0 +1,11 @@
+<Project>
+    <PropertyGroup>
+        <Authors>Impostor</Authors>
+        <PackageLicenseExpression>MIT</PackageLicenseExpression>
+        <RepositoryUrl>https://github.com/Impostor/Impostor.Hazel</RepositoryUrl>
+        <RepositoryType>git</RepositoryType>
+
+        <VersionPrefix>1.0.0</VersionPrefix>
+        <VersionSuffix>dev</VersionSuffix>
+    </PropertyGroup>
+</Project>
\ No newline at end of file
index e3f17261ad8c6666632b875146f8af0d49915712..021ad27098d6b7f9090353ff29bc5694a6be023b 100644 (file)
@@ -6,6 +6,7 @@
     <DefineConstants>HAZEL_BAG</DefineConstants>
     <RootNamespace>Impostor.Hazel</RootNamespace>
     <AssemblyName>Impostor.Hazel</AssemblyName>
+    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
   </PropertyGroup>
 
   <ItemGroup>
index 6836c6808fb21d00e7e92c8af606745302a3cb54..6d3060682683f11ebda7ba26cc8a9869c82f2744 100644 (file)
@@ -4,6 +4,7 @@
         <TargetFramework>net7.0</TargetFramework>
         <ImplicitUsings>enable</ImplicitUsings>
         <Nullable>enable</Nullable>
+        <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
     </PropertyGroup>
 
 </Project>
diff --git a/build.cake b/build.cake
new file mode 100644 (file)
index 0000000..bfac352
--- /dev/null
@@ -0,0 +1,28 @@
+var target = Argument("target", "Build");
+
+var workflow = BuildSystem.GitHubActions.Environment.Workflow;
+var buildId = workflow.RunNumber;
+var tag = workflow.RefType == GitHubActionsRefType.Tag ? workflow.RefName : null;
+
+Task("Build")
+    .Does(() =>
+{
+    var settings = new DotNetBuildSettings
+    {
+        Configuration = "Release",
+        MSBuildSettings = new DotNetMSBuildSettings(),
+    };
+
+    if (tag != null) 
+    {
+        settings.MSBuildSettings.Version = tag;
+    }
+    else if (buildId != 0)
+    {
+        settings.MSBuildSettings.VersionSuffix = "ci." + buildId;
+    }
+
+    DotNetBuild(".", settings);
+});
+
+RunTarget(target);