Skip to content

Commit dafe1f5

Browse files
Pack & push to nuget.
1 parent 57817be commit dafe1f5

File tree

3 files changed

+51
-13
lines changed

3 files changed

+51
-13
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
name: CI
22
on:
33
push:
4-
pull_request:
5-
4+
branches: [ dev ]
5+
paths:
6+
- "**/*.csproj"
7+
- "Directory.Build.props"
8+
- ".github/workflows/ci.yml"
69
jobs:
7-
build-test:
10+
pack-and-push:
811
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
916
steps:
1017
- uses: actions/checkout@v4
11-
- uses: actions/setup-dotnet@v4
12-
with:
13-
dotnet-version: 9.0.304
14-
- name: Cache NuGet
15-
uses: actions/cache@v4
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
1620
with:
17-
path: ~/.nuget/packages
18-
key: nuget-${{ runner.os }}-${{ hashFiles('**/packages.lock.json', '**/*.csproj', '**/global.json') }}
19-
- run: dotnet restore
20-
- run: dotnet build --configuration Release --no-restore
21-
- run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage"
21+
dotnet-version: '9.0.304'
22+
- name: Set VERSION sufix for CI
23+
run: echo "VERSION_SUFFIX=-ci-$(date +'%Y%m%d%H%M%S').${{ github.run_number }}" >> $GITHUB_ENV
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
- name: Build
27+
run: dotnet build --no-restore --configuration Release
28+
- name: Add GitHub Packages as a NuGet source
29+
run: |
30+
dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
31+
--name "github" \
32+
--username "${{ github.actor }}" \
33+
--password "${{ secrets.GITHUB_TOKEN }}" \
34+
--store-password-in-clear-text \
35+
|| true
36+
- name: Pack and push NuGet packages
37+
run: |
38+
for nupkg in ./artifacts/*.nupkg; do
39+
dotnet nuget push "$nupkg" --source "github" --skip-duplicate;
40+
done

Directory.Build.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<Target Name="CopyReadme" AfterTargets="Pack">
3+
<Copy SourceFiles="README.md" DestinationFolder="$(OutputPath)" />
4+
</Target>
5+
</Project>

nuget.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="github" value="https://nuget.pkg.github.com/TaskHub-Server/index.json" />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6+
</packageSources>
7+
8+
<packageSourceCredentials>
9+
<github>
10+
<add key="Username" value="andrey-serdyuk" />
11+
<add key="Password" value="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" />
12+
</github>
13+
</packageSourceCredentials>
14+
</configuration>

0 commit comments

Comments
 (0)