diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 75851ac..203e245 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,12 +23,14 @@ jobs: run: dotnet workload restore - name: Restore dependencies run: dotnet restore - - name: Set Assembly Version - run: ./build.sh --task=GitVersion --configuration=Release + - name: .NET project version updater + uses: vers-one/dotnet-project-version-updater@v1.7 + with: + files: | + "Float.Core/Float.Core.csproj", "**/*.nuspec", "**/AssemblyInfo.cs" + version: ${{ github.event.release.name }} - name: Build Library run: dotnet build ./Float.Core/Float.Core.csproj --configuration Release --no-restore - - name: Update Version - run: sed -i "s/<\/Version>/${{ github.event.release.name }}<\/Version>/" ./Float.Core/Float.Core.csproj - name: Pack and Upload run: dotnet pack --configuration Release --no-restore - name: Deploy to NuGet diff --git a/build.cake b/build.cake deleted file mode 100644 index 849ff03..0000000 --- a/build.cake +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env cake - -// Required namespaces - -using System; - -// Tools and addins - -#tool nuget:?package=NUnit.ConsoleRunner&version=3.12.0 -#addin nuget:?package=Cake.Coverlet&version=2.5.4 -#addin nuget:?package=Cake.ExtendedNuGet&version=4.0.2 -#addin nuget:?package=Cake.GitVersioning&version=3.4.244 -#addin nuget:?package=Cake.Git&version=1.0.1 - -// Parameters and arguments - -readonly string task = Argument("task", "Build"); -readonly string projectName = Argument("projectName", "Float.Core"); -readonly string configuration = Argument("configuration", "Debug"); -readonly Uri nugetUrl = Argument("nugetUrl", null); -readonly string nugetToken = Argument("nugetToken", string.Empty); - -// Derived global parameters - -readonly var root = MakeAbsolute(new DirectoryPath("./")); -readonly var isReleaseBuild = configuration == "Release"; -readonly var netAssemblyInfoLocation = File($"./{projectName}/Properties/AssemblyInfo.cs"); -readonly var testProjectName = $"{projectName}.Tests"; -readonly var solution = $"{projectName}.sln"; - -readonly var project = new -{ - Main = $"./{projectName}/{projectName}.csproj", - Test = $"./{testProjectName}/{testProjectName}.csproj", -}; - -// Parameters to be defined later - -var assemblyVersion = "0.0.0.0"; -var packageVersion = "0.0.0.0-feat"; - -// Tasks - -Task("Clean") - .Does(() => - { - CleanDirectories(GetDirectories("./.vs")); - CleanDirectories(GetDirectories("./**/obj")); - CleanDirectories(GetDirectories("./**/bin")); - }); - -Task("RestorePackages") - .IsDependentOn("Clean") - .Does(() => - { - NuGetRestore(solution); - }); - -Task("GitVersion") - .Does(() => - { - var gitVersion = GitVersioningGetVersion(); - - assemblyVersion = $"{gitVersion.AssemblyVersion}"; - packageVersion = $"{gitVersion.NuGetPackageVersion}"; - - Information($"Assembly version: {assemblyVersion}"); - Information($"NuGet version: {packageVersion}"); - Information($"Informational version: {gitVersion.AssemblyInformationalVersion}"); - - var visible = isReleaseBuild - ? new string[] {} - : new [] { testProjectName }; - - CreateAssemblyInfo(netAssemblyInfoLocation, new AssemblyInfoSettings - { - Version = $"{gitVersion.AssemblyVersion}", - FileVersion = $"{gitVersion.AssemblyFileVersion}", - InformationalVersion = $"{gitVersion.AssemblyInformationalVersion}", - ComVisible = true, - InternalsVisibleTo = visible, - CustomAttributes = new [] - { - new AssemblyInfoCustomAttribute - { - NameSpace = "System.Resources", - Name = "NeutralResourcesLanguage", - Value = "en", - }, - }, - }); - }); - -Task("Build") - .IsDependentOn("GitVersion") - .Does(() => - { - DotNetCoreBuild(project.Main, new DotNetCoreBuildSettings - { - Configuration = configuration, - NoIncremental = true, - NoRestore = true, - MSBuildSettings = new DotNetCoreMSBuildSettings() - .SetVersion(packageVersion) - }); - }); - -Task("Test") - .IsDependentOn("Build") - .WithCriteria(!isReleaseBuild) - .Does(() => - { - var testSettings = new DotNetCoreTestSettings - { - Loggers = new[] { "trx" }, - }; - - var coverletSettings = new CoverletSettings - { - CollectCoverage = true, - CoverletOutputFormat = CoverletOutputFormat.opencover, - }; - - DotNetCoreTest(project.Test, testSettings, coverletSettings); - }); - -Task("Pack") - .IsDependentOn("Build") - .Does(() => - { - DotNetCorePack(project.Main, new DotNetCorePackSettings - { - Configuration = configuration, - NoBuild = true, - NoRestore = true, - IncludeSymbols = true, - MSBuildSettings = new DotNetCoreMSBuildSettings() - .SetVersion(packageVersion) - }); - - var packPath = File($"./{projectName}/bin/{configuration}/netstandard2.0/{projectName}.dll"); - var packHash = CalculateFileHash(packPath).ToHex(); - var packSize = $"{FileSize(packPath)}"; - Information($" Assembly hash: {packHash}"); - Information($" Assembly size: {packSize} bytes"); - }); - -Task("Deploy") - .IsDependentOn("Test") - .IsDependentOn("Pack") - .Does(() => - { - if (!HasArgument("nugetUrl")) - { - throw new Exception("--nugetUrl is required."); - } - - if (!HasArgument("nugetToken")) - { - throw new Exception("--nugetToken is required."); - } - - if (!(GetFiles($"./{projectName}/bin/{configuration}/*[!symbols].nupkg").First() is FilePath packageFile)) - { - throw new Exception("Unable to find NuGet package file."); - } - - var packageId = GetNuGetPackageId(packageFile); - var packageVer = GetNuGetPackageVersion(packageFile); - - Information("Publishing NuGet Package"); - Information($"Package ID: {packageId}"); - Information($"Package Version: {packageVer}"); - - PublishNuGets( - nugetUrl.AbsoluteUri, - nugetToken, - new PublishNuGetsSettings - { - }, - new [] - { - $"{packageFile}", - } - ); - }); - -// Run - -RunTarget(task); diff --git a/build.sh b/build.sh deleted file mode 100755 index 1e1522c..0000000 --- a/build.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env bash - -set -eEuo pipefail -shopt -s extglob; - -########################################################################## -# This is the Cake bootstrapper script for Linux and OS X. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## - -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -ADDINS_DIR=$TOOLS_DIR/Addins -MODULES_DIR=$TOOLS_DIR/Modules -NUGET_EXE=$TOOLS_DIR/nuget.exe -MANIFEST_FILE=$SCRIPT_DIR/.config/dotnet-tools.json -PACKAGES_CONFIG=$TOOLS_DIR/packages.config -PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum -ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config -MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config - -export CAKE_PATHS_TOOLS=$TOOLS_DIR -export CAKE_PATHS_ADDINS=$ADDINS_DIR -export CAKE_PATHS_MODULES=$MODULES_DIR - -# Define md5sum or md5 depending on Linux/OSX -MD5_EXE= -if [[ "$(uname -s)" == "Darwin" ]]; then - MD5_EXE="md5 -r" -else - MD5_EXE="md5sum" -fi - -# Define default arguments. -SCRIPT=$SCRIPT_DIR/build.cake -CAKE_ARGUMENTS=() - -# Parse arguments. (modified heavily by srichey) -while [ ${#} -gt 0 ]; do - case "${1}" in - -s|--script) - SCRIPT="${2}" - ;; - \-\-+([a-zA-Z])=+(*)) # double dash flags ONLY (mainly to avoid parsing bugs) - if [[ "${1}" =~ "=" ]]; then # check if we have an equals sign - IFS='='; ARRAY=(${1}); unset IFS; - - # check that the value after the = is valid - if [ -z "${ARRAY[1]-}" ]; then - echo "Invalid value for flag: \"${1}\"" - exit 1 - fi - - CAKE_ARGUMENTS+=("${1}") - elif [ -z "${2:-}" ]; then # check if 2 is bound - # if not, we better have an equals sign - if [[ "${1}" =~ "=" ]]; then - IFS='='; ARRAY=(${1}); unset IFS; - - # check that the value after the = is valid - if [ -z ${ARRAY[1]-} ]; then - echo "Invalid value for flag: \"${1}\"" - exit 1 - fi - - CAKE_ARGUMENTS+=("${1}") - else - echo "Expected \"=\" or another argument for flag \"${1}\"" - exit 1 - fi - else # if 2 is bound but we have an equals, assume "--flag value" - echo "Please provide an equals sign to tie flags to their values." - exit 1 - fi - ;; - \-+([A-Za-z])=+(*)) # single dash flags - echo "Please use double dash flags: single dashes are unsupported." - exit 1 - ;; - \-\-+([a-zA-Z])) # double dash, implicitly true - CAKE_ARGUMENTS+=("${1}=true") - ;; - *) - echo "Error: unrecognized argument ${1}" - exit 1 - ;; - esac - shift -done - -# Make sure the tools folder exist. -if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" -fi - -# Make sure that packages.config exist. -if [ ! -f "$TOOLS_DIR/packages.config" ]; then - echo "Downloading packages.config..." - curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occurred while downloading packages.config." - exit 1 - fi -fi - -# Download NuGet if it does not exist. -if [ ! -f "$NUGET_EXE" ]; then - echo "Downloading NuGet..." - curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - if [ $? -ne 0 ]; then - echo "An error occurred while downloading nuget.exe." - exit 1 - fi -fi - -# Restore tools from NuGet. -pushd "$TOOLS_DIR" >/dev/null -if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then - find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf -fi - -mono "$NUGET_EXE" install -ExcludeVersion -if [ $? -ne 0 ]; then - echo "Could not restore NuGet tools." - exit 1 -fi - -$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5" - -popd >/dev/null - -# Restore addins from NuGet. -if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then - pushd "$ADDINS_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet addins." - exit 1 - fi - - popd >/dev/null -fi - -# Restore modules from NuGet. -if [ -f "$MODULES_PACKAGES_CONFIG" ]; then - pushd "$MODULES_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet modules." - exit 1 - fi - - popd >/dev/null -fi - -# Restore dotnet tools from NuGet. -if [ -f "${MANIFEST_FILE}" ]; then - dotnet tool restore - - if [ $? -ne 0 ]; then - echo "Could not restore dotnet tools." - exit 1 - fi -fi - -# Make sure that Cake has been installed as a dotnet tool. -dotnet cake --version - -if [ $? -ne 0 ]; then - echo "Unable to run Cake as a dotnet tool." - exit 1 -fi - -# Logging added by srichey -if [[ "${CAKE_ARGUMENTS[@]+"${CAKE_ARGUMENTS[@]}"}" ]]; then - echo "Bootstrapper parsed the following arguments:" - - for arg in "${CAKE_ARGUMENTS[@]}"; do - echo " $arg" - done -else - echo "No arguments provided." -fi - -echo "Bootstrap completing, starting Cake..." - -# Start Cake -exec dotnet cake "${SCRIPT}" "${CAKE_ARGUMENTS[@]+"${CAKE_ARGUMENTS[@]}"}" diff --git a/readme.md b/readme.md index d4ea2af..0be29f3 100644 --- a/readme.md +++ b/readme.md @@ -2,25 +2,6 @@ This is a collection of common utilities used by Float projects. -## Building - -This project can be built using [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/) or [Cake](https://cakebuild.net/). It is recommended that you build this project by invoking the bootstrap script: - -First you must restore the nuget libraries - - dotnet restore - - ./build.sh - -There are a number of optional arguments that can be provided to the bootstrapper that will be parsed and passed on to Cake itself. See the [Cake build file](./build.cake) in order to identify all supported parameters. - - ./build.sh \ - --task=Build \ - --projectName=Float.Core \ - --configuration=Debug \ - --nugetUrl=https://nuget.org \ - --nugetToken=#### - ## License All content in this repository is shared under an MIT license. See [license.md](./license.md) for details. diff --git a/tools/packages.config b/tools/packages.config deleted file mode 100644 index 2a03746..0000000 --- a/tools/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - -