Skip to content

Commit 79ef8b6

Browse files
authored
Add .NET pack composite action (#14)
* Add dotnet pack push composite action * Add dotnet env vars * Fix typo
1 parent 7ea4591 commit 79ef8b6

4 files changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/reusable-dotnet-quality.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,7 @@ jobs:
171171
./**/Summary.txt
172172
./**/fossa.html
173173
env:
174+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
175+
DOTNET_NOLOGO: 1
174176
# https://docs.github.com/en/actions/reference/workflows-and-actions/contexts
175177
GITHUB_TOKEN: ${{ github.token }}

actions/dotnet/build-test-sonar/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ runs:
7878
- name: Build .NET solution
7979
run: dotnet build --no-restore --configuration Debug
8080
shell: bash
81+
env:
82+
BUILD_SOURCEBRANCHNAME: ${{ github.ref_name }}
83+
BUILD_BUILDID: ${{ github.run_id }}
8184
- name: Run tests
8285
run: |
8386
dotnet test --no-build --verbosity normal --configuration Debug \

actions/dotnet/build-test/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ runs:
1717
- name: Build .NET code
1818
run: dotnet build --no-restore --configuration Debug
1919
shell: bash
20+
env:
21+
BUILD_SOURCEBRANCHNAME: ${{ github.ref_name }}
22+
BUILD_BUILDID: ${{ github.run_id }}
2023
- name: Run tests
2124
run: |
2225
dotnet test --no-build --verbosity normal --configuration Debug \
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Pack & Push
2+
description: Package .NET projects and push to the registry
3+
4+
inputs:
5+
dotnet-version:
6+
description: .NET SDK version to be used
7+
required: false
8+
default: "10.0"
9+
registry-token:
10+
description: Registry
11+
required: true
12+
registry-address:
13+
description: Registry address (NuGet.org by default)
14+
required: false
15+
default: "https://api.nuget.org/v3/index.json"
16+
push-enabled:
17+
description: Push
18+
required: false
19+
default: "false"
20+
21+
runs:
22+
using: "composite"
23+
steps:
24+
- name: Install .NET
25+
uses: actions/setup-dotnet@v5
26+
with:
27+
dotnet-version: ${{ inputs.dotnet-version }}
28+
- name: Package
29+
# "**/*.csproj;!**/*Tests.csproj"
30+
run: dotnet pack --configuration Release -o output
31+
shell: bash
32+
env:
33+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
34+
DOTNET_NOLOGO: 1
35+
BUILD_SOURCEBRANCHNAME: ${{ github.ref_name }}
36+
BUILD_BUILDID: ${{ github.run_id }}
37+
- name: Push to registry
38+
if: ${{ inputs.push-enabled == 'true' }}
39+
# "$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg"
40+
run: for f in output/*.nupkg; do dotnet nuget push "$f" --api-key ${{ inputs.registry-token }} --source ${{ inputs.registry-address }} ; done
41+
shell: bash

0 commit comments

Comments
 (0)