-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (65 loc) · 2.63 KB
/
release-nuget-package.yml
File metadata and controls
75 lines (65 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: 'Release NuGet package'
on:
workflow_call:
inputs:
# Required
artifact-run-id:
description: 'The run ID of the artifact workflow.'
required: true
type: string
artifact-name:
description: 'The name of the artifact to download.'
required: true
type: string
nuget-feed-server:
description: 'NuGet feed type. Allowed values: ''NuGet'', ''AzureArtifacts''.'
type: 'string'
required: true
environment:
description: 'Environment to run the action in.'
type: 'string'
required: true
# Optional
dotnet-sdk-version:
description: 'Version of the .NET SDK to use. Default: ''9.0.x''.'
type: string
required: false
default: '9.0.x'
jobs:
release-package:
name: ${{ inputs.environment }}
runs-on: ubuntu-latest
env:
working-directory: '/packages/${{ github.run_id }}-${{ github.run_attempt }}'
environment:
name: ${{ inputs.environment }}
steps:
- if: ${{ !(inputs.nuget-feed-server == 'NuGet' || inputs.nuget-feed-server == 'AzureArtifacts') }}
name: 'Invalid NuGet feed server type'
shell: bash
run: |
echo 'Invalid NuGet feed server type ${{ inputs.nuget-feed-server }}. Allowed values are 'NuGet' or 'AzureArtifacts'.'
exit 1
- name: 'Setup .NET ${{ inputs.dotnet-sdk-version }}'
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet-sdk-version }}
- name: 'Download artifact'
uses: actions/download-artifact@v5
with:
run-id: ${{ inputs.artifact-run-id }}
name: ${{ inputs.artifact-name }}
path: ${{ runner.temp }}/${{ env.working-directory }}
- if: ${{ inputs.nuget-feed-server == 'NuGet' }}
name: 'Publish package to NuGet'
shell: bash
run: |
dotnet nuget push **/*.nupkg --source ${{ vars.NUGET_PACKAGE_FEED_URL }} --api-key ${{ secrets.NUGET_PACKAGE_FEED_API_KEY }}
working-directory: ${{ runner.temp }}/${{ env.working-directory }}
- if: ${{ inputs.nuget-feed-server == 'AzureArtifacts' }}
name: 'Publish package to Azure Artifacts'
shell: bash
run: |
dotnet nuget add source ${{ vars.NUGET_PACKAGE_FEED_URL }} --name nuget-feed --username username --password ${{ secrets.NUGET_PACKAGE_FEED_API_KEY }} --store-password-in-clear-text
dotnet nuget push **/*.nupkg --source nuget-feed --api-key ${{ secrets.NUGET_PACKAGE_FEED_API_KEY }} --skip-duplicate
working-directory: ${{ runner.temp }}/${{ env.working-directory }}