Skip to content

Commit

Permalink
(build) Update to latest edition of cake.recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Sep 14, 2020
1 parent e60a28e commit 4a832d9
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 319 deletions.
37 changes: 4 additions & 33 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,16 @@
image:
# - macos
- Ubuntu
- Visual Studio 2017
image: Visual Studio 2019
matrix:
fast_finish: true
environment:
APPVEYOR_YML_DISABLE_PS_LINUX: true
branches:
except:
- ci/travis
- /dependabot\/.*/
skip_commits:
files:
- "*.md"
- "LICENSE"
- ".travis.yml"

for:
-
matrix:
only:
- image: Ubuntu
environment:
AZURE_SOURCE:
GITHUB_PASSWORD:
GITTER_TOKEN:
GPR_SOURCE:
MYGET_API_KEY:
NUGET_API_KEY:
SLACK_TOKEN:
TWITTER_ACCESS_TOKEN:
TWITTER_CONSUMER_KEY:
WYAM_ACCESS_TOKEN:

skip_tags: true
install:
- git submodule update --init
- sudo -H pip install transifex-client
- sudo apt-get update || echo "Update failed, ignoring..."
- sudo apt-get install -y libgit2-dev
- ".github/**/*.yml"

install:
- git submodule update --init
Expand All @@ -50,8 +22,7 @@ build: off
test: off

build_script:
- pwsh: ./build.ps1 --target=ContinuousIntegration --verbosity=Diagnostic
- pwsh: ./build.ps1 --target=CI --verbosity=Diagnostic

cache:
- "tools -> build.config,setup.cake,.build/sonarcloud.cake"
- ".dotnet -> build.config"
- "tools -> .build/dotnet-tools.json,setup.cake,.build/sonarcloud.cake"
4 changes: 2 additions & 2 deletions .build/sonarcloud.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Task("SonarCloud-Begin")
.WithCriteria(() => HasEnvironmentVariable("SONARCLOUD_TOKEN"), "Missing sonar cloud token environment variable")
.WithCriteria(() => HasEnvironmentVariable("SONARCLOUD_ORGANIZATION"), "Missing sonar cloud organization environment variable")
.WithCriteria(() => HasEnvironmentVariable("SONARCLOUD_PROJECT_KEY"), "Missing sonar cloud project key environment variable")
.Does(() => RequireTool(SonarQubeTool,
.Does<BuildVersion>((version) => RequireTool(SonarQubeTool,
() =>
{
Information("Starting SonarCloud analysing");
Expand All @@ -31,7 +31,7 @@ Task("SonarCloud-Begin")
{ "TEMP_ORGANIZATION", EnvironmentVariable("SONARCLOUD_ORGANIZATION") },
{ "TEMP_OPENCOVER_FILTER", BuildParameters.Paths.Files.TestCoverageOutputFilePath.ToString().Replace(".xml", "*.xml") },
{ "TEMP_TOKEN", EnvironmentVariable("SONARCLOUD_TOKEN") },
{ "TEMP_VERSION", BuildParameters.Version.SemVersion },
{ "TEMP_VERSION", version.SemVersion },
{ "TEMP_TEST_RESULTS", BuildParameters.Paths.Directories.TestResults.CombineWithFilePath("TestResults.xml").ToString() },
});
}));
Expand Down
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "0.38.4",
"commands": [
"dotnet-cake"
]
}
}
}
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build

on:
push:
branches:
- master
- develop
- "release/**"
- "hotfix/**"
- "feature/**"
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
env:
AZURE_PASSWORD: ${{ secrets.AZURE_PASSWORD }}
AZURE_SOURCE: ${{ secrets.AZURE_SOURCE }}
AZURE_USER: ${{ secrets.AZURE_USER }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITTER_ROOM_ID: ${{ secrets.GITTER_ROOM_ID }}
GITTER_TOKEN: ${{ secrets.GITTER_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
NUGET_SOURCE: "https://api.nuget.org/v3/index.json"
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
WYAM_ACCESS_TOKEN: ${{ secrets.WYAM_ACCESS_TOKEN }}
WYAM_DEPLOY_BRANCH: "gh-pages"
WYAM_DEPLOY_REMOTE: ${{ github.event.repository.html_url }}

steps:
- uses: actions/[email protected]
with:
sumbodules: true
- name: Fetch all tags and branches
run: git fetch --prune --unshallow
- name: Install Transifex Client
if: ${{ runner.os }} == 'ubuntu-latest' # We do not need it for anything else
run: sudo apt-get install transifex-client -y
- name: Cache Tools
uses: actions/[email protected]
with:
path: tools
key: ${{ runner.os }}-tools-${{ hashFiles('setup.cake') }}
- name: Build Addin
uses: cake-build/cake-action@v1
with:
script-path: setup.cake
target: CI
verbosity: Diagnostic
cake-version: 0.38.4
cake-bootstrap: true
- name: Upload artifacts
uses: actions/[email protected]
with:
name: ${{ matrix.os }}-artifacts
path: |
BuildArtifacts/report.html
BuildArtifacts/packages/**/*.nupkg
BuildArtifacts/**/coverlet/*.xml
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions build.config

This file was deleted.

152 changes: 13 additions & 139 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,146 +1,20 @@
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Definition
$TOOLS_DIR = "$SCRIPT_DIR/tools"
if ($IsMacOS -or $IsLinux) {
$CAKE_EXE = "$TOOLS_DIR/dotnet-cake"
}
else {
$CAKE_EXE = "$TOOLS_DIR/dotnet-cake.exe"
}

$DOTNET_EXE = "$(Get-Command dotnet -ea 0 | select -Expand Source)"
$INSTALL_NETCORE = $false
[string[]]$DOTNET_SDKS = ""
[string]$CAKE_VERSION = ""
foreach ($line in Get-Content "$SCRIPT_DIR/build.config" -Encoding utf8) {
if ($line -like "CAKE_VERSION=*") {
$CAKE_VERSION = $line.Substring($line.IndexOf('=') + 1)
}
elseif ($line -like "DOTNET_SDKS=*") {
$DOTNET_SDKS = $line.Substring($line.IndexOf('=') + 1) -split ','
}
}

if ([string]::IsNullOrWhiteSpace($CAKE_VERSION) -or !$DOTNET_SDKS) {
"An errer occured while parsing Cake / .NET Core SDK version."
return 1
}

if ($IsMacOS -or $IsLinux) {
$PathSep = ":"
}
else {
$PathSep = ";"
}

if (Test-Path "$SCRIPT_DIR/.dotnet") {
$env:PATH = "$SCRIPT_DIR/.dotnet${PathSep}${env:PATH}"
$env:DOTNET_ROOT = "$SCRIPT_DIR/.dotnet"
$DOTNET_EXE = Get-ChildItem -Path "$SCRIPT_DIR/.dotnet/dotnet*" -Exclude "*.ps1" | select -First 1 -Expand FullName
}

if ([string]::IsNullOrWhiteSpace($DOTNET_EXE)) {
$INSTALL_NETCORE = $true
}
elseif (($DOTNET_SDKS | ? { $_ -ne 'ANY' })) {
foreach ($sdk in $DOTNET_SDKS) {
$re = "^\s*$([regex]::Escape($sdk))\s+"
$DOTNET_INSTALLED_VERSION = . $DOTNET_EXE --list-sdks 2>&1 | ? { $_ -match $re }
if (!$DOTNET_INSTALLED_VERSION) {
$INSTALL_NETCORE = $true
break
}
}
}
$ErrorActionPreference = 'Stop'

if ($true -eq $INSTALL_NETCORE) {
if (!(Test-Path "$SCRIPT_DIR/.dotnet")) {
New-Item -Path "$SCRIPT_DIR/.dotnet" -ItemType Directory -Force | Out-Null
}
function Run([string[]]$arguments) {
$proc = Start-Process "dotnet" $arguments -PassThru -NoNewWindow
Wait-Process -InputObject $proc

$ScriptPath = ""
$LaunchUrl = ""
$ScriptUrl = ""

if ($IsMacOS -or $IsLinux) {
$ScriptPath = "$SCRIPT_DIR/.dotnet/dotnet-install.sh"
$ScriptUrl = "https://dot.net/v1/dotnet-install.sh"
$LaunchUrl = "$(Get-Command bash)"
}
else {
$ScriptPath = "$SCRIPT_DIR/.dotnet/dotnet-install.ps1"
$ScriptUrl = "https://dot.net/v1/dotnet-install.ps1"
$LaunchUrl = "$ScriptPath"
}
(New-Object System.Net.WebClient).DownloadFile($ScriptUrl, $ScriptPath)

foreach ($DOTNET_VERSION in $DOTNET_SDKS) {
$arguments = @()
if ($IsMacOS -or $IsLinux) {
$arguments = @(
$ScriptPath
"--install-dir"
"$SCRIPT_DIR/.dotnet"
"--no-path"
)
if ($DOTNET_VERSION -ne "ANY") {
$arguments += @(
"--version"
"$DOTNET_VERSION"
)
}
}
else {
$arguments = @{
InstallDir = "$SCRIPT_DIR/.dotnet"
NoPath = $true
Version = "$DOTNET_VERSION"
}
}

& $LaunchUrl @arguments
}

$env:PATH = "$SCRIPT_DIR/.dotnet${PathSep}${env:PATH}"
$env:DOTNET_ROOT = "$SCRIPT_DIR/.dotnet"

$DOTNET_EXE = Get-ChildItem -Path "$SCRIPT_DIR/.dotnet/dotnet*" -Exclude "*.ps1" | select -First 1 -Expand FullName

}
elseif (Test-Path "/opt/dotnet/sdk" -ea 0) {
$env:DOTNET_ROOT = "/opt/dotnet/sdk"
if ($proc.ExitCode -ne 0) {
"Non-Zero exit code ($($proc.ExitCode)), exiting..."
exit $proc.ExitCode
}
}

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER = 0
Run tool, restore

$CAKE_INSTALLED_VERSION = Get-Command dotnet-cake -ea 0 | % { & $_.Source --version }
Run cake, setup.cake, --bootstrap

if ($CAKE_INSTALLED_VERSION -eq $CAKE_VERSION) {
$CAKE_EXE = Get-Command dotnet-cake | % Source
}
else {
$CakePath = "$TOOLS_DIR/.store/cake.tool/$CAKE_VERSION"
$CAKE_EXE = (Get-ChildItem -Path $TOOLS_DIR -Filter "dotnet-cake*" -File -ea 0 | select -First 1 -Expand FullName)

if (!(Test-Path -Path $CakePath -PathType Container) -or !(Test-Path $CAKE_EXE -PathType Leaf)) {
if (!([string]::IsNullOrWhiteSpace($CAKE_EXE)) -and (Test-Path $CAKE_EXE -PathType Leaf)) {
& $DOTNET_EXE tool uninstall --tool-path $TOOLS_DIR Cake.Tool
}

& $DOTNET_EXE tool install --tool-path $TOOLS_DIR --version $CAKE_VERSION Cake.Tool
if ($LASTEXITCODE -ne 0) {
"An error occured while installing Cake."
return 1
}

$CAKE_EXE = (Get-ChildItem -Path $TOOLS_DIR -Filter "dotnet-cake*" -File | select -First 1 -Expand FullName)
}
}

& "$CAKE_EXE" "$SCRIPT_DIR/setup.cake" --bootstrap
if ($LASTEXITCODE -eq 0) {
& "$CAKE_EXE" "$SCRIPT_DIR/setup.cake" $args
}
$arguments = @("cake"; "setup.cake")
$arguments += @($args)

return $LASTEXITCODE
Run $arguments
Loading

0 comments on commit 4a832d9

Please sign in to comment.