Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed Aug 12, 2024
2 parents cbf232d + 3da9d59 commit b74744c
Show file tree
Hide file tree
Showing 46 changed files with 2,294 additions and 116 deletions.
43 changes: 20 additions & 23 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
#---------------------------------#
# Build Image #
#---------------------------------#
image: Visual Studio 2017
image: Visual Studio 2022

init:
- git config --global core.autocrlf true

#---------------------------------#
# Install .NET #
#---------------------------------#
install:
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk"
- ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null
- ps: Invoke-WebRequest -Uri "https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1" -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1"
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 5.0.408 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.424 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.409 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 8.0.303 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
- ps: dotnet --info

#---------------------------------#
# Build Script #
#---------------------------------#
build_script:
- ps: .\build.ps1 -Target AppVeyor
- ps: .\build.ps1 --target=CI

#---------------------------------#
# Tests
#---------------------------------#
test: off

#---------------------------------#
# Pull Requests #
#---------------------------------#
pull_requests:
do_not_increment_build_number: true

#---------------------------------#
# General #
#---------------------------------#
skip_branch_with_pr: true

#---------------------------------#
# Branches to build #
#---------------------------------#
Expand All @@ -40,11 +44,4 @@ branches:
# Build Cache #
#---------------------------------#
cache:
- tools -> recipe.cake, tools/packages.config

#---------------------------------#
# Skip builds for doc changes #
#---------------------------------#
skip_commits:
# Regex for matching commit message
message: /(doc).*/
- tools -> recipe.cake
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": "1.3.0",
"commands": [
"dotnet-cake"
]
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
!src/Cake.GitHub/Releases/
!src/Cake.GitHub.Tests/Releases/
x64/
x86/
bld/
Expand Down
Binary file removed Cake.WindowsAppStore.png
Binary file not shown.
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>

<PropertyGroup>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
3 changes: 3 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mode: ContinuousDeployment
assembly-versioning-scheme: MajorMinorPatch
next-version: 1.0.0
111 changes: 106 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Cake.GitHub

Add-in for Cake that allows integration with GitHub. The following integrations are support:
Add-in for Cake that allows integration with GitHub. The following integrations are supported:

* [Status](#status)
* [Create Release](#create-release)
* [Set Milestone](#set-milestone)

## Discussion

For questions and to discuss ideas & feature requests, use the [GitHub discussions on the Cake GitHub repository](https://github.com/cake-build/cake/discussions), under the [Extension Q&A](https://github.com/cake-build/cake/discussions/categories/extension-q-a) category.

[![Join in the discussion on the Cake repository](https://img.shields.io/badge/GitHub-Discussions-green?logo=github)](https://github.com/cake-build/cake/discussions)

* Status

## Status

Allows updating the status of a build in GitHub.

API documentation: https://developer.github.com/v3/repos/statuses/#create-a-status
API documentation: https://docs.github.com/en/rest/reference/repos#create-a-commit-status

```
```cs
GitHubStatus("username", "apitoken", "owner", "repository", "commitSha", new GitHubStatusSettings
{
State = GitHubStatusState.Pending,
Expand All @@ -20,4 +28,97 @@ GitHubStatus("username", "apitoken", "owner", "repository", "commitSha", new Git
})
```

## Create Release

Allows creating a [GitHub Release](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases)

API documentation: https://docs.github.com/en/rest/reference/repos#create-a-release

```cs
Task("CreateGitHubRelease")
.Does(async () =>
{
await GitHubCreateReleaseAsync(
/// The user name to use for authentication (pass null when using an access token).
userName: "user",
/// The access token or password to use for authentication.
apiToken: "apitoken",
// The owner (user or group) of the repository to create a release in.
owner: "owner",
/// The name of the repository to create a release in.
repository: "repository"
/// The name of the tag to create a release for.
/// If the tag does not yet exist, a new tag will be created (using either the HEAD of the default branch or the commit specified in the settings).
/// If the tag already exists, the existing tag will be used and the commit specified in the settings will be ignored.
tagName: "v1.2.3",

// Specify additional settings for the release (optional)
settings: GitHubCreateReleaseSettings()
{
// The id of the commit to create the release from
// (uses the HEAD commit of the repo's default branch if not specified)
TargetCommitish = "abc123",

// Set the name of the release (defaults to the tag name when not specified)
Name = $"v1.2.3",

// The release's description as Markdown string (optional)
Body = "Description",

// Set to true to create a draft release (default: false)
Draft = false,

// Set to true to mark the release as prerelease (default: false)
Prerelease = false,

// Overwrite will delete any existing commit with the same tag name if it exists
Overwrite = false
}
);

});
```

## Set Milestone

Assigns an Issue or Pull Request to a [Milestone](https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/about-milestones).

API documentation: https://docs.github.com/en/rest/issues/issues#update-an-issue

```cs
Task("SetMilestone")
.Does(async () =>
{
await GitHubSetMilestoneAsync(
// The user name to use for authentication (pass null when using an access token).
userName: "user",

// The access token or password to use for authentication.
apiToken: "apitoken",

// The owner (user or group) of the repository.
owner: "owner",

// The name of the repository.
repository: "repository",

// The number of the issue or pull request to set the milestone for.
number: 23,

// The title of the milestone to assign the issue or pull request to.
// Note that GitHub treats milestone titles *case-sensitive*.
milestoneTitle: "Milestone 1",

// Specify additional settings for updating the milestone (optional)
settings: GitHubSetMilestoneSettings()
{
// Set to true to set the issue's or pull request's milestone even if it is already set to a different milestone (default: false)
Overwrite = false,

// Set to true to create a milestone with the specified title if no such milestone exists (default: false)
// When set to false, GitHubSetMilestoneAsync() will fail if no matching milestone is found.
CreateMilestone = false
}
);
});
```
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"rollForward": "latestMinor",
"allowPrerelease": false
}
}
48 changes: 30 additions & 18 deletions recipe.cake
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
#load nuget:?package=Cake.Recipe&version=1.0.0
#load nuget:?package=Cake.Recipe&version=3.1.1

//*************************************************************************************************
// Settings
//*************************************************************************************************

Environment.SetVariableNames();

BuildParameters.SetParameters(context: Context,
buildSystem: BuildSystem,
sourceDirectoryPath: "./src",
title: "Cake.GitHub",
repositoryOwner: "cake-contrib",
repositoryName: "Cake.GitHub",
appVeyorAccountName: "cakecontrib",
shouldRunDotNetCorePack: true,
shouldRunDupFinder: false,
shouldRunGitVersion: true);
BuildParameters.SetParameters(
context: Context,
buildSystem: BuildSystem,
sourceDirectoryPath: "./src",
title: "Cake.GitHub",
repositoryOwner: "cake-contrib",
repositoryName: "Cake.GitHub",
appVeyorAccountName: "cakecontrib",
shouldUseDeterministicBuilds: true,
shouldRunCodecov: false,
shouldGenerateDocumentation: false,
shouldRunInspectCode: false,
shouldRunCoveralls: false,
shouldRunDotNetCorePack: true);

BuildParameters.PrintParameters(Context);

ToolSettings.SetToolSettings(context: Context,
dupFinderExcludePattern: new string[] {
BuildParameters.RootDirectoryPath + "/src/Cake.GitHub.Tests/*.cs" },
testCoverageFilter: "+[*]* -[Microsoft.WindowsAzure.Storage]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[FakeItEasy]*",
testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");
ToolSettings.SetToolSettings(
context: Context,
skipDuplicatePackages: true,
testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.GitHub.Reporting.Generic]LitJson.* -[Shouldly]* -[DiffEngine]* -[EmptyFiles]*",
testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");

//*************************************************************************************************
// Execution
//*************************************************************************************************

Build.RunDotNetCore();
Build.RunDotNetCore();
41 changes: 19 additions & 22 deletions src/Cake.GitHub.Tests/Cake.GitHub.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>Cake.GitHub.Tests</AssemblyName>
<PackageId>Cake.GitHub.Tests</PackageId>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>Cake.GitHub.Tests</AssemblyName>
<PackageId>Cake.GitHub.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.33.0" />
<PackageReference Include="FakeItEasy" Version="4.5.1" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.7.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Cake.GitHub\Cake.GitHub.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Cake.Core" Version="4.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.20.70" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Cake.GitHub\Cake.GitHub.csproj" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/Cake.GitHub.Tests/GitHubTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Core;
using Core.Diagnostics;
using Core.IO;
using FakeItEasy;
using Xunit;

public class GitHubTests
Expand Down
43 changes: 43 additions & 0 deletions src/Cake.GitHub.Tests/Helpers/FakeFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.IO;
using Cake.Core.IO;

namespace Cake.GitHub.Tests
{
internal class FakeFile : IFile
{
public FilePath Path { get; set; }

public long Length
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}

public FileAttributes Attributes
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}

public bool Exists { get; set; }

public bool Hidden => throw new NotImplementedException();

Core.IO.Path IFileSystemInfo.Path => Path;


public FakeFile(FilePath path)
{
Path = path;
}

public void Copy(FilePath destination, bool overwrite) => throw new NotImplementedException();

public void Delete() => throw new NotImplementedException();

public void Move(FilePath destination) => throw new NotImplementedException();

public Stream Open(FileMode fileMode, FileAccess fileAccess, FileShare fileShare) => new MemoryStream();
}
}
Loading

0 comments on commit b74744c

Please sign in to comment.