@@ -24,13 +24,17 @@ concurrency:
2424 cancel-in-progress : true
2525
2626env :
27- containerImage : " kubernetes-reflector"
28- containerImageBuildContext : " src/"
29- containerImageBuildDockerfile : " src/ES.Kubernetes.Reflector/Dockerfile"
30- dockerHubContainerImageRepository : " emberstack"
31- ghcrContainerImageRepository : " ghcr.io/emberstack"
32- helmChart : " reflector"
33- helmChartDir : " src/helm/reflector"
27+ helm_chart : " reflector"
28+ helm_chart_dir : " src/helm/reflector"
29+ helm_chart_repository : " ghcr.io/emberstack/helm-charts"
30+ helm_chart_repository_protocol : " oci://"
31+
32+ container_image : " kubernetes-reflector"
33+ container_image_build_context : " ."
34+ container_image_build_platforms : " linux/amd64,linux/arm/v7,linux/arm64"
35+ container_image_build_dockerfile : " src/ES.Kubernetes.Reflector/Dockerfile"
36+ container_image_repository_dockerhub : " emberstack"
37+ container_image_repository_ghcr : " ghcr.io/emberstack"
3438
3539jobs :
3640 discovery :
4246 pathsFilter_src : ${{ steps.pathsFilter.outputs.src }}
4347 gitVersion_SemVer : ${{ steps.gitversion.outputs.GitVersion_SemVer }}
4448 gitVersion_AssemblySemFileVer : ${{ steps.gitversion.outputs.GitVersion_AssemblySemFileVer }}
45- requiresBuild : ${{ steps.requires_build.outputs.result }}
46- requiresBuildPush : ${{ steps.requires_build_push.outputs.result }}
47- requiresRelease : ${{ steps.requires_release.outputs.result }}
49+ build : ${{ steps.evaluate_build.outputs.result }}
50+ build_push : ${{ steps.evaluate_build_push.outputs.result }}
51+ build_configuration : ${{ steps.evaluate_build_configuration.outputs.result }}
52+ release : ${{ steps.evaluate_release.outputs.result }}
4853 steps :
4954 - name : checkout
5055 uses : actions/checkout@v4
@@ -76,12 +81,22 @@ jobs:
7681 base : ${{ github.ref }}
7782 filters : |
7883 src:
84+ - '*.sln'
85+ - '*.slnx'
86+ - '*.props'
7987 - 'src/**'
88+ build:
89+ - '*.sln'
90+ - '*.slnx'
91+ - '*.props'
92+ - 'src/**'
93+ - 'tests/**'
94+ - 'playground/**'
8095
81- - name : evaluate - requires_build
82- id : requires_build
96+ - name : evaluate - build
97+ id : evaluate_build
8398 run : |
84- if [ "${{ steps.pathsFilter.outputs.src }}" = "true" ] || \
99+ if [ "${{ steps.pathsFilter.outputs.build }}" = "true" ] || \
85100 [ "${{ github.event.inputs.force_build }}" = "true" ] || \
86101 [ "${{ github.event.inputs.force_publish }}" = "true" ]; then
87102 result=true
@@ -90,18 +105,28 @@ jobs:
90105 fi
91106 echo "result=$result" >> $GITHUB_OUTPUT
92107
93- - name : evaluate - requires_build_push
94- id : requires_build_push
108+ - name : evaluate - build_push
109+ id : evaluate_build_push
95110 run : |
96- if [ "${{ steps.requires_build .outputs.result }}" = "true" ]; then
111+ if [ "${{ steps.evaluate_build .outputs.result }}" = "true" ]; then
97112 result=true
98113 else
99114 result=false
100115 fi
101116 echo "result=$result" >> $GITHUB_OUTPUT
102117
103- - name : evaluate - requires_release
104- id : requires_release
118+ - name : evaluate - build_configuration
119+ id : evaluate_build_configuration
120+ run : |
121+ if [ "${{ github.ref }}" = "refs/heads/main" ]; then
122+ result=Release
123+ else
124+ result=Debug
125+ fi
126+ echo "result=$result" >> $GITHUB_OUTPUT
127+
128+ - name : evaluate - release
129+ id : evaluate_release
105130 run : |
106131 if [ "${{ github.ref }}" = "refs/heads/main" ] || \
107132 [ "${{ github.event.inputs.force_publish }}" = "true" ]; then
@@ -111,47 +136,66 @@ jobs:
111136 fi
112137 echo "result=$result" >> $GITHUB_OUTPUT
113138
114-
115-
116139 build :
117140 name : build
118- if : ${{ needs.discovery.outputs.requiresBuild == 'true' }}
141+ if : ${{ needs.discovery.outputs.build == 'true' }}
119142 needs : [discovery]
120143 runs-on : ubuntu-latest
121144 env :
145+ build : ${{ needs.discovery.outputs.build }}
146+ build_push : ${{ needs.discovery.outputs.build_push }}
147+ build_configuration : ${{ needs.discovery.outputs.build_configuration }}
122148 gitVersion_SemVer : ${{ needs.discovery.outputs.gitVersion_SemVer }}
123149 gitVersion_AssemblySemFileVer : ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }}
124150 steps :
125151 - name : checkout
126152 uses : actions/checkout@v4
127153
128- - name : tools - kubectl - install
129- uses : azure/setup-kubectl@v4
154+ - name : artifacts - prepare directories
155+ run : |
156+ mkdir -p .artifacts/helm
157+ mkdir -p .artifacts/kubectl
130158
131- - name : tools - oras - install
132- uses : oras-project/setup-oras@v1
159+ - name : tools - dotnet - install
160+ uses : actions/setup-dotnet@v4
161+ with :
162+ dotnet-version : " 9.x"
133163
134- - name : tools - oras - login - ghcr.io
135- if : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
136- run : echo "${{ secrets.ES_GITHUB_PAT }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
164+ - name : dotnet - restore
165+ run : dotnet restore
166+
167+ - name : dotnet - build
168+ run : dotnet build --no-restore --configuration ${{ env.build_configuration }} /p:Version=${{ env.gitVersion_SemVer }} /p:AssemblyVersion=${{env.gitVersion_AssemblySemFileVer}} /p:NuGetVersion=${{env.gitVersion_SemVer}}
169+
170+ - name : dotnet - test
171+ run : dotnet test --no-build --configuration ${{ env.build_configuration }} --verbosity normal
172+
173+ - name : tests - report
174+ uses : dorny/test-reporter@v2
175+ if : ${{ github.event.pull_request.head.repo.fork == false }}
176+ with :
177+ name : Test Results
178+ path : .artifacts/TestResults/*.trx
179+ reporter : dotnet-trx
180+ fail-on-empty : " false"
137181
138182 - name : tools - helm - install
139183 uses : azure/setup-helm@v4
140184
141185 - name : tools - helm - login - ghcr.io
142- if : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
186+ if : ${{ env.build_push == 'true' }}
143187 run : echo "${{ secrets.ES_GITHUB_PAT }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
144188
145189 - name : tools - docker - login ghcr.io
146- if : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
190+ if : ${{ env.build_push == 'true' }}
147191 uses : docker/login-action@v3
148192 with :
149193 registry : ghcr.io
150194 username : ${{ github.actor }}
151195 password : ${{ secrets.ES_GITHUB_PAT }}
152196
153197 - name : tools - docker - login docker.io
154- if : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
198+ if : ${{ env.build_push == 'true' }}
155199 uses : docker/login-action@v3
156200 with :
157201 registry : docker.io
@@ -167,62 +211,98 @@ jobs:
167211 with :
168212 driver : docker-container # REQUIRED for multi-platform builds
169213
170- - name : artifacts - prepare directories
171- run : |
172- mkdir -p .artifacts/helm
173- mkdir -p .artifacts/kubectl
174- mkdir -p .artifacts/artifacthub
175-
176214 - name : helm - import README
177- run : cp README.md ${{ env.helmChartDir }}/README.md
215+ run : cp README.md ${{ env.helm_chart_dir }}/README.md
178216
179217 - name : helm - package chart
180- run : helm package --destination .artifacts/helm --version ${{ env.gitVersion_SemVer }} --app-version ${{ env.gitVersion_SemVer }} ${{ env.helmChartDir }}
218+ run : helm package --destination .artifacts/helm --version ${{ env.gitVersion_SemVer }} --app-version ${{ env.gitVersion_SemVer }} ${{ env.helm_chart_dir }}
181219
182220 - name : helm - template chart
183- run : helm template --namespace kube-system ${{ env.helmChart }} .artifacts/helm/${{ env.helmChart }}-${{ env.gitVersion_SemVer }}.tgz > .artifacts/kubectl/${{ env.helmChart }}.yaml
221+ run : helm template --namespace kube-system ${{ env.helm_chart }} .artifacts/helm/${{ env.helm_chart }}-${{ env.gitVersion_SemVer }}.tgz > .artifacts/kubectl/${{ env.helm_chart }}.yaml
184222
185223 - name : helm - artifacthub - repo
186- run : install -D src/helm/artifacthub-repo.yaml .artifacts/artifacthub /artifacthub-repo.yaml
224+ run : install -D src/helm/artifacthub-repo.yaml .artifacts/helm /artifacthub-repo.yaml
187225
188226 - name : docker - build and push
189227 uses : docker/build-push-action@v6
190228 with :
191- context : ${{ env.containerImageBuildContext }}
192- file : ${{ env.containerImageBuildDockerfile }}
193- push : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
229+ context : ${{ env.container_image_build_context }}
230+ file : ${{ env.container_image_build_dockerfile }}
231+ push : ${{ env.build_push == 'true' }}
194232 provenance : false
195- platforms : linux/amd64,linux/arm/v7,linux/arm64
233+ platforms : ${{ env.container_image_build_platforms }}
196234 labels : |
197235 org.opencontainers.image.source=https://github.com/${{ github.repository }}
198236 org.opencontainers.image.url=https://github.com/${{ github.repository }}
199- org.opencontainers.image.vendor=${{ github.repository_owner }}
237+ org.opencontainers.image.vendor=https://github.com/ ${{ github.repository_owner }}
200238 org.opencontainers.image.version=${{ env.gitVersion_SemVer }}
201239 org.opencontainers.image.revision=${{ github.sha }}
202240 tags : |
203- ${{ env.dockerHubContainerImageRepository }}/${{ env.containerImage }}:${{ env.gitVersion_SemVer }}
204- ${{ env.ghcrContainerImageRepository }}/${{ env.containerImage }}:${{ env.gitVersion_SemVer }}
241+ ${{ env.container_image_repository_dockerhub }}/${{ env.container_image }}:${{ env.gitVersion_SemVer }}
242+ ${{ env.container_image_repository_ghcr }}/${{ env.container_image }}:${{ env.gitVersion_SemVer }}
205243
206- - name : helm - push - ghcr.io
207- run : helm push .artifacts/helm/${{ env.helmChart }}-${{ env.gitVersion_SemVer }}.tgz oci://ghcr.io/${{ github.repository_owner }}/helm-charts
244+ - name : helm - push
245+ if : ${{ env.build_push == 'true' }}
246+ run : helm push .artifacts/helm/${{ env.helm_chart }}-${{ env.gitVersion_SemVer }}.tgz ${{ env.helm_chart_repository_protocol }}${{ env.helm_chart_repository }}
208247
209- - name : docker - tag and push - latest
210- if : ${{ needs.discovery.outputs.requiresRelease == 'true' }}
211- run : |
212- docker buildx imagetools create \
213- --tag ${{ env.dockerHubContainerImageRepository }}/${{ env.containerImage }}:latest \
214- --tag ${{ env.ghcrContainerImageRepository }}/${{ env.containerImage }}:latest \
215- ${{ env.ghcrContainerImageRepository }}/${{ env.containerImage }}:${{ env.gitVersion_SemVer }}
248+ - name : artifacts - helm - upload
249+ uses : actions/upload-artifact@v4
250+ with :
251+ name : artifacts-helm-${{env.gitVersion_SemVer}}
252+ path : .artifacts/helm
253+
254+ - name : artifacts - kubectl - upload
255+ uses : actions/upload-artifact@v4
256+ with :
257+ name : artifacts-kubectl-${{env.gitVersion_SemVer}}
258+ path : .artifacts/kubectl
259+
260+ release :
261+ name : release
262+ if : ${{ needs.discovery.outputs.release == 'true' }}
263+ needs : [discovery, build]
264+ runs-on : ubuntu-latest
265+ env :
266+ gitVersion_SemVer : ${{ needs.discovery.outputs.gitVersion_SemVer }}
267+ gitVersion_AssemblySemFileVer : ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }}
268+ steps :
269+
270+ - name : artifacts - helm - download
271+ uses : actions/download-artifact@v4
272+ with :
273+ name : artifacts-helm-${{env.gitVersion_SemVer}}
274+ path : .artifacts/helm
275+
276+ - name : artifacts - kubectl - download
277+ uses : actions/download-artifact@v4
278+ with :
279+ name : artifacts-kubectl-${{env.gitVersion_SemVer}}
280+ path : .artifacts/kubectl
281+
282+ - name : tools - oras - install
283+ uses : oras-project/setup-oras@v1
284+
285+ - name : tools - oras - login - ghcr.io
286+ run : echo "${{ secrets.ES_GITHUB_PAT }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
216287
217- - name : oras - push - artifact hub metadata
218- if : ${{ needs.discovery.outputs.requiresRelease == 'true' }}
288+
289+ - name : oras - push - helm - artifact hub metadata
290+ if : ${{ env.helm_chart_repository_protocol == 'oci://' }}
219291 run : |
220- oras push ghcr.io/ ${{ github.repository_owner }}/helm-charts/ ${{ env.helmChart }}:artifacthub.io \
292+ oras push ${{ env.helm_chart_repository }}/${{ env.helm_chart }}:artifacthub.io \
221293 --config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
222- .artifacts/artifacthub/artifacthub-repo.yaml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
294+ .artifacts/helm/artifacthub-repo.yaml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
295+
296+ - name : docker - tag and push - latest
297+ run : |
298+ docker buildx imagetools create \
299+ --tag ${{ env.container_image_repository_dockerhub }}/${{ env.container_image }}:latest \
300+ --tag ${{ env.container_image_repository_ghcr }}/${{ env.container_image }}:latest \
301+ --tag ${{ env.container_image_repository_dockerhub }}/${{ env.container_image }}:${{ env.gitVersion_SemVer }} \
302+ --tag ${{ env.container_image_repository_ghcr }}/${{ env.container_image }}:${{ env.gitVersion_SemVer }} \
303+ ${{ env.container_image_repository_ghcr }}/${{ env.container_image }}:${{ env.gitVersion_SemVer }}
223304
224305 - name : github - release - create
225- if : ${{ needs.discovery.outputs.requiresRelease == 'true' }}
226306 uses : softprops/action-gh-release@v2
227307 with :
228308 repository : ${{ github.repository }}
@@ -232,4 +312,4 @@ jobs:
232312 generate_release_notes : true
233313 token : ${{ secrets.ES_GITHUB_PAT }}
234314 files : |
235- .artifacts/kubectl/${{ env.helmChart }}.yaml
315+ .artifacts/kubectl/${{ env.helmChart }}.yaml
0 commit comments