Skip to content

Commit

Permalink
Use GitHub Actions instead of AppVeyor
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielweyer committed Mar 6, 2022
1 parent 453bfb4 commit 40e65c3
Show file tree
Hide file tree
Showing 8 changed files with 2,190 additions and 456 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.0.0",
"version": "2.1.0",
"commands": [
"dotnet-cake"
]
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build
on:
push:
branches:
- main
- 'features/**'
paths-ignore:
- 'docs/**'
- .editorconfig
- LICENSE
- README.md
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install latest .NET SDK
run: ./build/dotnet-install.sh
- name: Restore .NET tools
run: dotnet tool restore
- name: Build
run: |
dotnet cake build.cake --bootstrap
dotnet cake build.cake --pack
- name: Upload NuGet packages
uses: actions/upload-artifact@v2
with:
name: packages
path: ./artifacts/packages
- name: Upload dotnet test results
uses: actions/upload-artifact@v2
with:
name: tests-results
path: ./artifacts/test-results/*.trx
if: ${{ always() }}
- name: Report test results
uses: dorny/[email protected]
continue-on-error: true
if: ${{ always() }}
with:
name: Test results
path: 'artifacts/test-results/*.trx'
reporter: dotnet-trx
- name: Create GitHub release on main branch
if: ${{ github.ref_name == 'main' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
touch empty-release-notes.txt
gh release create v${{ env.PACKAGE_VERSION }} --title v${{ env.PACKAGE_VERSION }} ./artifacts/packages/* --target ${{ github.sha }} --repo ${{ github.repository }} --notes-file empty-release-notes.txt
- name: Create GitHub prerelease on features branches
if: ${{ startsWith(github.ref_name, 'features/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
touch empty-release-notes.txt
gh release create v${{ env.PACKAGE_VERSION }} --title v${{ env.PACKAGE_VERSION }} ./artifacts/packages/* --target ${{ github.sha }} --repo ${{ github.repository }} --notes-file empty-release-notes.txt --prerelease
- name: Push NuGet package on main branch
if: ${{ github.ref_name == 'main' }}
run: dotnet nuget push ./artifacts/packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Decode Base64

`.NET Core` [global tool][dotnet-global-tools] to decode a `UTF8` `Base64` encoded string.
`.NET` [global tool][dotnet-global-tools] to decode a `UTF8` `Base64` encoded string.

| Package | Release |
| - | - |
| `dotnet-decode-base64` | [![NuGet][nuget-tool-badge]][nuget-tool-command] |

| CI | Status | Platform(s) | Framework(s) |
| --- | --- | --- | --- |
| [AppVeyor][app-veyor] | [![Build Status][app-veyor-shield]][app-veyor] | `Windows` | `netcoreapp3.1.0`, `net6.0` |
| [GitHub][github-actions] | [![Build Status][github-actions-shield]][github-actions] | `Ubuntu` | `netcoreapp3.1`, `net6.0` |

Supports both [base64][base64] and [base64url][base64url].

Expand All @@ -26,10 +26,10 @@ dotnet tool install -g dotnet-decode-base64
dotnet decode-base64 SGVsbG8gV29ybGQh
```

[github-actions]: https://github.com/gabrielweyer/dotnet-decode-base64/actions/workflows/build.yml
[github-actions-shield]: https://github.com/gabrielweyer/dotnet-decode-base64/actions/workflows/build.yml/badge.svg
[nuget-tool-badge]: https://img.shields.io/nuget/v/dotnet-decode-base64.svg?label=NuGet&style=flat-square
[nuget-tool-command]: https://www.nuget.org/packages/dotnet-decode-base64/
[app-veyor]: https://ci.appveyor.com/project/GabrielWeyer/dotnet-decode-base64
[app-veyor-shield]: https://img.shields.io/appveyor/ci/gabrielweyer/dotnet-decode-base64/main.svg?label=appveyor&style=flat-square
[dotnet-global-tools]: https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools
[base64]: https://tools.ietf.org/html/rfc4648#section-4
[base64url]: https://tools.ietf.org/html/rfc4648#section-5
75 changes: 0 additions & 75 deletions appveyor.yml

This file was deleted.

74 changes: 51 additions & 23 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#tool dotnet:?package=GitVersion.Tool&version=5.8.1
#tool dotnet:?package=GitVersion.Tool&version=5.8.2
#addin nuget:?package=Cake.Incubator&version=7.0.0

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
Expand All @@ -8,9 +9,12 @@ var packageVersion = "1.0.0";

var artifactsDir = MakeAbsolute(Directory("artifacts"));
var packagesDir = artifactsDir.Combine(Directory("packages"));
var testResultsDir = artifactsDir.Combine(Directory("test-results"));

var solutionPath = "./dotnet-decode-base64.sln";

var testProjects = new List<TestProject>();

Task("Clean")
.Does(() =>
{
Expand Down Expand Up @@ -42,16 +46,18 @@ Task("SemVer")
Information($"NuGetVersion: {packageVersion}");
});

Task("SetAppVeyorVersion")
Task("SetGitHubVersion")
.IsDependentOn("Semver")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.WithCriteria(() => GitHubActions.IsRunningOnGitHubActions)
.Does(() =>
{
AppVeyor.UpdateBuildVersion(packageVersion);
var gitHubEnvironmentFile = Environment.GetEnvironmentVariable("GITHUB_ENV");
var packageVersionEnvironmentVariable = $"PACKAGE_VERSION={packageVersion}";
System.IO.File.WriteAllText(gitHubEnvironmentFile, packageVersionEnvironmentVariable);
});

Task("Build")
.IsDependentOn("SetAppVeyorVersion")
.IsDependentOn("SetGitHubVersion")
.Does(() =>
{
var settings = new DotNetBuildSettings
Expand All @@ -69,20 +75,45 @@ Task("Build")
DotNetBuild(solutionPath, settings);
});

Task("Test")
Task("ListTestProjectsAndFrameworkVersions")
.IsDependentOn("Build")
.Does(() =>
.DoesForEach(GetFiles("./tests/*/*-tests.csproj"), (testProject) =>
{
var parsedProject = ParseProject(testProject.FullPath, configuration: configuration);

parsedProject.TargetFrameworkVersions.ToList().ForEach(frameworkVersion =>
{
var projectToTest = new TestProject
{
FullPath = testProject.FullPath,
AssemblyName = parsedProject.AssemblyName,
FrameworkVersion = frameworkVersion
};
testProjects.Add(projectToTest);
});
});

Task("Test")
.IsDependentOn("ListTestProjectsAndFrameworkVersions")
.DoesForEach(() => testProjects, (testProject) =>
{
var settings = new DotNetTestSettings
{
Configuration = configuration,
NoBuild = true
NoBuild = true,
Framework = testProject.FrameworkVersion
};

GetFiles("./tests/*/*-tests.csproj")
.ToList()
.ForEach(f => DotNetTest(f.FullPath, settings));
});
if (GitHubActions.IsRunningOnGitHubActions)
{
var trxTestResultsFile = testResultsDir
.Combine($"{testProject.AssemblyName}.{testProject.FrameworkVersion}.trx");
settings.Loggers.Add($"\"trx;LogFileName={trxTestResultsFile}\"");
}

DotNetTest(testProject.FullPath, settings);
})
.DeferOnError();

Task("Pack")
.IsDependentOn("Test")
Expand All @@ -105,17 +136,14 @@ Task("Pack")
.ForEach(f => DotNetPack(f.FullPath, settings));
});

Task("PublishAppVeyorArtifacts")
.IsDependentOn("Pack")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.Does(() =>
{
GetFiles($"{packagesDir}/*")
.ToList()
.ForEach(f => AppVeyor.UploadArtifact(f, new AppVeyorUploadArtifactsSettings { DeploymentName = "packages" }));
});

Task("Default")
.IsDependentOn("PublishAppVeyorArtifacts");
.IsDependentOn("Pack");

RunTarget(target);

class TestProject
{
public string FullPath { get; set; }
public string AssemblyName { get; set; }
public string FrameworkVersion { get; set; }
}
Loading

0 comments on commit 40e65c3

Please sign in to comment.