-
Notifications
You must be signed in to change notification settings - Fork 248
174 lines (149 loc) · 5.84 KB
/
deploy-package.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Deploy NuGet package
on:
workflow_dispatch:
inputs:
environment:
description: Deployment environment
type: choice
options:
- staging
- nuget.org
default: staging
required: true
preview:
description: Append preview suffix
type: boolean
default: true
required: true
concurrency:
group: ${{ inputs.environment }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.compose.outputs.version }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
preferLatestVersion: true
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
updateAssemblyInfo: true
useConfigFile: true
configFilePath: src/gitversion.yml
- name: Compose version
id: compose
run: |
ver=${{ steps.gitversion.outputs.majorMinorPatch }}${{ inputs.preview && '-preview.' || '' }}${{ inputs.preview && steps.gitversion.outputs.preReleaseNumber || inputs.preview && github.run_number || '' }}
echo "version=$ver" >> "$GITHUB_OUTPUT"
- name: Update release notes URL
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "<PackageReleaseNotes>https://github.com/DaveSkender/Stock.Indicators/releases</PackageReleaseNotes>"
replace: "<PackageReleaseNotes>https://github.com/DaveSkender/Stock.Indicators/releases/tag/${{ steps.compose.outputs.version }}</PackageReleaseNotes>"
regex: false
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.x"
dotnet-quality: "ga"
- name: Build library
run: >
dotnet build src/Indicators.csproj
--configuration Release
--property:Version=${{ steps.compose.outputs.version }}
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Pack for NuGet
run: >
dotnet pack src/Indicators.csproj
--configuration Release
--no-build
--include-symbols
--output NuGet
-p:PackageVersion=${{ steps.compose.outputs.version }}
- name: Save package
uses: actions/upload-artifact@v4
with:
name: packages
path: NuGet
include-hidden-files: true
- name: Summary output
run: |
{
echo "| Version No. | Component |"
echo "| :---------- | :---------------------------------------------- |"
echo "| Major | ${{ steps.gitversion.outputs.major }} |"
echo "| Minor | ${{ steps.gitversion.outputs.minor }} |"
echo "| Patch | ${{ steps.gitversion.outputs.patch }} |"
echo "| Base | ${{ steps.gitversion.outputs.majorMinorPatch }} |"
echo "| Composed | ${{ steps.compose.outputs.version }} |"
} >> $GITHUB_STEP_SUMMARY
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
environment:
name: ${{ inputs.environment }}
url: "${{ vars.NUGET_DOWNLOAD_PREFIX }}${{ needs.build.outputs.version }}"
steps:
- name: Pre-flight summary
run: |
{
echo "| Parameter | Value |"
echo "| :-------------- | :--------------------------------- |"
echo "| Environment | ${{ inputs.environment }} |"
echo "| Publishing URL | ${{ vars.NUGET_PUBLISH_URL }} |"
echo "| Download URL | ${{ vars.NUGET_DOWNLOAD_PREFIX }} |"
echo "| Version ID | ${{ needs.build.outputs.version }} |"
} >> $GITHUB_STEP_SUMMARY
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.x"
dotnet-quality: "ga"
- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_TOKEN }}
nuget-version: '6.x'
- name: Download package
uses: actions/download-artifact@v4
with:
name: packages
path: NuGet
- name: Publish to Azure Artifacts (staging)
if: inputs.environment == 'staging'
run: |
dotnet new nugetconfig --force
nuget sources Add -Name "AzureArtifacts" -Source ${{ vars.NUGET_PUBLISH_URL }} -UserName DaveSkender -Password ${{ secrets.NUGET_TOKEN }} -NonInteractive -ConfigFile nuget.config
nuget push NuGet/*.nupkg -src AzureArtifacts -ApiKey AZ -NonInteractive -ConfigFile nuget.config
- name: Publish to NuGet.org
if: inputs.environment == 'nuget.org'
run: |
dotnet new nugetconfig --force
nuget setApiKey ${{ secrets.NUGET_TOKEN }} -src nuget -ConfigFile nuget.config
nuget push NuGet/*.nupkg -src nuget -NonInteractive -ConfigFile nuget.config -Verbosity Detailed
- name: Tag and draft release note
uses: ncipollo/release-action@v1
if: inputs.environment == 'nuget.org'
with:
body: |
We’ve released a new Stock Indicators for .NET NuGet package.
See [Skender.Stock.Indicators @ NuGet.org](${{ vars.NUGET_DOWNLOAD_PREFIX }}${{ needs.build.outputs.version }}) for more information.
generateReleaseNotes: true
draft: true
makeLatest: ${{ !inputs.preview }}
prerelease: ${{ inputs.preview }}
tag: ${{ needs.build.outputs.version }}
commit: ${{ github.ref_name }}