12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- name : Build and publish artifacts from main and develop
15
+ name : Build and publish
16
16
17
17
# Triggers build on pushes to the main and develop branches.
18
18
on :
19
19
push :
20
20
branches :
21
- - main
22
- - ' develop**'
21
+ - ' main'
22
+ - ' develop'
23
+ paths :
24
+ - ' **.h'
25
+ - ' **.c'
26
+ - ' **.cs'
27
+ - ' **.csproj'
28
+ - ' **.sln'
29
+ - ' .github/workflows/build-and-publish.yml'
30
+
23
31
workflow_dispatch :
24
32
inputs :
25
33
push-to-dev :
26
34
description : ' Push to internal NuGet'
27
- required : true
35
+ required : false
36
+ default : false
28
37
type : boolean
29
38
version :
30
39
description : ' Version'
@@ -39,18 +48,16 @@ permissions:
39
48
40
49
jobs :
41
50
build :
42
- # Give this job a friendly name to show in GitHub UI.
43
- name : Build + Test the SDK
44
-
45
- # Even though we build for multiple platforms, we only need to run
46
- # on a single host operating system. This is because we utilize cross-
47
- # build functionality of the dotnet build system.
51
+ name : Build
48
52
runs-on : windows-2019
49
53
50
54
steps :
51
55
# Checkout the local repository
52
56
- uses : actions/checkout@v4
53
-
57
+ - uses : actions/setup-dotnet@v4
58
+ with :
59
+ global-json-file : global.json
60
+
54
61
- name : Add local NuGet repository
55
62
run : dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Yubico/index.json"
56
63
@@ -65,15 +72,17 @@ jobs:
65
72
$versionProp.Save($file.FullName)
66
73
67
74
# Build the project
68
- # The default GitHub runners seem to have N and N-1 versions of .NET Framework installed. In practice, they seem
69
- # to have even more installed than that, but at a minimum N and N-1 seem like safe assumptions. We can therefore
70
- # save some time and use the pre-installed version rather than downloading a fresh copy.
71
-
72
75
- name : Build Yubico.NET.SDK.sln
73
76
run : dotnet build --configuration ReleaseWithDocs --nologo --verbosity normal Yubico.NET.SDK.sln
74
77
75
- # Upload artifacts
78
+ # Run tests
79
+ - name : Test Yubico.YubiKey
80
+ run : dotnet test --configuration ReleaseWithDocs --verbosity normal --no-build --nologo Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj
81
+
82
+ - name : Test Yubico.Core
83
+ run : dotnet test --configuration ReleaseWithDocs --verbosity normal --no-build --nologo Yubico.Core/tests/Yubico.Core.UnitTests.csproj
76
84
85
+ # Upload artifacts
77
86
- name : Save documentation artifacts
78
87
uses : actions/upload-artifact@v4
79
88
with :
88
97
Yubico.DotNetPolyfills/src/bin/ReleaseWithDocs/*.nupkg
89
98
Yubico.Core/src/bin/ReleaseWithDocs/*.nupkg
90
99
Yubico.YubiKey/src/bin/ReleaseWithDocs/*.nupkg
100
+
101
+ - name : Save build artifacts
102
+ uses : actions/upload-artifact@v4
103
+ with :
104
+ name : Symbols Packages
105
+ path : |
106
+ Yubico.DotNetPolyfills/src/bin/ReleaseWithDocs/*.snupkg
107
+ Yubico.Core/src/bin/ReleaseWithDocs/*.snupkg
108
+ Yubico.YubiKey/src/bin/ReleaseWithDocs/*.snupkg
91
109
92
110
- name : Save build artifacts
93
111
uses : actions/upload-artifact@v4
@@ -115,72 +133,16 @@ jobs:
115
133
path : |
116
134
Yubico.YubiKey/examples/PivSampleCode
117
135
Yubico.YubiKey/examples/SharedSampleCode
118
-
119
- # Test the project
120
- #
121
- # Here we call `dotnet test` on each individual test project that we want to have run as part of CI. We do this
122
- # to skip running the integration tests which require actual YubiKeys to be present. We have tried using the filter
123
- # capabilities of the `dotnet test` runner tool, however we have found that failures don't always register with
124
- # GitHub when that is done.
125
-
126
- - name : Test Yubico.YubiKey
127
- run : dotnet test --configuration ReleaseWithDocs --verbosity normal --no-build --nologo Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj
128
-
129
- - name : Test Yubico.Core
130
- run : dotnet test --configuration ReleaseWithDocs --verbosity normal --no-build --nologo Yubico.Core/tests/Yubico.Core.UnitTests.csproj
131
-
132
- publish_docs :
133
- # Give this job a friendly name to show in GitHub UI.
134
- name : Publish documentation
135
-
136
- # Publish the docs using Ubuntu as the docker image we want to create is linux-based.
137
- runs-on : ubuntu-latest
138
-
139
- # Don't run this step until build completes.
140
- needs : build
141
-
142
- # Connection information for our docker image registry
143
- env :
144
- IMAGE_REGISTRY_URL : us-docker.pkg.dev
145
- IMAGE_REGISTRY_PROJECT : support-cluster-769001
146
- IMAGE_REPOSITORY : yesdk
147
- IMAGE_NAME : yesdk-docserver
148
-
149
- steps :
150
- # Checkout the local repository as we need the Dockerfile and other things even for this step.
151
- - uses : actions/checkout@v4
152
-
153
- # Grab the just-built documentation artifact and inflate the archive at the expected location.
154
- - uses : actions/download-artifact@v4
155
- with :
156
- name : Documentation
157
- path : Yubico.YubiKey/docs/_site/
158
-
159
- # Construct the docker image
160
- - name : Docker build
161
- run : |
162
- docker build -t "${IMAGE_NAME}:${{ github.sha }}" .
163
136
164
- # Authenticate to Google Cloud
165
- - name : Authenticate
166
- uses : google-github-actions/auth@v2
167
- with :
168
- workload_identity_provider : ${{ vars.GLOBAL_GCP_WORKLOAD_IDENTITY_PROVIDER }}
169
- service_account :
[email protected]
170
-
171
- # Push our docker image to GCP
172
- - name : Push Docker image
173
- run : |
174
- gcloud auth configure-docker ${IMAGE_REGISTRY_URL} --project ${IMAGE_REGISTRY_PROJECT}
175
- docker tag "${IMAGE_NAME}:${{ github.sha }}" "${IMAGE_REGISTRY_URL}/${IMAGE_REGISTRY_PROJECT}/${IMAGE_REPOSITORY}/${IMAGE_NAME}:${{ github.sha }}"
176
- docker push "${IMAGE_REGISTRY_URL}/${IMAGE_REGISTRY_PROJECT}/${IMAGE_REPOSITORY}/${IMAGE_NAME}:${{ github.sha }}"
177
- echo "New image tag: ${{ github.sha }}"
137
+ upload-docs :
138
+ name : Upload docs
139
+ uses : ./.github/workflows/upload-docs.yml
140
+ needs : build
178
141
179
142
publish-internal :
180
143
name : Publish to internal NuGet
181
144
runs-on : windows-2019
182
145
needs : build
183
- environment : Internal NuGet feed
184
146
if : ${{ github.event.inputs.push-to-dev }}
185
147
steps :
186
148
- uses : actions/download-artifact@v4
0 commit comments