Skip to content

Commit

Permalink
Build with Github Workflows #92 (#93)
Browse files Browse the repository at this point in the history
* Create main.yml

* build with GitHub Action

* Create release.yml

* Documentation moved ro README.md

* remove cake and build with dotnet build

* add dotnet build workflow

* add testcoverage

* naming

* added release

* Update Badges

* removed comments

* add source url for GetBuildVersion

* update API and tasks added
  • Loading branch information
bbtbir authored Oct 31, 2022
1 parent 82606d5 commit 1258f1d
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 249 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
54 changes: 54 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow will build TfsUrlParser project

name: CI

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

defaults:
run:
working-directory: src

jobs:
build:
env:
BUILD_CONFIG: "Debug"

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3

- name: Get Build Version
run: |
Import-Module ..\build\GetBuildVersion.psm1
Write-Host $Env:GITHUB_REF
$version = GetBuildVersion -VersionString $Env:GITHUB_REF
echo "BUILD_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration $BUILD_CONFIG -p:Version=$BUILD_VERSION --no-restore

- name: Test
run: dotnet test -p:Configuration=$BUILD_CONFIG --no-restore --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Codecov
uses: codecov/codecov-action@v3
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This workflow will release TfsUrlParser

name: Release

on:
release:
types: [published]

defaults:
run:
working-directory: src

jobs:
build:
env:
BUILD_CONFIG: "Release"

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3

- name: Get Build Version
run: |
Import-Module ..\build\GetBuildVersion.psm1
Write-Host $Env:GITHUB_REF
$version = GetBuildVersion -VersionString $Env:GITHUB_REF
echo "BUILD_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration $BUILD_CONFIG -p:Version=$BUILD_VERSION --no-restore

- name: Test
run: dotnet test -p:Configuration=$BUILD_CONFIG --no-restore --no-build --verbosity normal --collect:"XPlat Code Coverage"

- name: Codecov
uses: codecov/[email protected]

- name: Setup NuGet
uses: NuGet/setup-nuget@v1

- name: Publish NuGet
run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGETORG}}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/TfsUrlParser.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/TfsUrlParser/TfsUrlParser.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/src/TfsUrlParser/TfsUrlParser.sln"
],
"problemMatcher": "$msCompile"
}
]
}
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,28 @@ This NuGet package contains code for parsing Azure DevOps and Azure DevOps Serve

|Develop|Master|
|:--:|:--:|
|[![Build status](https://ci.appveyor.com/api/projects/status/i4evodvrv7qc9e6y/branch/develop?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/tfsurlparser/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/i4evodvrv7qc9e6y/branch/master?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/tfsurlparser/branch/master)|
|[![Build status](https://github.com/bbtsoftware/tfsurlparser/actions/workflows/dotnet.yml/badge.svg?branch=develop)](https://github.com/bbtsoftware/TfsUrlParser/actions/workflows/main.yml?query=branch%3Adevelop)|[![Build status](https://github.com/bbtsoftware/tfsurlparser/actions/workflows/develop.yml/badge.svg?branch=master)](https://github.com/bbtsoftware/TfsUrlParser/actions/workflows/dotnet.yml?query=branch%3Amaster)|

## Code Coverage

[![Coverage Status](https://coveralls.io/repos/github/BBTSoftwareAG/tfs-url-parser/badge.svg?branch=develop)](https://coveralls.io/github/BBTSoftwareAG/tfs-url-parser?branch=develop)
[![Coverage Status](https://codecov.io/gh/bbtsoftware/TfsUrlParser/branch/develop/graph/badge.svg?token=0VLbB8a8EF)](https://codecov.io/gh/bbtsoftware/TfsUrlParser)

## Quick Links
## Class RepositoryDescription

* [Documentation](https://bbtsoftware.github.io/TfsUrlParser/)
To use the Azure DevOps URL parser you need to add the [TfsUrlParser NuGet package](https://www.nuget.org/packages/TfsUrlParser/).

```csharp
var repositoryDescription =
new RepositoryDescription(
"http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository");

Console.WriteLine(repositoryDescription.ServerUrl);
Console.WriteLine(repositoryDescription.CollectionUrl);
Console.WriteLine(repositoryDescription.CollectionName);
Console.WriteLine(repositoryDescription.ProjectName);
Console.WriteLine(repositoryDescription.RepositoryUrl);
Console.WriteLine(repositoryDescription.RepositoryName);
```

## Build

Expand Down
36 changes: 36 additions & 0 deletions build/GetBuildVersion.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// https://github.com/MADE-Apps/MADE.NET/blob/main/build/GetBuildVersion.psm1

Function GetBuildVersion {
Param (
[string]$VersionString
)

# Process through regex
$VersionString -match "(?<major>\d+)(\.(?<minor>\d+))?(\.(?<patch>\d+))?(\-(?<pre>[0-9A-Za-z\-\.]+))?(\+(?<build>\d+))?" | Out-Null

if ($matches -eq $null) {
return "1.0.0-build"
}

# Extract the build metadata
$BuildRevision = [uint64]$matches['build']
# Extract the pre-release tag
$PreReleaseTag = [string]$matches['pre']
# Extract the patch
$Patch = [uint64]$matches['patch']
# Extract the minor
$Minor = [uint64]$matches['minor']
# Extract the major
$Major = [uint64]$matches['major']

$Version = [string]$Major + '.' + [string]$Minor + '.' + [string]$Patch;
if ($PreReleaseTag -ne [string]::Empty) {
$Version = $Version + '-' + $PreReleaseTag
}

if ($BuildRevision -ne 0) {
$Version = $Version + '.' + [string]$BuildRevision
}

return $Version
}
50 changes: 0 additions & 50 deletions docs/input/_Bottom.cshtml

This file was deleted.

5 changes: 0 additions & 5 deletions docs/input/_Footer.cshtml

This file was deleted.

Loading

0 comments on commit 1258f1d

Please sign in to comment.