Skip to content

Commit

Permalink
Use GitHub Actions as CI (GtkSharp#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-cpp authored Jan 26, 2022
1 parent 0b3795e commit 4ba1013
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 434 deletions.
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": "2.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
30 changes: 30 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Restore dotnet tools
run: dotnet tool restore
- name: Run build.cake
run: dotnet cake build.cake
env:
GITHUB_ACTIONS: true
- uses: actions/upload-artifact@main
with:
name: Nuget Packages
path: |
BuildOutput/NugetPackages/**/*.nupkg
if-no-files-found: error
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,5 @@ tools/**

# OpenCover UI analysis results
OpenCover/

.cake
4 changes: 2 additions & 2 deletions CakeScripts/GAssembly.cake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GAssembly
{
// Fixup API file
var symfile = P.Combine(Dir, Name + "-symbols.xml");
Cake.DotNetCoreExecute("BuildOutput/Tools/GapiFixup.dll",
Cake.DotNetExecute("BuildOutput/Tools/GapiFixup.dll",
"--metadata=" + Metadata + " " + "--api=" + tempapi +
(Cake.FileExists(symfile) ? " --symbols=" + symfile : string.Empty)
);
Expand All @@ -60,7 +60,7 @@ public class GAssembly
}

// Generate code
Cake.DotNetCoreExecute("BuildOutput/Tools/GapiCodegen.dll",
Cake.DotNetExecute("BuildOutput/Tools/GapiCodegen.dll",
"--outdir=" + GDir + " " +
"--schema=Source/Libs/Shared/Gapi.xsd " +
extraargs + " " +
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@ Differences can be seen with the following table:

## Building from source

Pre requirements for building from source are that you have .Net Core and msbuild installed on the system.
Pre requirements for building from source are that you have .Net 6 installed on the system.

To build the repository, first clone it:
To build the repository, simply do:

```sh
git clone https://github.com/GtkSharp/GtkSharp.git
cd GtkSharp
dotnet tool restore
dotnet cake build.cake
```

and then simply run either `.\build.ps1` or `./build.sh` depending your operating system. If you have [Cake](https://cakebuild.net/) installed as a .NET global tool just run `dotnet-cake`.

If you wish to generate the nuget packages simply add the `--BuildTarget=PackageNuGet` as an argument when calling the build script.

A breakdown on how the source is structured:

* Tools that are needed to generate wrapper code are found in [Tools](Source/Tools) folder
Expand Down
47 changes: 0 additions & 47 deletions azure-pipelines.yml

This file was deleted.

44 changes: 39 additions & 5 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#load CakeScripts\GAssembly.cake
#load CakeScripts\Settings.cake
#addin "Cake.FileHelpers&version=4.0.0"
#addin "Cake.Incubator&version=6.0.0"
#addin "Cake.FileHelpers&version=5.0.0"
#addin "Cake.Incubator&version=7.0.0"

// VARS

Expand All @@ -14,11 +14,47 @@ var configuration = Argument("Configuration", "Release");
var msbuildsettings = new DotNetCoreMSBuildSettings();
var list = new List<GAssembly>();

private void ParseVersion()
{
if (!string.IsNullOrEmpty(EnvironmentVariable("GITHUB_ACTIONS")))
{
var version = "3.24.24." + EnvironmentVariable("GITHUB_RUN_NUMBER");

var upstreamUrl = "GtkSharp/GtkSharp";
var repositoryUrl = EnvironmentVariable("GITHUB_REPOSITORY");
var branch = EnvironmentVariable("GITHUB_REF");

if (string.IsNullOrEmpty(repositoryUrl))
return;

if (repositoryUrl != upstreamUrl) // If we are building a PR
{
var split = repositoryUrl.Split('/');
version = version + "-" + split[0];
}
else if (repositoryUrl == upstreamUrl &&
!string.IsNullOrEmpty(branch) &&
branch != " refs/heads/master") // If we are building our repository
{
var branchName = branch.Substring(11);
version = version + "-" + branchName;
}

Settings.Version = version;

Console.WriteLine("Branch: " + branch);
}

Console.WriteLine("Version: " + Settings.Version);
}

// TASKS

Task("Init")
.Does(() =>
{
ParseVersion();

// Assign some common properties
msbuildsettings = msbuildsettings.WithProperty("Version", Settings.Version);
msbuildsettings = msbuildsettings.WithProperty("Authors", "'GtkSharp Contributors'");
Expand Down Expand Up @@ -142,9 +178,7 @@ Task("PackageTemplates")
// TASK TARGETS

Task("Default")
.IsDependentOn("Build");

Task("FullBuild")
.IsDependentOn("Build")
.IsDependentOn("PackageNuGet")
.IsDependentOn("PackageTemplates");

Expand Down
Loading

0 comments on commit 4ba1013

Please sign in to comment.