Skip to content

Commit 0524c9e

Browse files
author
Petr Sramek
committed
test
1 parent b3a546f commit 0524c9e

File tree

6 files changed

+460
-387
lines changed

6 files changed

+460
-387
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 'Publish packages to NuGet feed'
2+
author: 'Pete Sramek'
3+
description: 'Publishes packages in working directory to public NuGet feed'
4+
inputs:
5+
# Required
6+
nuget-feed-url:
7+
description: 'NuGet feed URL'
8+
required: true
9+
nuget-feed-api-key:
10+
description: 'NuGet feed API key'
11+
required: true
12+
nuget-feed-type:
13+
description: 'NuGet feed type. Allowed values: ''NuGet'', ''AzureArtifacts'''
14+
required: true
15+
# Optional
16+
dotnet-sdk-version:
17+
description: '.NET SDK version. Default: 9.x'
18+
required: false
19+
default: '9.x'
20+
working-directory:
21+
description: 'Working directory to search for file.'
22+
required: false
23+
default: ${{ github.workspace }}
24+
25+
runs:
26+
using: composite
27+
28+
steps:
29+
30+
- if: ${{ inputs.nuget-feed-server != 'NuGet' && inputs.nuget-feed-server != 'AzureArtifacts' }}
31+
name: 'Validate NuGet feed server type'
32+
shell: bash
33+
run: |
34+
echo "Invalid NuGet feed server type. Allowed values are ''NuGet'' or ''AzureArtifacts''."
35+
exit 1
36+
37+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
38+
uses: actions/checkout@v4
39+
40+
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
41+
uses: actions/setup-dotnet@v4
42+
with:
43+
dotnet-version: ${{ inputs.dotnet-sdk-version }}
44+
45+
- if: ${{ inputs.nuget-feed-type == 'NuGet' }}
46+
name: 'Add NuGet source'
47+
shell: bash
48+
run: |
49+
dotnet nuget add source ${{ inputs.nuget-feed-url }} --name nuget-feed
50+
working-directory: ${{ inputs.working-directory }}
51+
52+
- name: 'Publish Nuget packages'
53+
shell: bash
54+
run: |
55+
dotnet nuget push **/*.nupkg --source ${{ inputs.nuget-feed-url }} --api-key ${{ inputs.nuget-feed-api-key }}
56+
working-directory: ${{ inputs.working-directory }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Write file to step summary'
2+
author: 'Pete Sramek'
3+
description: 'Writes file contents to step summary.'
4+
inputs:
5+
# Required
6+
file-glob-pattern:
7+
description: 'Search pattern for files to write.'
8+
required: true
9+
10+
# Optional
11+
working-directory:
12+
description: 'Working directory to search for file.'
13+
required: false
14+
default: ${{ github.workspace }}
15+
16+
runs:
17+
using: composite
18+
steps:
19+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
20+
uses: actions/checkout@v4
21+
22+
- name: Writing ${{ inputs.file }} to step summary
23+
shell: bash
24+
run: cat ${{ inputs.file }} >> $GITHUB_STEP_SUMMARY
25+
working-directory: ${{ inputs.working-directory }}

.github/workflows/build.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: .NET
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'preview/**'
7+
- 'release/**'
8+
- 'support/**'
9+
paths-ignore:
10+
- '!src/**'
11+
12+
permissions:
13+
actions: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: build-${{ github.head_ref || github.ref }}
19+
cancel-in-progress: false
20+
21+
env:
22+
dotnet-sdk-version: '9.x'
23+
build-configuration: 'Release'
24+
build-platform: 'Any CPU'
25+
git-version: '6.0.x'
26+
test-result-directory: 'test-results'
27+
28+
jobs:
29+
versioning:
30+
name: Versioning with GitVersion
31+
runs-on: ubuntu-latest
32+
outputs:
33+
ASSEMBLY_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}
34+
ASSEMBLY_INFORMATIONAL_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}+${{ steps.gitversion.outputs.sha }}
35+
FILE_VERSION: ${{ steps.gitversion.outputs.assemblySemVer }}.${{ github.run_number }}
36+
PACKAGE_VERSION: ${{ fromJSON(format('[ "{0}{1}", "{0}" ]', steps.gitversion.outputs.assemblySemVer, steps.gitversion.outputs.preReleaseLabelWithDash))[fromJSON(env.is-release)] }}
37+
38+
steps:
39+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
- name: Install GitVersion ${{ env.git-version }}
44+
uses: gittools/actions/gitversion/setup@v3.1.11
45+
with:
46+
versionSpec: ${{ env.git-version }}
47+
preferLatestVersion: true
48+
- name: Determine version with GitVersion ${{ env.git-version }}
49+
id: gitversion
50+
uses: gittools/actions/gitversion/execute@v3.1.11
51+
with:
52+
useConfigFile: true
53+
configFilePath: ./.gitversion/version.yml
54+
55+
build:
56+
name: Build with .NET
57+
needs: [versioning]
58+
runs-on: ubuntu-latest
59+
env:
60+
ASSEMBLY_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_VERSION }}
61+
ASSEMBLY_INFORMATIONAL_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_INFORMATIONAL_VERSION }}
62+
FILE_VERSION: ${{ needs.versioning.outputs.FILE_VERSION }}
63+
steps:
64+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
65+
uses: actions/checkout@v4
66+
67+
- uses: ./.github/actions/build
68+
with:
69+
assembly-version: ${{ env.ASSEMBLY_VERSION }}
70+
assembly-informational-version: ${{ env.ASSEMBLY_INFORMATIONAL_VERSION }}
71+
assembly-file-version: ${{ env.FILE_VERSION }}
72+
treat-warnins-as-error: ${{ env.is-release }}
73+
build-glob-pattern: ${{ vars.SRC_DEFAULT_GLOB_PATTERN }}
74+
75+
test:
76+
name: Test with .NET
77+
needs: [build]
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
81+
uses: actions/checkout@v4
82+
83+
- name: 'Setup .NET'
84+
uses: actions/setup-dotnet@v4
85+
with:
86+
dotnet-version: ${{ env.dotnet-sdk-version }}
87+
88+
- uses: ./.github/actions/test
89+
with:
90+
test-project-glob-pattern: ${{ vars.TEST_DEFAULT_GLOB_PATTERN }}
91+
test-results-directory: '${{ runner.temp }}/test-results/'
92+
code-coverage-settings-file: '${{ github.workspace}}/code-coverage-settings.xml'
93+
94+
- uses: ./.github/actions/test-report
95+
id: test-report
96+
with:
97+
test-result-folder: '${{ runner.temp }}/test-results/'
98+
99+
- name: Write test report summary
100+
uses: ./.github/action/write-file-to-summary
101+
with:
102+
file-path: ${{ steps.test-report.outputs.test-report-file }}
103+
104+
- uses: ./.github/actions/code-coverage
105+
id: code-coverage-report
106+
with:
107+
test-result-folder: '${{ runner.temp }}/test-results/'
108+
109+
- name: Write code coverage report summary
110+
uses: ./.github/action/write-file-to-summary
111+
with:
112+
file-path: ${{ steps.code-coverage-report.outputs.code-coverage-report-file }}
113+
114+
pack:
115+
name: Pack with .NET
116+
needs: [build, versioning]
117+
runs-on: ubuntu-latest
118+
env:
119+
ASSEMBLY_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_VERSION }}
120+
ASSEMBLY_INFORMATIONAL_VERSION: ${{ needs.versioning.outputs.ASSEMBLY_INFORMATIONAL_VERSION }}
121+
FILE_VERSION: ${{ needs.versioning.outputs.FILE_VERSION }}
122+
PACKAGE_VERSION: ${{ needs.versioning.outputs.PACKAGE_VERSION }}
123+
steps:
124+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
125+
uses: actions/checkout@v4
126+
- name: Setup .NET
127+
uses: actions/setup-dotnet@v4
128+
with:
129+
dotnet-version: ${{ env.dotnet-sdk-version }}
130+
- name: Download Build
131+
uses: actions/download-artifact@v4
132+
with:
133+
name: build
134+
- name: Pack with .NET
135+
run: |
136+
dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.PACKAGE_VERSION }} /p:Version=${{ env.ASSEMBLY_VERSION }} /p:AssemblyInformationalVersion=${{ env.ASSEMBLY_INFORMATIONAL_VERSION }} /p:FileVersion=${{ env.FILE_VERSION }} --output ${{ runner.temp }}/packages/
137+
- name: Upload Package
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: package
141+
path: |
142+
${{ runner.temp }}/packages/**/*.nupkg
143+
${{ runner.temp }}/packages/**/*.snupkg
144+
145+
publish-internal-package:
146+
if: ${{ !github.env.is_release }}
147+
name: Publish package with .NET CLI
148+
needs: [pack]
149+
runs-on: ubuntu-latest
150+
steps:
151+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
152+
uses: actions/checkout@v4
153+
- name: Dotnet Setup
154+
uses: actions/setup-dotnet@v4
155+
with:
156+
dotnet-version: ${{ env.dotnet-sdk-version }}
157+
- name: Download Packages
158+
uses: actions/download-artifact@v4
159+
with:
160+
name: package
161+
path: ${{ runner.temp }}/packages/
162+
- run: |
163+
dotnet nuget add source ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_URL }} --name private-feed --username username --password ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_API_KEY }} --store-password-in-clear-text
164+
dotnet nuget push **/*.nupkg --source private-feed --api-key ${{ secrets.PRIVATE_NUGET_PACKAGE_FEED_API_KEY }}
165+
working-directory: ${{ runner.temp }}/packages/

0 commit comments

Comments
 (0)