@@ -3,27 +3,26 @@ name: Pipeline
33on :
44 push :
55 branches :
6- - ' ** ' # Matches all branches
6+ - " ** " # Matches all branches
77 pull_request :
88 branches :
9- - ' ** ' # Matches all branches
9+ - " ** " # Matches all branches
1010
1111 workflow_dispatch :
1212 inputs :
1313 force_build :
14- description : ' Forces a build even if no changes are detected'
14+ description : " Forces a build even if no changes are detected"
1515 required : true
16- default : ' false'
16+ default : " false"
1717 force_publish :
18- description : ' Forces a publish even if no changes are detected'
18+ description : " Forces a publish even if no changes are detected"
1919 required : true
20- default : ' false'
20+ default : " false"
2121
2222concurrency :
2323 group : pipeline-${{ github.ref_name }}
2424 cancel-in-progress : true
2525
26-
2726env :
2827 containerImage : " kubernetes-reflector"
2928 containerImageBuildContext : " src/"
3332 helmChart : " reflector"
3433 helmChartDir : " src/helm/reflector"
3534
36-
3735jobs :
3836 discovery :
3937 runs-on : ubuntu-latest
4644 gitVersion_AssemblySemFileVer : ${{ steps.gitversion.outputs.GitVersion_AssemblySemFileVer }}
4745 requiresBuild : ${{ steps.requires_build.outputs.result }}
4846 requiresBuildPush : ${{ steps.requires_build_push.outputs.result }}
49-
47+ requires_release : ${{ steps.requires_release.outputs.result }}
5048 steps :
5149 - name : checkout
5250 uses : actions/checkout@v4
@@ -56,12 +54,12 @@ jobs:
5654 - name : tools - dotnet - install
5755 uses : actions/setup-dotnet@v4
5856 with :
59- dotnet-version : ' 9.x'
57+ dotnet-version : " 9.x"
6058
6159 - name : tools - gitversion - install
6260 uses :
gittools/actions/gitversion/[email protected] 6361 with :
64- versionSpec : ' 5.x'
62+ versionSpec : " 5.x"
6563 preferLatestVersion : true
6664
6765 - name : gitversion - execute
@@ -102,6 +100,17 @@ jobs:
102100 fi
103101 echo "result=$result" >> $GITHUB_OUTPUT
104102
103+ - name : evaluate - requires_release
104+ id : requires_release
105+ run : |
106+ if [ "${{ github.ref }}" = "refs/heads/main" ]; then
107+ result=true
108+ else
109+ result=false
110+ fi
111+ echo "result=$result" >> $GITHUB_OUTPUT
112+
113+
105114
106115 build :
107116 name : build
@@ -118,18 +127,19 @@ jobs:
118127 - name : tools - kubectl - install
119128 uses : azure/setup-kubectl@v4
120129
121- - name : tools - helm - install
122- uses : azure /setup-helm@v4
130+ - name : tools - oras - install
131+ uses : oras-project /setup-oras@v1
123132
124- - name : tools - helm - login - ghcr
133+ - name : tools - oras - login - ghcr.io
125134 if : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
126- run : |
127- echo "${{ secrets.ES_GITHUB_PAT }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
135+ run : echo "${{ secrets.ES_GITHUB_PAT }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
136+
137+ - name : tools - helm - install
138+ uses : azure/setup-helm@v4
128139
129- - name : tools - helm - login - docker .io
140+ - name : tools - helm - login - ghcr .io
130141 if : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
131- run : |
132- echo "${{ secrets.ES_DOCKERHUB_PAT }}" | helm registry login registry-1.docker.io -u ${{ secrets.ES_DOCKERHUB_USERNAME }} --password-stdin
142+ run : echo "${{ secrets.ES_GITHUB_PAT }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
133143
134144 - name : tools - docker - login ghcr.io
135145 if : ${{ needs.discovery.outputs.requiresBuildPush == 'true' }}
@@ -154,8 +164,7 @@ jobs:
154164 - name : tools - docker - setup buildx
155165 uses : docker/setup-buildx-action@v3
156166 with :
157- driver : docker-container # REQUIRED for multi-platform builds
158-
167+ driver : docker-container # REQUIRED for multi-platform builds
159168
160169 - name : artifacts - prepare directories
161170 run : |
@@ -169,7 +178,7 @@ jobs:
169178 run : helm package --destination .artifacts/helm --version ${{ env.gitVersion_SemVer }} --app-version ${{ env.gitVersion_SemVer }} ${{ env.helmChartDir }}
170179
171180 - name : helm - template chart
172- run : helm template --namespace kube-system ${{ env.helmChart }} .artifacts/helm/${{ env.helmChart }}-${{ env.gitVersion_SemVer }}.tgz > .artifacts/kubectl/${{ env.helmChart }}-${{ env.gitVersion_SemVer }} .yaml
181+ run : helm template --namespace kube-system ${{ env.helmChart }} .artifacts/helm/${{ env.helmChart }}-${{ env.gitVersion_SemVer }}.tgz > .artifacts/kubectl/${{ env.helmChart }}.yaml
173182
174183 - name : docker - build and push
175184 uses : docker/build-push-action@v5
@@ -192,22 +201,26 @@ jobs:
192201 - name : helm - push - ghcr.io
193202 run : helm push .artifacts/helm/${{ env.helmChart }}-${{ env.gitVersion_SemVer }}.tgz oci://ghcr.io/${{ github.repository_owner }}/helm-charts
194203
195- - name : " artifacts - upload - helm chart"
196- uses : actions/upload-artifact@v4
197- with :
198- name : helm
199- path : .artifacts/helm
204+ - name : docker - tag and push - latest
205+ run : |
206+ docker buildx imagetools create \
207+ --tag ${{ env.dockerHubContainerImageRepository }}/${{ env.containerImage }}:latest \
208+ --tag ${{ env.ghcrContainerImageRepository }}/${{ env.containerImage }}:latest \
209+ ${{ env.ghcrContainerImageRepository }}/${{ env.containerImage }}:${{ env.gitVersion_SemVer }}
200210
201- - name : " artifacts - upload - artifacthub "
202- uses : actions/upload-artifact@v4
203- with :
204- name : artifacthub
205- path : src/helm /artifacthub-repo.yaml
211+ - name : oras - push - artifact hub metadata
212+ run : |
213+ oras push ghcr.io/${{ github.repository_owner }}/helm-charts/${{ env.helmChart }}:artifacthub.io \
214+ --config /dev/null:application/vnd.cncf. artifacthub.config.v1+yaml \
215+ .artifacts/artifacthub /artifacthub-repo.yaml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1 .yaml
206216
207- - name : " artifacts - upload - kubectl manifests "
208- uses : actions/upload-artifact@v4
217+ - name : github - release - create
218+ uses : softprops/action-gh-release@v2
209219 with :
210- name : kubectl
211- path : .artifacts/kubectl
212-
213-
220+ repository : ${{ github.repository }}
221+ tag_name : v${{ env.gitVersion_SemVer }}
222+ body : The release process is automated.
223+ generate_release_notes : true
224+ token : ${{ secrets.ES_GITHUB_PAT }}
225+ files : |
226+ .artifacts/kubectl/${{ env.helmChart }}.yaml
0 commit comments