Skip to content

Commit 5b502c6

Browse files
committed
GitHub actions (#387)
1 parent f954655 commit 5b502c6

File tree

3 files changed

+57
-29
lines changed

3 files changed

+57
-29
lines changed

.github/workflows/pr-validation.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
branches: [ dev, master ]
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
jobs:
11+
Build:
12+
runs-on: windows-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Run build and tests
17+
run: ./Build.ps1 -RunTests $true
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
1-
name: main
1+
name: Release
22

33
on:
44
push:
5-
branches: [ dev ]
6-
pull_request:
7-
branches: [ dev ]
5+
branches: [ dev, master ]
86

97
# Allows you to run this workflow manually from the Actions tab
108
workflow_dispatch:
119

1210
jobs:
13-
build:
11+
Build:
1412
runs-on: windows-latest
1513
steps:
1614
- uses: actions/checkout@v2
1715

16+
- name: Run build
17+
run: ./Build.ps1
18+
1819
- name: Read version from csproj
1920
run: |
2021
$selectResult = Select-String -Path ".\src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj" -Pattern '<VersionPrefix>(.+)</VersionPrefix>'
21-
echo ("VERSION=" + $selectResult.Matches[0].Groups[1].Value) >> $env:GITHUB_ENV
22+
$versionMatch = $selectResult.Matches[0].Groups[1].Value
23+
echo ("VERSION=" + $versionMatch) >> $env:GITHUB_ENV
24+
echo "Found version $versionMatch"
2225
23-
- name: Run build script
24-
run: ./Build.ps1
25-
26-
- name: Create releease
26+
- name: Create GitHub releease
27+
# if: ${{ github.ref_name == 'master' }}
2728
uses: "marvinpinto/action-automatic-releases@latest"
2829
with:
2930
repo_token: "${{ secrets.GITHUB_TOKEN }}"
3031
automatic_release_tag: "v${{ env.VERSION }}-test"
3132
draft: true
32-
title: "Release ${{ env.VERSION }}-test"
33+
title: "v${{ env.VERSION }}-test"
3334
files: |
34-
\a\serilog-sinks-mssqlserver\serilog-sinks-mssqlserver\artifacts\Serilog.Sinks.MSSqlServer.5.7.0.nupkg
35-
README.md
36-
.\artifacts\Serilog.Sinks.MSSqlServer.5.7.0-dev-local.snupkg
35+
artifacts/*.nupkg
36+
artifacts/*.snupkg
37+
38+
# TODO: upload to nuget.org

Build.ps1

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter(Mandatory = $false)]
4+
[System.Boolean]
5+
$RunTests = $false
6+
)
7+
18
echo "build: Build started"
29

310
Push-Location $PSScriptRoot
@@ -9,8 +16,8 @@ if(Test-Path .\artifacts) {
916

1017
& dotnet restore --no-cache
1118

12-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
13-
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
19+
$branch = @{ $true = $env:GITHUB_REF_NAME; $false = $(git symbolic-ref --short -q HEAD) }[$env:GITHUB_REF_NAME -ne $NULL];
20+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:GITHUB_RUN_NUMBER, 10); $false = "local" }[$env:GITHUB_RUN_NUMBER -ne $NULL];
1421
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
1522

1623
echo "build: Version suffix is $suffix"
@@ -30,26 +37,28 @@ foreach ($src in ls src/*) {
3037
Pop-Location
3138
}
3239

33-
foreach ($test in ls test/*.PerformanceTests) {
34-
Push-Location $test
40+
if ($RunTests -eq $true) {
41+
foreach ($test in ls test/*.PerformanceTests) {
42+
Push-Location $test
3543

36-
echo "build: Building performance test project in $test"
44+
echo "build: Building performance test project in $test"
3745

38-
& dotnet build -c Release
39-
if($LASTEXITCODE -ne 0) { exit 2 }
46+
& dotnet build -c Release
47+
if($LASTEXITCODE -ne 0) { exit 2 }
4048

41-
Pop-Location
42-
}
49+
Pop-Location
50+
}
4351

44-
foreach ($test in ls test/*.Tests) {
45-
Push-Location $test
52+
foreach ($test in ls test/*.Tests) {
53+
Push-Location $test
4654

47-
echo "build: Testing project in $test"
55+
echo "build: Testing project in $test"
4856

49-
& dotnet test -c Release
50-
if($LASTEXITCODE -ne 0) { exit 3 }
57+
& dotnet test -c Release
58+
if($LASTEXITCODE -ne 0) { exit 3 }
5159

52-
Pop-Location
60+
Pop-Location
61+
}
5362
}
5463

5564
Pop-Location

0 commit comments

Comments
 (0)