-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
123 lines (111 loc) · 4.53 KB
/
action.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: '.NET Library Build and Release'
description: 'A Composite Action that Builds, Publishes and Releases a .NET 7+ Library'
author: 'RICADO'
branding:
icon: 'link'
color: 'blue'
# Inputs
inputs:
project-name:
description: 'The Project Name (e.g. RICADO.Logging)'
required: true
github-token:
description: 'The GitHub Token used to Generate a Changelog and Create Releases'
required: true
private-nuget-url:
description: 'The URL of the Private NuGet Repository (e.g. https://nuget.pkg.github.com/myname/index.json)'
required: true
private-nuget-token:
description: 'The Token used for Authentication with the Private NuGet Repository'
required: true
public-nuget-url:
description: 'The URL of the Public NuGet Repository (e.g. https://api.nuget.org/v3/index.json)'
required: false
default: 'https://api.nuget.org/v3/index.json'
public-nuget-token:
description: 'The Token used for Authentication with the Public NuGet Repository'
required: false
publish-public:
description: 'Whether the Library should be Published to the Public NuGet Repository'
required: false
default: 'false'
dotnet-version:
description: 'The .NET SDK Version to be used for Builds (e.g. 7.0.x)'
required: false
default: '7.0.x'
# Outputs
outputs:
changelog:
description: 'Markdown formatted changelog'
value: ${{ steps.changelog.outputs.changelog }}
runs:
using: 'composite'
steps:
# Step 1 - Extract Environment Variables
- name: Extract Environment Variables
uses: FranzDiebold/github-env-vars-action@v2
# Step 2 - Setup .NET with GitHub Packages Authentication
- name: Setup .NET with GitHub Packages Authentication
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet-version }}
source-url: ${{ inputs.private-nuget-url }}
env:
NUGET_AUTH_TOKEN: ${{ inputs.private-nuget-token }}
# Step 3 - Restore NuGet Packages
- name: Restore NuGet Packages
run: dotnet restore "${{ inputs.project-name }}/${{ inputs.project-name }}.csproj"
shell: bash
# Step 4 - Build the Library
- name: Build the Library
run: dotnet build "${{ inputs.project-name }}/${{ inputs.project-name }}.csproj" -c Release --no-restore
shell: bash
# Step 5 - Pack the Library
- name: Pack the Library
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: dotnet pack "${{ inputs.project-name}}/${{ inputs.project-name }}.csproj" -c Release -p:PackageVersion=${{ env.CI_REF_NAME }}
shell: bash
# Step 6 - Generate the Changelog
- name: Generate the Changelog
id: changelog
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: metcalfc/[email protected]
with:
mytoken: ${{ inputs.github-token }}
# Step 7 - Create Draft GitHub Release
# NOTE: Skipping until GitHub resolves an issue: https://github.com/cli/cli/issues/3037
- name: Create Draft GitHub Release
id: create-draft-release
if: ${{ false && startsWith(github.ref, 'refs/tags/') }}
uses: ncipollo/release-action@v1
with:
body: ${{ steps.changelog.outputs.changelog }}
draft: true
name: Version ${{ env.CI_REF_NAME }}
tag: ${{ env.CI_REF_NAME }}
token: ${{ inputs.github-token }}
# Step 8 - Push the Package to GitHub Packages
- name: Push the Package to GitHub Packages
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: dotnet nuget push "${{ inputs.project-name }}/bin/Release/*.nupkg" -k ${{ inputs.private-nuget-token }} -s "${{ inputs.private-nuget-url }}" --skip-duplicate
shell: bash
# Step 9 - Push the Package to NuGet
- name: Push the Package to Nuget
if: ${{ startsWith(github.ref, 'refs/tags/') && inputs.publish-public == 'true' }}
run: dotnet nuget push "${{ inputs.project-name }}/bin/Release/*.nupkg" -k ${{ inputs.public-nuget-token }} -s "${{ inputs.public-nuget-url }}" --skip-duplicate
shell: bash
# Step 10 - Publish GitHub Release
- name: Publish GitHub Release
id: publish-release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
draft: false
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
tag: ${{ env.CI_REF_NAME }}
token: ${{ inputs.github-token }}
updateOnlyUnreleased: true
body: ${{ steps.changelog.outputs.changelog }}
name: Version ${{ env.CI_REF_NAME }}