Skip to content

Commit 7f3d58c

Browse files
authored
Publish to nuget on new tag (#6)
* publish to nuget on new tag * rename ci.yml workflow to publish-nuget-on-tag.yml * do not use variable for runner version * build test projects separately
1 parent 895d47e commit 7f3d58c

File tree

3 files changed

+93
-43
lines changed

3 files changed

+93
-43
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Continuous Integration on new tag
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
8+
- "v[0-9]+.[0-9]+.[0-9]+-preview.[0-9]+"
9+
10+
env:
11+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
12+
DOTNET_NOLOGO: true
13+
ARTIFACTS_NAME: artifacts
14+
ARTIFACTS_FOLDER: ${{github.workspace}}/artifacts
15+
NUGET_URI: "https://api.nuget.org/v3/index.json"
16+
17+
jobs:
18+
build:
19+
name: Build
20+
runs-on: ubuntu-22.04
21+
22+
steps:
23+
- name: Checkout (all tree)
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
filter: tree:0
28+
29+
- name: Set up .NET Core (global.json)
30+
uses: actions/setup-dotnet@v4
31+
32+
- name: dotnet build (sources only)
33+
run: dotnet build src/Sotsera.Sources.Common/Sotsera.Sources.Common.csproj --configuration Release
34+
35+
- name: dotnet build (tests only)
36+
run: |
37+
dotnet build test/Sotsera.Sources.Common.Tests.Unit/Sotsera.Sources.Common.Tests.Unit.csproj --configuration Release
38+
dotnet build test/Sotsera.Sources.Common.Tests.Integration/Sotsera.Sources.Common.Tests.Integration.csproj --configuration Release
39+
40+
- name: dotnet test
41+
run: dotnet test --configuration Release --no-build
42+
43+
- name: Upload artifacts
44+
uses: actions/upload-artifact@v4
45+
with:
46+
if-no-files-found: error
47+
name: ${{ env.ARTIFACTS_NAME }}
48+
path: ${{ env.ARTIFACTS_FOLDER }}
49+
retention-days: 5
50+
51+
publish:
52+
name: Publish
53+
runs-on: ubuntu-22.04
54+
needs: build
55+
56+
steps:
57+
- name: Dowload artifacts
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: ${{ env.ARTIFACTS_NAME }}
61+
path: ${{ env.ARTIFACTS_FOLDER }}
62+
63+
- name: Set up .NET Core (global.json)
64+
uses: actions/setup-dotnet@v4
65+
66+
- name: Publish NuGet packages
67+
shell: pwsh
68+
env:
69+
NUGET_APY_KEY: ${{ secrets.NUGET_APY_KEY }}
70+
run: |
71+
Write-Host "Current ref: $env:GITHUB_REF"
72+
Write-Host "Searching nupkg in folder: ${{ env.ARTIFACTS_FOLDER }}"
73+
$files = Get-ChildItem "${{ env.ARTIFACTS_FOLDER }}/*" -Include *.nupkg
74+
foreach($file in $files) {
75+
Write-Host "Pushing NuGet package: $($file.FullName)"
76+
& dotnet nuget push "$($file.FullName)" --api-key "$env:NUGET_APY_KEY" --source ${{ env.NUGET_URI }} --force-english-output --skip-duplicate
77+
}

.github/workflows/verify-pull-request.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,32 @@ on:
44
pull_request:
55
branches: [ "main" ]
66

7+
env:
8+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
9+
DOTNET_NOLOGO: true
10+
711
jobs:
812
build:
913
name: Verify pull request
10-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-22.04
1115

1216
steps:
13-
- uses: actions/checkout@v4
17+
- name: Checkout
18+
uses: actions/checkout@v4
1419

15-
- name: Set up .NET Core (version from global.json)
20+
- name: Set up .NET Core (global.json)
1621
uses: actions/setup-dotnet@v4
17-
with:
18-
global-json-file: global.json
1922

20-
- name: dotnet build sources
23+
- name: dotnet build (sources only)
2124
run: dotnet build src/Sotsera.Sources.Common/Sotsera.Sources.Common.csproj --configuration Release
2225

26+
- name: dotnet build (tests only)
27+
run: |
28+
dotnet build test/Sotsera.Sources.Common.Tests.Unit/Sotsera.Sources.Common.Tests.Unit.csproj --configuration Release
29+
dotnet build test/Sotsera.Sources.Common.Tests.Integration/Sotsera.Sources.Common.Tests.Integration.csproj --configuration Release
30+
2331
- name: dotnet test
24-
run: dotnet test --configuration Release
32+
run: dotnet test --configuration Release --no-build
2533

2634
- name: dotnet format
27-
run: dotnet format -v detailed --verify-no-changes
35+
run: dotnet format -v detailed --verify-no-changes --no-restore

0 commit comments

Comments
 (0)