Skip to content

Commit 60cf2e6

Browse files
committed
publish to nuget on new tag
1 parent 895d47e commit 60cf2e6

File tree

2 files changed

+68
-22
lines changed

2 files changed

+68
-22
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Continuous Integration
1+
name: Continuous Integration on new tag
22

33
on:
44
push:
@@ -7,29 +7,69 @@ on:
77
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
88
- "v[0-9]+.[0-9]+.[0-9]+-preview.[0-9]+"
99

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+
1017
jobs:
1118
build:
12-
name: Continuous Integration
13-
runs-on: ubuntu-latest
19+
name: Build
20+
runs-on: ${{ vars.RUNNER }}
1421

1522
steps:
16-
- uses: actions/checkout@v4
23+
- name: Checkout (all tree)
24+
uses: actions/checkout@v4
1725
with:
1826
fetch-depth: 0
1927
filter: tree:0
2028

21-
- name: Set up .NET Core (version from global.json)
29+
- name: Set up .NET Core (global.json)
2230
uses: actions/setup-dotnet@v4
23-
with:
24-
global-json-file: global.json
2531

26-
- name: dotnet build sources
27-
run: dotnet build src/Sotsera.Sources.Common/Sotsera.Sources.Common.csproj --configuration Release
32+
- name: dotnet build (sources only)
33+
run: dotnet build src/**/*.csproj --configuration Release
34+
35+
- name: dotnet build (tests only)
36+
run: dotnet build test/**/*.csproj --configuration Release
2837

2938
- name: dotnet test
30-
run: dotnet test --configuration Release
39+
run: dotnet test --configuration Release --no-build
40+
41+
- name: Upload artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
if-no-files-found: error
45+
name: ${{ env.ARTIFACTS_NAME }}
46+
path: ${{ env.ARTIFACTS_FOLDER }}
47+
retention-days: 5
3148

32-
- uses: actions/upload-artifact@v4
49+
publish:
50+
name: Publish
51+
runs-on: ${{ vars.RUNNER }}
52+
needs: build
53+
54+
steps:
55+
- name: Dowload artifacts
56+
uses: actions/download-artifact@v4
3357
with:
34-
name: artifact
35-
path: artifacts/
58+
name: ${{ env.ARTIFACTS_NAME }}
59+
path: ${{ env.ARTIFACTS_FOLDER }}
60+
61+
- name: Set up .NET Core (global.json)
62+
uses: actions/setup-dotnet@v4
63+
64+
- name: Publish NuGet packages
65+
shell: pwsh
66+
env:
67+
NUGET_APY_KEY: ${{ secrets.NUGET_APY_KEY }}
68+
run: |
69+
Write-Host "Current ref: $env:GITHUB_REF"
70+
Write-Host "Searching nupkg in folder: ${{ env.ARTIFACTS_FOLDER }}"
71+
$files = Get-ChildItem "${{ env.ARTIFACTS_FOLDER }}/*" -Include *.nupkg
72+
foreach($file in $files) {
73+
Write-Host "Pushing NuGet package: $($file.FullName)"
74+
& dotnet nuget push "$($file.FullName)" --api-key "$env:NUGET_APY_KEY" --source ${{ env.NUGET_URI }} --force-english-output --skip-duplicate
75+
}

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,30 @@ 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: ${{ vars.RUNNER }}
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
21-
run: dotnet build src/Sotsera.Sources.Common/Sotsera.Sources.Common.csproj --configuration Release
23+
- name: dotnet build (sources only)
24+
run: dotnet build src/**/*.csproj --configuration Release
25+
26+
- name: dotnet build (tests only)
27+
run: dotnet build test/**/*.csproj --configuration Release
2228

2329
- name: dotnet test
24-
run: dotnet test --configuration Release
30+
run: dotnet test --configuration Release --no-build
2531

2632
- name: dotnet format
27-
run: dotnet format -v detailed --verify-no-changes
33+
run: dotnet format -v detailed --verify-no-changes --no-restore

0 commit comments

Comments
 (0)