Skip to content

Commit 4ad5dab

Browse files
committed
update workflows
1 parent 499e87b commit 4ad5dab

File tree

4 files changed

+102
-35
lines changed

4 files changed

+102
-35
lines changed

.github/actions/build/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Build'
2+
description: 'Sets up the environment and builds the solution'
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: actions/setup-dotnet@v1
7+
with:
8+
dotnet-version: 6.0.x
9+
10+
- uses: nuget/setup-nuget@v1
11+
with:
12+
nuget-version: 6.x
13+
14+
- run: dotnet restore
15+
shell: pwsh
16+
17+
- run: dotnet build --configuration Release --no-restore
18+
shell: pwsh

.github/workflows/ci.yml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
1+
name: Continuous Integration
2+
13
on:
24
push:
3-
branches: [ main ]
5+
branches:
6+
- main
47
pull_request:
5-
types: [opened, synchronize, reopened]
6-
branches: [ main ]
7-
schedule:
8-
- cron: 0 12 * * 1
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
security-events: write
14+
15+
concurrency:
16+
group: ${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
defaults:
20+
run:
21+
shell: pwsh
922

1023
env:
1124
DOTNET_NOLOGO: true
1225
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
1326

1427
jobs:
1528
build:
16-
name: Build
1729
runs-on: ubuntu-latest
1830

1931
steps:
20-
- uses: actions/checkout@v1
21-
with:
22-
fetch-depth: 0
32+
- uses: actions/checkout@v2
33+
34+
- uses: ./.github/actions/build
35+
36+
- run: dotnet test --configuration Release --logger 'console;verbosity=detailed' /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
2337

24-
- name: Setup .NET Core 6.0.x
25-
uses: actions/setup-dotnet@v1
38+
- uses: snyk/actions/dotnet@master
39+
continue-on-error: true
40+
env:
41+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
2642
with:
27-
dotnet-version: 6.0.x
43+
args: >-
44+
--all-projects
45+
--detection-depth=8
46+
--severity-threshold=high
47+
--sarif-file-output=snyk.sarif
48+
command: test
2849

29-
- name: Build
30-
run: dotnet build --configuration Release
50+
- uses: github/codeql-action/upload-sarif@v1
51+
with:
52+
sarif_file: snyk.sarif

.github/workflows/publish.yml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
1+
name: Publish
2+
13
on:
24
push:
3-
tags: [ 'v*' ]
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
concurrency:
13+
group: ${{ github.ref }}
14+
cancel-in-progress: false
415

516
env:
617
DOTNET_NOLOGO: true
718
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
819

920
jobs:
10-
build:
11-
name: Build
21+
publish:
1222
runs-on: ubuntu-latest
1323

1424
steps:
15-
- uses: actions/checkout@v1
16-
with:
17-
fetch-depth: 0
25+
- uses: actions/checkout@v2
1826

19-
- name: Setup .NET Core 6.0.x
20-
uses: actions/setup-dotnet@v1
21-
with:
22-
dotnet-version: 6.0.x
27+
- uses: ./.github/actions/build
2328

24-
- name: Build and publish
29+
- uses: smokedlinq/powershell-devops@v0
30+
31+
- run: ./.github/workflows/scripts/Set-VersionVariables.ps1
2532
shell: pwsh
26-
run: |
27-
dotnet build --configuration Release
28-
dotnet pack --configuration Release -p:Version=$($env:GITHUB_REF -replace '^refs/tags/v','') --output ./publish
29-
cd ./publish
30-
dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
31-
dotnet nuget push "*.nupkg" -s https://nuget.pkg.github.com/${{ github.repository_owner }} --skip-duplicate --no-symbols true --api-key ${{ secrets.GITHUB_TOKEN }}
32-
33-
- name: Create release
34-
uses: actions/create-release@master
33+
34+
- run: dotnet pack --configuration Release -p:Version=$PACKAGE_VERSION --output ./publish
35+
36+
- run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
37+
working-directory: ./publish
38+
39+
- run: dotnet nuget push "*.nupkg" -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate --no-symbols true --api-key ${{ secrets.GITHUB_TOKEN }}
40+
working-directory: ./publish
41+
42+
- uses: actions/create-release@master
43+
continue-on-error: true
3544
env:
3645
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3746
with:
3847
tag_name: ${{ github.ref }}
3948
release_name: Release ${{ github.ref }}
4049
draft: false
41-
prerelease: false
50+
prerelease: ${{ env.IS_PRERELEASE }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Requires -Version 7
2+
# Requires -Moduels powershell-devops
3+
4+
[CmdletBinding()]
5+
param
6+
(
7+
[ValidateNotNullOrEmpty()]
8+
[string] $GITHUB_REF = $(Get-EnvironmentVariable GITHUB_REF -Require)
9+
)
10+
11+
$Version = $($GITHUB_REF -replace '^refs/tags/v','')
12+
$IsPrerelease = $Version -like '*-*' ? 'true' : 'false'
13+
14+
Write-Host "PACKAGE_VERSION: '$Version'"
15+
Write-Host "IS_PRERELEASE: $IsPrerelease"
16+
17+
Set-EnvironmentVariable PACKAGE_VERSION $Version
18+
Set-EnvironmentVariable IS_PRERELEASE $IsPrerelease

0 commit comments

Comments
 (0)