|
| 1 | +name: Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' # Matches all branches |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '**' # Matches all branches |
| 10 | + |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + force_build: |
| 14 | + description: 'Forces a build even if no changes are detected' |
| 15 | + required: true |
| 16 | + default: 'false' |
| 17 | + force_publish: |
| 18 | + description: 'Forces a publish even if no changes are detected' |
| 19 | + required: true |
| 20 | + default: 'false' |
| 21 | + |
| 22 | +jobs: |
| 23 | + ci: |
| 24 | + name: CI |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + pull-requests: read |
| 28 | + id-token: write |
| 29 | + contents: read |
| 30 | + checks: write |
| 31 | + env: |
| 32 | + build: false |
| 33 | + outputs: |
| 34 | + paths_filter_src: ${{ steps.tools-paths-filter.outputs.src }} |
| 35 | + gitVersion_SemVer: ${{ steps.tools-gitversion-execute.outputs.GitVersion_SemVer }} |
| 36 | + gitVersion_AssemblySemFileVer: ${{ steps.tools-gitversion-execute.outputs.GitVersion_AssemblySemFileVer }} |
| 37 | + requires_build: ${{ env.build }} |
| 38 | + steps: |
| 39 | + |
| 40 | + - name: checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + fetch-depth: 0 |
| 44 | + |
| 45 | + - name: tools - dotnet - install |
| 46 | + uses: actions/setup-dotnet@v4 |
| 47 | + with: |
| 48 | + dotnet-version: '9.x' |
| 49 | + |
| 50 | + - name: tools - gitversion - install |
| 51 | + uses: gittools/actions/gitversion/setup@v3.2.1 |
| 52 | + with: |
| 53 | + versionSpec: '5.x' |
| 54 | + preferLatestVersion: true |
| 55 | + |
| 56 | + - name: tools - gitversion - execute |
| 57 | + id: tools-gitversion-execute |
| 58 | + uses: gittools/actions/gitversion/execute@v3.2.1 |
| 59 | + with: |
| 60 | + useConfigFile: true |
| 61 | + configFilePath: GitVersion.yaml |
| 62 | + |
| 63 | + - name: tools - paths filter |
| 64 | + id: tools-paths-filter |
| 65 | + uses: dorny/paths-filter@v3 |
| 66 | + with: |
| 67 | + base: ${{ github.ref }} |
| 68 | + filters: | |
| 69 | + src: |
| 70 | + - 'src/**' |
| 71 | +
|
| 72 | +
|
| 73 | + - name: evaluate - requires_build |
| 74 | + id: evaluate_requires_build |
| 75 | + run: | |
| 76 | + if [ "${{ steps.change_detection.outputs.src }}" = "true" ] || \ |
| 77 | + [ "${{ github.event.inputs.force_build }}" = "true" ] || \ |
| 78 | + [ "${{ github.event.inputs.force_publish }}" = "true" ] || \ |
| 79 | + [ "${{ github.event_name }}" = "pull_request" ]; then |
| 80 | + result=true |
| 81 | + else |
| 82 | + result=false |
| 83 | + fi |
| 84 | + echo "requires_build=$result" >> $GITHUB_OUTPUT |
| 85 | +
|
| 86 | +
|
| 87 | +
|
| 88 | + - name: evaluate - requires_build |
| 89 | + if: steps.change_detection.outputs.src == 'true' || |
| 90 | + github.event.inputs.force_build == 'true' || |
| 91 | + github.event.inputs.force_publish == 'true' || |
| 92 | + github.event_name == 'pull_request' |
| 93 | + run: echo "requires_build=true" >> $GITHUB_OUTPUT |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + cd: |
| 98 | + name: CD |
| 99 | + runs-on: ubuntu-latest |
| 100 | + needs: ci |
| 101 | + if: > |
| 102 | + (github.event.inputs.force_publish == 'true' || |
| 103 | + (needs.ci.outputs.change_detection_src == 'true' && github.event_name == 'push')) && |
| 104 | + (github.ref == 'refs/heads/main' || |
| 105 | + github.ref == 'refs/heads/develop' || |
| 106 | + startsWith(github.ref, 'refs/heads/feature/') || |
| 107 | + startsWith(github.ref, 'refs/heads/releases/') || |
| 108 | + startsWith(github.ref, 'refs/heads/hotfix/')) |
| 109 | + env: |
| 110 | + build: ${{ needs.ci.outputs.build }} |
| 111 | + semVer: ${{ needs.ci.outputs.semVer }} |
| 112 | + changes_src: ${{ needs.ci.outputs.change_detection_src }} |
| 113 | + steps: |
| 114 | + - name: artifacts - nuget - download |
| 115 | + uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + name: artifacts-nuget-${{env.semVer}} |
| 118 | + path: .artifacts/nuget |
| 119 | + |
| 120 | + - name: dotnet nuget push - GitHub |
| 121 | + run: | |
| 122 | + dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/emberstack/index.json" |
| 123 | + for pkg in .artifacts/nuget/*.nupkg; do |
| 124 | + dotnet nuget push "$pkg" --source "github" --api-key ${{ secrets.ES_GITHUB_PAT }} --skip-duplicate |
| 125 | + done |
| 126 | +
|
| 127 | + - name: dotnet nuget push - NuGet |
| 128 | + if: github.ref == 'refs/heads/main' |
| 129 | + run: | |
| 130 | + for pkg in .artifacts/nuget/*.nupkg; do |
| 131 | + dotnet nuget push "$pkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.ES_NUGET_APIKEY }} --skip-duplicate |
| 132 | + done |
| 133 | +
|
| 134 | + - name: checkout |
| 135 | + uses: actions/checkout@v4 |
| 136 | + with: |
| 137 | + fetch-depth: 0 |
| 138 | + |
| 139 | + - name: github - create release |
| 140 | + if: github.ref == 'refs/heads/main' |
| 141 | + env: |
| 142 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 143 | + run: | |
| 144 | + gh release create version/v${{env.semVer}} --title "v${{env.semVer}}" --generate-notes |
| 145 | +
|
| 146 | +
|
| 147 | +
|
| 148 | +
|
| 149 | +
|
| 150 | +
|
| 151 | +
|
| 152 | +
|
| 153 | +
|
| 154 | +
|
| 155 | +
|
| 156 | +
|
| 157 | +
|
| 158 | +
|
| 159 | +
|
| 160 | +
|
| 161 | +
|
| 162 | +
|
| 163 | +
|
| 164 | +
|
| 165 | +
|
| 166 | +
|
| 167 | +# name: Main Workflow |
| 168 | + |
| 169 | +# on: |
| 170 | +# push: |
| 171 | +# paths: |
| 172 | +# - "src/**" |
| 173 | +# - ".github/workflows/main.yaml" |
| 174 | +# pull_request: |
| 175 | +# paths: |
| 176 | +# - "src/**" |
| 177 | +# - ".github/workflows/main.yaml" |
| 178 | + |
| 179 | +# env: |
| 180 | +# version: 9.1.${{github.run_number}} |
| 181 | +# imageRepository: "emberstack/kubernetes-reflector" |
| 182 | +# DOCKER_CLI_EXPERIMENTAL: "enabled" |
| 183 | + |
| 184 | +# jobs: |
| 185 | +# ci: |
| 186 | +# name: CI |
| 187 | +# runs-on: ubuntu-latest |
| 188 | +# steps: |
| 189 | +# - uses: actions/checkout@v4 |
| 190 | + |
| 191 | +# - name: artifacts - prepare directories |
| 192 | +# run: | |
| 193 | +# mkdir -p .artifacts/helm |
| 194 | +# mkdir -p .artifacts/kubectl |
| 195 | + |
| 196 | +# - name: helm - import README |
| 197 | +# run: cp README.md src/helm/reflector/README.md |
| 198 | + |
| 199 | +# - name: helm - package chart |
| 200 | +# run: helm package --destination .artifacts/helm --version ${{env.version}} --app-version ${{env.version}} src/helm/reflector |
| 201 | + |
| 202 | +# - name: helm - template chart |
| 203 | +# run: helm template --namespace kube-system reflector .artifacts/helm/reflector-${{env.version}}.tgz > .artifacts/kubectl/reflector-${{env.version}}.yaml |
| 204 | + |
| 205 | +# - name: "artifacts - upload - helm chart" |
| 206 | +# uses: actions/upload-artifact@v4 |
| 207 | +# with: |
| 208 | +# name: helm |
| 209 | +# path: .artifacts/helm |
| 210 | + |
| 211 | +# - name: "artifacts - upload - artifacthub" |
| 212 | +# uses: actions/upload-artifact@v4 |
| 213 | +# with: |
| 214 | +# name: artifacthub |
| 215 | +# path: src/helm/artifacthub-repo.yaml |
| 216 | + |
| 217 | +# - name: "artifacts - upload - kubectl manifests" |
| 218 | +# uses: actions/upload-artifact@v4 |
| 219 | +# with: |
| 220 | +# name: kubectl |
| 221 | +# path: .artifacts/kubectl |
| 222 | + |
| 223 | +# - name: tools - docker - login |
| 224 | +# if: github.event_name == 'push' && github.actor != 'dependabot[bot]' |
| 225 | +# uses: docker/login-action@v3 |
| 226 | +# with: |
| 227 | +# username: ${{ secrets.ES_DOCKERHUB_USERNAME }} |
| 228 | +# password: ${{ secrets.ES_DOCKERHUB_PAT }} |
| 229 | + |
| 230 | +# - name: docker - setup - register QEMU |
| 231 | +# run: | |
| 232 | +# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 233 | + |
| 234 | +# - name: docker - setup - buildx |
| 235 | +# uses: docker/setup-buildx-action@v3 |
| 236 | +# with: |
| 237 | +# driver: docker-container # REQUIRED for multi-platform builds |
| 238 | + |
| 239 | +# - name: docker - build and push |
| 240 | +# uses: docker/build-push-action@v5 |
| 241 | +# with: |
| 242 | +# context: src/ |
| 243 | +# file: src/ES.Kubernetes.Reflector/Dockerfile |
| 244 | +# push: ${{ github.event_name == 'push' && github.actor != 'dependabot[bot]' }} |
| 245 | +# provenance: false |
| 246 | +# platforms: linux/amd64,linux/arm/v7,linux/arm64 |
| 247 | +# tags: ${{ env.imageRepository }}:build-${{ env.version }} |
| 248 | + |
| 249 | +# # - name: "docker - build PR" |
| 250 | +# # if: github.event_name == 'pull_request' |
| 251 | +# # run: | |
| 252 | +# # docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 253 | +# # docker buildx create --name builder --driver docker-container --use |
| 254 | +# # docker buildx inspect --bootstrap |
| 255 | +# # docker buildx build --platform linux/amd64 -t ${{env.imageRepository}}:build-${{env.version}}-amd64 -f src/ES.Kubernetes.Reflector/Dockerfile src/ |
| 256 | +# # docker buildx build --platform linux/arm -t ${{env.imageRepository}}:build-${{env.version}}-arm32v7 -f src/ES.Kubernetes.Reflector/Dockerfile src/ |
| 257 | +# # docker buildx build --platform linux/arm64 -t ${{env.imageRepository}}:build-${{env.version}}-arm64v8 -f src/ES.Kubernetes.Reflector/Dockerfile src/ |
| 258 | + |
| 259 | +# # - name: tools - docker - login |
| 260 | +# # if: github.event_name == 'push' && github.actor != 'dependabot[bot]' |
| 261 | +# # uses: docker/login-action@v3 |
| 262 | +# # with: |
| 263 | +# # username: ${{ secrets.ES_DOCKERHUB_USERNAME }} |
| 264 | +# # password: ${{ secrets.ES_DOCKERHUB_PAT }} |
| 265 | + |
| 266 | +# # - name: "docker - build and publish" |
| 267 | +# # if: github.event_name == 'push' && github.actor != 'dependabot[bot]' |
| 268 | +# # run: | |
| 269 | +# # docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 270 | +# # docker buildx create --name builder --driver docker-container --use |
| 271 | +# # docker buildx inspect --bootstrap |
| 272 | +# # docker buildx build --push --platform linux/amd64 --provenance=false -t ${{env.imageRepository}}:build-${{env.version}}-amd64 -f src/ES.Kubernetes.Reflector/Dockerfile src/ |
| 273 | +# # docker buildx build --push --platform linux/arm --provenance=false -t ${{env.imageRepository}}:build-${{env.version}}-arm32v7 -f src/ES.Kubernetes.Reflector/Dockerfile src/ |
| 274 | +# # docker buildx build --push --platform linux/arm64 --provenance=false -t ${{env.imageRepository}}:build-${{env.version}}-arm64v8 -f src/ES.Kubernetes.Reflector/Dockerfile src/ |
| 275 | +# # docker pull --platform linux/amd64 ${{env.imageRepository}}:build-${{env.version}}-amd64 |
| 276 | +# # docker pull --platform linux/arm/v7 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 |
| 277 | +# # docker pull --platform linux/arm64 ${{env.imageRepository}}:build-${{env.version}}-arm64v8 |
| 278 | +# # docker manifest create ${{env.imageRepository}}:build-${{env.version}} ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:build-${{env.version}}-arm64v8 |
| 279 | +# # docker manifest inspect ${{env.imageRepository}}:build-${{env.version}} |
| 280 | +# # docker manifest push ${{env.imageRepository}}:build-${{env.version}} |
| 281 | + |
| 282 | +# cd: |
| 283 | +# name: CD |
| 284 | +# needs: ci |
| 285 | +# if: github.event_name == 'push' && github.ref == 'refs/heads/workflows' |
| 286 | +# runs-on: ubuntu-latest |
| 287 | +# steps: |
| 288 | +# - name: tools - docker - login |
| 289 | +# uses: docker/login-action@v3 |
| 290 | +# with: |
| 291 | +# username: ${{ secrets.ES_DOCKERHUB_USERNAME }} |
| 292 | +# password: ${{ secrets.ES_DOCKERHUB_PAT }} |
| 293 | + |
| 294 | +# - name: tools - oras - setup |
| 295 | +# uses: oras-project/setup-oras@v1 |
| 296 | + |
| 297 | +# - name: artifacts - download - helm chart |
| 298 | +# uses: actions/download-artifact@v4 |
| 299 | +# with: |
| 300 | +# name: helm |
| 301 | +# path: .artifacts/helm |
| 302 | + |
| 303 | +# - name: artifacts - download - artifacthub |
| 304 | +# uses: actions/download-artifact@v4 |
| 305 | +# with: |
| 306 | +# name: artifacthub |
| 307 | +# path: .artifacts/artifacthub |
| 308 | + |
| 309 | +# - name: artifacts - download - kubectl manifests |
| 310 | +# uses: actions/download-artifact@v4 |
| 311 | +# with: |
| 312 | +# name: kubectl |
| 313 | +# path: .artifacts/kubectl |
| 314 | + |
| 315 | +# # - name: "docker - tag and push" |
| 316 | +# # run: | |
| 317 | +# # docker pull ${{env.imageRepository}}:build-${{env.version}}-amd64 |
| 318 | +# # docker pull ${{env.imageRepository}}:build-${{env.version}}-arm32v7 |
| 319 | +# # docker pull ${{env.imageRepository}}:build-${{env.version}}-arm64v8 |
| 320 | +# # docker manifest create ${{env.imageRepository}}:${{env.version}} ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:build-${{env.version}}-arm64v8 |
| 321 | +# # docker manifest create ${{env.imageRepository}}:latest ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:build-${{env.version}}-arm64v8 |
| 322 | +# # docker manifest push ${{env.imageRepository}}:${{env.version}} |
| 323 | +# # docker manifest push ${{env.imageRepository}}:latest |
| 324 | +# # docker manifest push ${{env.imageRepository}}:${{env.version}} |
| 325 | +# # docker manifest push ${{env.imageRepository}}:latest |
| 326 | +# # docker tag ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:${{env.version}}-amd64 |
| 327 | +# # docker tag ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:${{env.version}}-arm32v7 |
| 328 | +# # docker tag ${{env.imageRepository}}:build-${{env.version}}-arm64v8 ${{env.imageRepository}}:${{env.version}}-arm64v8 |
| 329 | +# # docker push ${{env.imageRepository}}:${{env.version}}-amd64 |
| 330 | +# # docker push ${{env.imageRepository}}:${{env.version}}-arm32v7 |
| 331 | +# # docker push ${{env.imageRepository}}:${{env.version}}-arm64v8 |
| 332 | + |
| 333 | + |
| 334 | +# - name: helm - login - ghcr |
| 335 | +# run: | |
| 336 | +# echo "${{ secrets.ES_GITHUB_PAT }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin |
| 337 | + |
| 338 | + |
| 339 | + |
| 340 | +# - name: oras - login - ghcr |
| 341 | +# run: echo "${{ secrets.ES_GITHUB_PAT }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin |
| 342 | + |
| 343 | + |
| 344 | +# - name: helm - push |
| 345 | +# run: helm push .artifacts/helm/reflector-${{env.version}}.tgz oci://ghcr.io/${{ github.repository_owner }}/helm-charts |
| 346 | + |
| 347 | + |
| 348 | +# - name: oras - push - artifact hub metadata |
| 349 | +# run: | |
| 350 | +# oras push ghcr.io/${{ github.repository_owner }}/helm-charts/reflector:artifacthub.io \ |
| 351 | +# --config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \ |
| 352 | +# .artifacts/artifacthub/artifacthub-repo.yaml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml |
| 353 | + |
| 354 | +# # - name: github - release - set manifest name |
| 355 | +# # run: | |
| 356 | +# # mkdir -p github |
| 357 | +# # cp .artifacts/kubectl/reflector-${{env.version}}.yaml github/reflector.yaml |
| 358 | + |
| 359 | +# # - name: github - create release |
| 360 | +# # uses: softprops/action-gh-release@v2 |
| 361 | +# # with: |
| 362 | +# # repository: emberstack/kubernetes-reflector |
| 363 | +# # tag_name: v${{env.version}} |
| 364 | +# # body: The release process is automated. |
| 365 | +# # generate_release_notes: true |
| 366 | +# # token: ${{ secrets.ES_GITHUB_PAT }} |
| 367 | +# # files: | |
| 368 | +# # github/reflector.yaml |
0 commit comments