Skip to content

[2.0] NUKE and much-needed CI work #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,22 @@ on:

jobs:
Build:
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100-rc.2.20479.15
- name: Test
run: dotnet test --verbosity normal
dotnet-version: 5.0.100
- name: Setup NUKE
run: dotnet tool install Nuke.GlobalTool --global
- name: Pack
run: dotnet pack --configuration Release --version-suffix build$GITHUB_RUN_NUMBER.0 -p:ContinuousIntegrationBuild=true
- name: Setup NuGet
if: ${{ github.repository == 'Ultz/Silk.NET' && github.event_name != 'pull_request' }}
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'
- name: Setup Feed
if: ${{ github.repository == 'Ultz/Silk.NET' && github.event_name != 'pull_request' }}
run: nuget sources add -Name Experimental -Source https://pkgs.dev.azure.com/UltzOS/Silk.NET/_packaging/Experimental/nuget/v3/index.json -username ${{ secrets.AZDO_ARTIFACTS_USERNAME }} -password ${{ secrets.AZDO_ARTIFACTS_TOKEN }}
- name: Push Experimental Packages
# TODO build native mixins such as BuildLibSilkDroid
run: nuke Pack --configuration Release --msbuild-properties VersionSuffix=build$GITHUB_RUN_NUMBER.0 ContinuousIntegrationBuild=true --feature-sets Android iOS
- name: Test
run: nuke Test --skip Clean Restore Compile
- name: Push to NuGet
if: ${{ github.repository == 'Ultz/Silk.NET' && github.event_name != 'pull_request' }}
run: nuget push "build/output_packages/*.nupkg" -Source Experimental -ApiKey ${{ secrets.AZDO_ARTIFACTS_TOKEN }}
run: nuke PushToNuGet --skip Clean Restore Pack --nuget-feed https://pkgs.dev.azure.com/UltzOS/Silk.NET/_packaging/Experimental/nuget/v3/index.json --nuget-username ${{ secrets.AZDO_ARTIFACTS_USERNAME }} --nuget-password ${{ secrets.AZDO_ARTIFACTS_TOKEN }} --nuget-api-key az
22 changes: 7 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,16 @@ on:

jobs:
Publish:

runs-on: ubuntu-latest

runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100-rc.2.20479.15
- name: Install dependencies
run: dotnet restore
- name: Pack
run: dotnet pack --configuration Release -p:ContinuousIntegrationBuild=true
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'
dotnet-version: 5.0.100
- name: Setup NUKE
run: dotnet tool install Nuke.GlobalTool --global
- name: Push to NuGet
run: nuget push "build/output_packages/Silk.NET.*.nupkg" -SkipDuplicate -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }}
run: nuke PushToNuGet --configuration Release --msbuild-properties ContinuousIntegrationBuild=true --feature-sets Android iOS --nuget-api-key ${{ secrets.NUGET_TOKEN }}
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ out/
# release/

# Gradle files
.gradle/
build/
**/.gradle/

# Local configuration file (sdk path, etc)
local.properties
Expand Down Expand Up @@ -467,6 +466,9 @@ gradle-app.setting
# gradle/wrapper/gradle-wrapper.properties

### Gradle Patch ###
**/build/
src/**/build/

# End of https://www.toptal.com/developers/gitignore/api/android,java,gradle

# Silk.NET Build System
build/sln
1 change: 1 addition & 0 deletions .nuke
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Silk.NET.sln
23 changes: 22 additions & 1 deletion Silk.NET.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30517.126
MinimumVisualStudioVersion = 15.0.26124.0
Expand Down Expand Up @@ -322,6 +322,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Windowing.Sdl.iOS"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iOS", "iOS", "{488775D1-32CC-46D7-8DD7-BB331EC659B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.NUKE", "build\nuke\Silk.NET.NUKE.csproj", "{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.NUKE.SshAgent", "src\Core\Silk.NET.NUKE.SshAgent\Silk.NET.NUKE.SshAgent.csproj", "{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -332,6 +336,9 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD24E9FF-1097-4777-A418-F2D88C558665}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD24E9FF-1097-4777-A418-F2D88C558665}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD24E9FF-1097-4777-A418-F2D88C558665}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -1959,6 +1966,18 @@ Global
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2}.Release|x64.Build.0 = Release|Any CPU
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2}.Release|x86.ActiveCfg = Release|Any CPU
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2}.Release|x86.Build.0 = Release|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x64.ActiveCfg = Debug|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x64.Build.0 = Debug|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x86.ActiveCfg = Debug|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x86.Build.0 = Debug|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|Any CPU.Build.0 = Release|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x64.ActiveCfg = Release|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x64.Build.0 = Release|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x86.ActiveCfg = Release|Any CPU
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2108,6 +2127,8 @@ Global
{8669819B-654F-4E41-9030-1CCA56D64E88} = {DFA0E841-33E5-4533-AF00-964E21A141B8}
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2} = {488775D1-32CC-46D7-8DD7-BB331EC659B9}
{488775D1-32CC-46D7-8DD7-BB331EC659B9} = {23324041-2076-477C-A4BF-B385B8066C6C}
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490}
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D}
Expand Down
35 changes: 0 additions & 35 deletions azure-pipelines.yml

This file was deleted.

6 changes: 6 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:; set -eo pipefail
:; ./build.sh "$@"
:; exit $?

@ECHO OFF
powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.ps1 %*
69 changes: 69 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)

Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"

Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

###########################################################################
# CONFIGURATION
###########################################################################

$BuildProjectFile = "$PSScriptRoot\build\nuke\Silk.NET.NUKE.csproj"
$TempDirectory = "$PSScriptRoot\\.tmp"

$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "Current"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1

###########################################################################
# EXECUTION
###########################################################################

function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}

# If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) {
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
$DotNetVersion = $DotNetGlobal.sdk.version
}
}

# If dotnet is installed locally, and expected version is not set or installation matches the expected version
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
(!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path
}
else {
$DotNetDirectory = "$TempDirectory\dotnet-win"
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"

# Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)

# Install by channel or version
if (!(Test-Path variable:DotNetVersion)) {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
} else {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
}

Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
62 changes: 62 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

echo $(bash --version 2>&1 | head -n 1)

set -eo pipefail
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)

###########################################################################
# CONFIGURATION
###########################################################################

BUILD_PROJECT_FILE="$SCRIPT_DIR/build/nuke/Silk.NET.NUKE.csproj"
TEMP_DIRECTORY="$SCRIPT_DIR//.tmp"

DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
DOTNET_CHANNEL="Current"

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

###########################################################################
# EXECUTION
###########################################################################

function FirstJsonValue {
perl -nle 'print $1 if m{"'$1'": "([^"]+)",?}' <<< ${@:2}
}

# If global.json exists, load expected version
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE"))
if [[ "$DOTNET_VERSION" == "" ]]; then
unset DOTNET_VERSION
fi
fi

# If dotnet is installed locally, and expected version is not set or installation matches the expected version
if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then
export DOTNET_EXE="$(command -v dotnet)"
else
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"

# Download install script
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
mkdir -p "$TEMP_DIRECTORY"
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
chmod +x "$DOTNET_INSTALL_FILE"

# Install by channel or version
if [[ -z ${DOTNET_VERSION+x} ]]; then
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
fi

echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"

"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
11 changes: 11 additions & 0 deletions build/nuke/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*.cs]
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_require_accessibility_modifiers = never:warning

csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
Loading