diff --git a/.fleet/settings.json b/.fleet/settings.json new file mode 100644 index 0000000..b9ad294 --- /dev/null +++ b/.fleet/settings.json @@ -0,0 +1,7 @@ +{ + "files.exclude": [ + "out", + ".idea", + ".vs" + ] +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de4c3a6..68ca660 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,14 @@ jobs: submodules: recursive - name: Set up .NET uses: actions/setup-dotnet@v4.0.0 - - name: Build project + - name: Run Cake run: | - dotnet build + ./cake + - name: Upload artifacts + if: always() + uses: actions/upload-artifact@v3.1.3 + with: + name: ${{ github.workflow }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.os }}-${{ matrix.cfg }} + path: | + out/log + out/pkg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e6a0f78..31b5626 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,7 @@ env: DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_GENERATE_ASPNET_CERTIFICATE: false DOTNET_NOLOGO: true + NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} jobs: release: if: github.repository == 'vezel-dev/zig-toolsets' @@ -23,9 +24,14 @@ jobs: submodules: recursive - name: Set up .NET uses: actions/setup-dotnet@v4.0.0 - - name: Build project + - name: Run Cake run: | - dotnet build - - name: Upload NuGet packages - run: | - dotnet nuget push pkg/feed/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_TOKEN }} --skip-duplicate + ./cake upload + - name: Upload artifacts + if: always() + uses: actions/upload-artifact@v3.1.3 + with: + name: ${{ github.workflow }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.os }}-${{ matrix.cfg }} + path: | + out/log + out/pkg diff --git a/.gitignore b/.gitignore index 0a46d42..8244a8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -.vs +/out *.user -/pkg/cache/*/* -/pkg/feed/*.nupkg -bin -obj +.idea +.vs diff --git a/.vscode/settings.json b/.vscode/settings.json index 5cb3d40..38ba0ed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,7 @@ { "files.exclude": { - "**/.vs": true, - "pkg/cache/*[!_._]": true, - "pkg/feed/*.nupkg": true, - "**/bin": true, - "**/obj": true + "out": true, + "**/.idea": true, + "**/.vs": true } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index deb9065..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Build", - "presentation": { - "panel": "dedicated", - "reveal": "silent", - "revealProblems": "onProblem", - "showReuseMessage": false, - "clear": true - }, - "group": { - "kind": "build", - "isDefault": true - }, - "type": "process", - "command": "dotnet", - "args": [ - "build", - "-clp:NoSummary" - ], - "runOptions": { - "instanceLimit": 1 - }, - "problemMatcher": "$msCompile" - }, - { - "label": "Clean", - "presentation": { - "panel": "dedicated", - "reveal": "silent", - "revealProblems": "onProblem", - "showReuseMessage": false, - "clear": true - }, - "type": "process", - "command": "dotnet", - "args": [ - "clean", - "-clp:NoSummary" - ], - "runOptions": { - "instanceLimit": 1 - }, - "problemMatcher": "$msCompile" - } - ] -} diff --git a/Directory.Build.props b/Directory.Build.props index 44d024e..5bc25f9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,6 @@ - false Release true false @@ -24,11 +23,18 @@ This project packs and distributes the Zig compiler and standard library in a set of NuGet packages for each platform that .NET runs on. These packages are mainly used by the Zig SDK but can also be used by other projects. MIT - $(MSBuildThisFileDirectory)pkg/feed/ https://ziglang.org https://ziglang.org/download/$(ZigVersion)/release-notes.html false https://github.com/vezel-dev/zig-toolsets.git true + + + true + $(MSBuildThisFileDirectory)out + $([MSBuild]::MakeRelative('$(MSBuildThisFileDirectory)', '$(MSBuildProjectDirectory)')) + pub + pkg + diff --git a/README.md b/README.md index b27b953..9d44f64 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@
+ width="128" + alt="Zig Toolsets" />

@@ -97,6 +98,11 @@ The following MSBuild properties will be injected into your project: * `ZigLibPath`: Path to the Zig standard library. * `ZigDocPath`: Path to the Zig standard library documentation. +## Building + +Simply run `./cake` (a [Bash](https://www.gnu.org/software/bash) script) to +build artifacts. + ## License This project is licensed under the terms found in diff --git a/cake b/cake new file mode 100644 index 0000000..25afce3 --- /dev/null +++ b/cake @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -eou pipefail + +cd -- "$(dirname -- "$(readlink -e -- "${BASH_SOURCE[0]}")")" + +dotnet tool restore +dotnet cake zig-toolsets.cake -t "${1:-default}" "${@:2}" diff --git a/cake.config b/cake.config new file mode 100644 index 0000000..db9a181 --- /dev/null +++ b/cake.config @@ -0,0 +1,8 @@ +[Paths] +Addins=out/bld/addins +Cache=out/bld/cache +Tools=out/bld/tools + +[Settings] +SkipVerification=true +EnableScriptCache=true diff --git a/dotnet-tools.json b/dotnet-tools.json new file mode 100644 index 0000000..3f28733 --- /dev/null +++ b/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "4.0.0", + "commands": [ + "dotnet-cake" + ] + } + } +} diff --git a/nuget.config b/nuget.config index 1171405..70aca96 100644 --- a/nuget.config +++ b/nuget.config @@ -1,6 +1,6 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/pkg/cache/_._ b/pkg/cache/_._ deleted file mode 100644 index e69de29..0000000 diff --git a/pkg/feed/_._ b/pkg/feed/_._ deleted file mode 100644 index e69de29..0000000 diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index c718018..831fad3 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -39,7 +39,7 @@ This package provides the toolset for the $(ZigBuildRuntime) build platform. - diff --git a/tasks.vs.json b/tasks.vs.json index 6f99e97..d5223af 100644 --- a/tasks.vs.json +++ b/tasks.vs.json @@ -6,21 +6,21 @@ "contextType": "build", "appliesTo": "/", "type": "launch", - "command": "dotnet", - "args": [ - "build", - "-clp:NoSummary" - ] - }, - { - "taskLabel": "Clean", - "contextType": "clean", - "appliesTo": "/", - "type": "launch", - "command": "dotnet", - "args": [ - "clean", - "-clp:NoSummary" + "commands": [ + { + "command": "dotnet", + "args": [ + "tool", + "restore" + ] + }, + { + "command": "dotnet", + "args": [ + "cake", + "zig-toolsets.cake" + ] + } ] } ] diff --git a/zig-toolsets.cake b/zig-toolsets.cake new file mode 100644 index 0000000..1548688 --- /dev/null +++ b/zig-toolsets.cake @@ -0,0 +1,106 @@ +#nullable enable + +// Arguments + +var target = Argument("t", "default"); + +// Environment + +var nugetToken = EnvironmentVariable("NUGET_TOKEN"); + +// Paths + +var root = Context.Environment.WorkingDirectory; +var zigToolsetsProj = root.CombineWithFilePath("zig-toolsets.proj"); +var @out = root.Combine("out"); +var outLog = @out.Combine("log"); +var outPkg = @out.Combine("pkg"); + +// Globs + +var nugetGlob = new GlobPattern(outPkg.Combine("release").CombineWithFilePath("*.nupkg").FullPath); + +// Utilities + +DotNetMSBuildSettings ConfigureMSBuild(string target) +{ + var prefix = $"{target}_{Environment.UserName}_{Environment.MachineName}_"; + var time = DateTime.Now; + + string name; + + do + { + name = $"{prefix}{time:yyyy-MM-dd_HH_mm_ss}.binlog"; + time = time.AddSeconds(1); + } + while (System.IO.File.Exists(name)); + + return new() + { + // TODO: https://github.com/dotnet/msbuild/issues/6756 + NoLogo = true, + BinaryLogger = new() + { + Enabled = true, + FileName = outLog.CombineWithFilePath(name).FullPath, + }, + ConsoleLoggerSettings = new() + { + NoSummary = true, + }, + ArgumentCustomization = args => args.Append("-ds:false"), + }; +} + +// Tasks + +Task("default") + .IsDependentOn("build") + .IsDependentOn("pack"); + +Task("restore") + .Does(() => + DotNetRestore( + zigToolsetsProj.FullPath, + new() + { + MSBuildSettings = ConfigureMSBuild("restore"), + })); + +Task("build") + .IsDependentOn("restore") + .Does(() => + DotNetBuild( + zigToolsetsProj.FullPath, + new() + { + MSBuildSettings = ConfigureMSBuild("build"), + NoRestore = true, + })); + +Task("pack") + .IsDependentOn("build") + .Does(() => + DotNetPack( + zigToolsetsProj.FullPath, + new() + { + MSBuildSettings = ConfigureMSBuild("pack"), + NoBuild = true, + })); + +Task("upload") + .WithCriteria(BuildSystem.GitHubActions.Environment.Workflow.Ref.StartsWith("refs/tags/v")) + .IsDependentOn("pack") + .Does(() => + DotNetNuGetPush( + nugetGlob.Pattern, + new() + { + Source = "https://api.nuget.org/v3/index.json", + ApiKey = nugetToken, + SkipDuplicate = true, + })); + +RunTarget(target);