-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreatenuget-withbuildnumber.yml
More file actions
110 lines (98 loc) · 3.59 KB
/
createnuget-withbuildnumber.yml
File metadata and controls
110 lines (98 loc) · 3.59 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
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
name: shared workflow to create nuget artifact
# When this action will be executed
on:
workflow_call:
inputs:
version-suffix:
description: The quality to add to the version number (beta.|preview.)
default: ""
required: false
type: string
version-number:
description: The number to add to the version after the suffix.
required: true
type: string
version-offset:
description: The offset to add to the version number.
default: 0
required: false
type: number
solutionfile-path:
description: The path to the solution file.
required: true
type: string
projectfile-path:
description: The path to the project file.
required: true
type: string
dotnet-version:
description: The version of the .NET SDK to use.
required: true
type: string
artifact-name:
description: The name of the artifact to create.
required: true
type: string
branch-name:
description: The name of the branch to checkout.
default: main
required: false
type: string
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout to the branch
uses: actions/checkout@v5
with:
ref: ${{ inputs.branch-name }}
# Fetch all history for proper source control information in deterministic builds
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Calculate version suffix with offset
id: version
env:
VERSION_NUMBER: ${{ inputs.version-number }}
VERSION_OFFSET: ${{ inputs.version-offset }}
run: |
echo "version-number-with-offset=$(($VERSION_NUMBER + $VERSION_OFFSET))" >> "$GITHUB_OUTPUT"
- name: Concatenate version suffix
id: version-suffix
env:
VERSION_SUFFIX: ${{ inputs.version-suffix }}
VERSION_NUMBER_WITH_OFFSET: ${{ steps.version.outputs.version-number-with-offset }}
run: |
echo "version-suffix-string=$VERSION_SUFFIX$VERSION_NUMBER_WITH_OFFSET" >> "$GITHUB_OUTPUT"
- name: Build the library (deterministic)
run: |
echo "Building with deterministic settings..."
dotnet build --version-suffix ${{ steps.version-suffix.outputs.version-suffix-string }} -c Release ${{ inputs.solutionfile-path }} \
/p:ContinuousIntegrationBuild=true \
/p:Deterministic=true \
/p:EmbedUntrackedSources=true \
/p:DebugType=embedded \
/p:PublishRepositoryUrl=true \
/p:PathMap='$(MSBuildProjectDirectory)=/'
- name: Run the unit tests
run: dotnet test ${{ inputs.solutionfile-path }}
- name: Create a Package (deterministic)
run: |
echo "Creating deterministic NuGet package..."
dotnet pack --version-suffix ${{ steps.version-suffix.outputs.version-suffix-string }} -c Release ${{ inputs.projectfile-path }} -o packages \
/p:ContinuousIntegrationBuild=true \
/p:Deterministic=true \
/p:EmbedUntrackedSources=true \
/p:DebugType=embedded \
/p:PublishRepositoryUrl=true \
/p:PathMap='$(MSBuildProjectDirectory)=/'
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: packages/*
retention-days: 3