From fc619a6a8de7be48ade626835b00e38e509fa5cc Mon Sep 17 00:00:00 2001 From: Parth Yadav Date: Tue, 3 Sep 2024 20:01:55 +0530 Subject: [PATCH] Update github actions for releasing manifests and images Images are pushed to ghcr.io as part of release. Signed-off-by: Parth Yadav --- .../workflows/build-bundle-on-release.yaml | 50 --------------- .../workflows/release-byoh-controller.yaml | 48 ++++++++++++++ .../workflows/release-k8s-byoh-bundle.yaml | 64 +++++++++++++++++++ .../{draft-release.yaml => release.yaml} | 4 +- .../cluster-template-topology-docker.yaml | 2 +- .../templates/docker/cluster-template.yaml | 6 +- .../templates/docker/cluster-with-kcp.yaml | 4 +- .../clusterclass-quickstart-docker.yaml | 6 +- .../v1beta1/templates/docker/md.yaml | 2 +- .../e2e/cluster-template-topology.yaml | 2 +- .../templates/e2e/cluster-template.yaml | 6 +- .../templates/e2e/cluster-with-kcp.yaml | 4 +- .../e2e/clusterclass-quickstart.yaml | 6 +- .../v1beta1/templates/e2e/md.yaml | 2 +- .../vm/cluster-template-topology.yaml | 2 +- .../templates/vm/cluster-template.yaml | 6 +- .../templates/vm/cluster-with-kcp.yaml | 4 +- .../templates/vm/clusterclass-quickstart.yaml | 6 +- .../v1beta1/templates/vm/md.yaml | 2 +- 19 files changed, 144 insertions(+), 82 deletions(-) delete mode 100644 .github/workflows/build-bundle-on-release.yaml create mode 100644 .github/workflows/release-byoh-controller.yaml create mode 100644 .github/workflows/release-k8s-byoh-bundle.yaml rename .github/workflows/{draft-release.yaml => release.yaml} (89%) diff --git a/.github/workflows/build-bundle-on-release.yaml b/.github/workflows/build-bundle-on-release.yaml deleted file mode 100644 index 3a32eb81..00000000 --- a/.github/workflows/build-bundle-on-release.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build and Publish BYOH Bundle - -on: - release: - types: [published] - push: - tags: - - '*' - -jobs: - build-and-publish-k8s-bundles: - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Login to Docker Hub - env: - DOCKER_USER: ${{secrets.DOCKERHUB_USER}} - DOCKER_PWD: ${{secrets.DOCKERHUB_PUSH_TOKEN}} - run: sudo docker login -u $DOCKER_USER -p $DOCKER_PWD - - - name: pre-cleanup the docker - run: sudo docker system prune -a -f && sudo docker buildx prune - - - name: Build BYOH Ingredients Docker image - run: | - cd installer/bundle_builder/ingredients/deb/ - docker build -t byoh-ingredients-deb . - - - name: Create BYOH Ingredients directory and download files - run: | - mkdir -p byoh-ingredients-download - docker run --rm -v ${{ github.workspace }}/byoh-ingredients-download:/ingredients byoh-ingredients-deb - - - name: Build BYOH Bundle Docker image - run: | - cd installer/bundle_builder/ - docker build -t byoh-build-push-bundle . - - - name: Build and Publish BYOH Bundle - env: - BUILD_ONLY: 0 - REPO: coredgeio - BUNDLE_NAME: ${{ github.ref_name }} - run: | - docker run --rm -v ${{ github.workspace }}/byoh-ingredients-download:/ingredients --env BUILD_ONLY=${{ env.BUILD_ONLY }} byoh-build-push-bundle ${REPO}/${BUNDLE_NAME} - - - name: Cleanup Docker - run: sudo docker logout && sudo docker system prune -a -f && sudo docker buildx prune diff --git a/.github/workflows/release-byoh-controller.yaml b/.github/workflows/release-byoh-controller.yaml new file mode 100644 index 00000000..7ad1e3cd --- /dev/null +++ b/.github/workflows/release-byoh-controller.yaml @@ -0,0 +1,48 @@ +name: Release BYOH controller + +# on: +# push: +# # Build and publish artifacts when new tag is created for release +# tags: +# - "v*.*.*" + +on: + push: + branches: [ main ] + +jobs: + build-and-publish-byoh-controller: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry (ghcr.io) + env: + DOCKER_USER: ${{ github.repository_owner }} + DOCKER_PWD: ${{ secrets.GITHUB_TOKEN }} + run: docker login -u $DOCKER_USER -p $DOCKER_PWD ghcr.io + + # - name: pre-cleanup the docker + # run: sudo docker system prune -a -f && sudo docker buildx prune + + # - name: build and push controller image + # env: + # REPO: ${{ github.repository_owner }} + # TAG: ${{ github.ref_name }} + # run: | + # IMG=ghcr.io/$REPO/cluster-api-byoh-controller:$TAG make docker-build + # docker push ghcr.io/$REPO/cluster-api-byoh-controller:$TAG + + - name: Make the image public via GitHub API + env: + REPO: ${{ github.repository_owner }} + TAG: ${{ github.ref_name }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -X GET \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/cluster-api-byoh-controller?tag=v0.5.1 \ + -d '{"visibility":"public"}' + diff --git a/.github/workflows/release-k8s-byoh-bundle.yaml b/.github/workflows/release-k8s-byoh-bundle.yaml new file mode 100644 index 00000000..ce68f423 --- /dev/null +++ b/.github/workflows/release-k8s-byoh-bundle.yaml @@ -0,0 +1,64 @@ +name: Release k8s BYOH Bundles + +on: + push: + # Build and publish artifacts when new tag is created for release + tags: + - "v*.*.*" + +jobs: + build-and-publish-k8s-bundles: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry (ghcr.io) + env: + DOCKER_USER: ${{ github.repository_owner }} + DOCKER_PWD: ${{ secrets.GITHUB_TOKEN }} + run: docker login -u $DOCKER_USER -p $DOCKER_PWD ghcr.io + + - name: pre-cleanup the docker + run: sudo docker system prune -a -f && sudo docker buildx prune + + - name: Build BYOH Ingredients Docker image + run: | + cd installer/bundle_builder/ingredients/deb/ + docker build -t byoh-ingredients-deb . + + - name: Create BYOH Ingredients directory and download files + run: | + mkdir -p byoh-ingredients-download + docker run --rm -v ${{ github.workspace }}/byoh-ingredients-download:/ingredients byoh-ingredients-deb + + - name: Build BYOH Bundle Docker image + run: | + cd installer/bundle_builder/ + docker build -t byoh-build-push-bundle . + + - name: Build and Publish BYOH Bundle + env: + BUILD_ONLY: 0 + REPO: ${{ github.repository_owner }} + BUNDLE_NAME: byoh-bundle-ubuntu_20.04.1_x86-64_k8s + TAG: v1.31.0 + run: | + docker run --rm -v ~/.docker/config.json:/root/.docker/config.json -v ${{ github.workspace }}/byoh-ingredients-download:/ingredients --env BUILD_ONLY=${{ env.BUILD_ONLY }} byoh-build-push-bundle ghcr.io/$REPO/$BUNDLE_NAME:$TAG + + - name: Cleanup Docker + run: sudo docker logout && sudo docker system prune -a -f && sudo docker buildx prune + + - name: Make the image public via GitHub API + env: + REPO: ${{ github.repository_owner }} + BUNDLE_NAME: byoh-bundle-ubuntu_20.04.1_x86-64_k8s + TAG: v1.31.0 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + IMAGE_URL="ghcr.io/$REPO/$BUNDLE_NAME" + curl -X PATCH \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/$BUNDLE_NAME/versions/latest \ + -d '{"visibility":"public"}' \ No newline at end of file diff --git a/.github/workflows/draft-release.yaml b/.github/workflows/release.yaml similarity index 89% rename from .github/workflows/draft-release.yaml rename to .github/workflows/release.yaml index 0f228608..9e306e29 100644 --- a/.github/workflows/draft-release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: Draft Release +name: Release on: push: @@ -20,7 +20,7 @@ jobs: go-version: 1.20.7 - name: Build Release Artifacts - run: IMG="coredgeio/cluster-api-byoh-controller:${{ github.ref_name }}" make build-release-artifacts + run: IMG="ghcr.io/coredgeio/cluster-api-byoh-controller:${{ github.ref_name }}" make build-release-artifacts - name: Publish Release uses: softprops/action-gh-release@v1 diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template-topology-docker.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template-topology-docker.yaml index e14e1959..f9ffc436 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template-topology-docker.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template-topology-docker.yaml @@ -20,7 +20,7 @@ spec: replicas: ${CONTROL_PLANE_MACHINE_COUNT} variables: - name: bundleLookupBaseRegistry - value: "coredgeio" + value: "ghcr.io/coredgeio" - name: controlPlaneIpAddr value: ${CONTROL_PLANE_ENDPOINT_IP} - name: kubeVipPodManifest diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template.yaml index af518bb4..391ddc74 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-template.yaml @@ -165,7 +165,7 @@ kind: ByoCluster metadata: name: ${CLUSTER_NAME} spec: - bundleLookupBaseRegistry: coredge + bundleLookupBaseRegistry: ghcr.io/coredgeio controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 @@ -203,7 +203,7 @@ metadata: spec: template: spec: - bundleRepo: coredge + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -213,5 +213,5 @@ metadata: spec: template: spec: - bundleRepo: coredge + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-with-kcp.yaml index 8704bb75..761a0ebc 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/cluster-with-kcp.yaml @@ -24,7 +24,7 @@ kind: ByoCluster metadata: name: ${CLUSTER_NAME} spec: - bundleLookupBaseRegistry: coredgeio + bundleLookupBaseRegistry: ghcr.io/coredgeio controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 @@ -145,5 +145,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/clusterclass-quickstart-docker.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/clusterclass-quickstart-docker.yaml index 1fc609e9..13fe4abb 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/clusterclass-quickstart-docker.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/clusterclass-quickstart-docker.yaml @@ -39,7 +39,7 @@ spec: schema: openAPIV3Schema: type: string - default: "coredgeio" + default: "ghcr.io/coredgeio" - name: controlPlaneIpAddr required: true schema: @@ -157,7 +157,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -189,7 +189,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/md.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/md.yaml index bb5dbd47..b117600a 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/md.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/docker/md.yaml @@ -59,5 +59,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template-topology.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template-topology.yaml index edb89aa0..c8c5bace 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template-topology.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template-topology.yaml @@ -24,7 +24,7 @@ spec: replicas: ${CONTROL_PLANE_MACHINE_COUNT} variables: - name: bundleLookupBaseRegistry - value: "coredgeio" + value: "ghcr.io/coredgeio" - name: controlPlaneIpAddr value: ${CONTROL_PLANE_ENDPOINT_IP} - name: kubeVipPodManifest diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template.yaml index 154e3fd2..ade5cf1d 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-template.yaml @@ -188,7 +188,7 @@ kind: ByoCluster metadata: name: ${CLUSTER_NAME} spec: - bundleLookupBaseRegistry: coredgeio + bundleLookupBaseRegistry: ghcr.io/coredgeio controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 @@ -226,7 +226,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -236,5 +236,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-with-kcp.yaml index 274ab07c..3c020cb3 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/cluster-with-kcp.yaml @@ -27,7 +27,7 @@ kind: ByoCluster metadata: name: ${CLUSTER_NAME} spec: - bundleLookupBaseRegistry: coredgeio + bundleLookupBaseRegistry: ghcr.io/coredgeio controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 @@ -148,5 +148,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/clusterclass-quickstart.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/clusterclass-quickstart.yaml index e26f3212..95a078d1 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/clusterclass-quickstart.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/clusterclass-quickstart.yaml @@ -39,7 +39,7 @@ spec: schema: openAPIV3Schema: type: string - default: "coredgeio" + default: "ghcr.io/coredgeio" - name: controlPlaneIpAddr required: true schema: @@ -155,7 +155,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -199,7 +199,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: v1 diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/md.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/md.yaml index bb5dbd47..b117600a 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/md.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/e2e/md.yaml @@ -59,5 +59,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template-topology.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template-topology.yaml index b61703be..e2379fb3 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template-topology.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template-topology.yaml @@ -24,7 +24,7 @@ spec: replicas: ${CONTROL_PLANE_MACHINE_COUNT} variables: - name: bundleLookupBaseRegistry - value: "coredgeio" + value: "ghcr.io/coredgeio" - name: controlPlaneIpAddr value: ${CONTROL_PLANE_ENDPOINT_IP} - name: kubeVipPodManifest diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template.yaml index 628c65a2..77263a81 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-template.yaml @@ -157,7 +157,7 @@ kind: ByoCluster metadata: name: ${CLUSTER_NAME} spec: - bundleLookupBaseRegistry: coredgeio + bundleLookupBaseRegistry: ghcr.io/coredgeio controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 @@ -195,7 +195,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -205,5 +205,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-with-kcp.yaml index a726c783..08881668 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/cluster-with-kcp.yaml @@ -27,7 +27,7 @@ kind: ByoCluster metadata: name: ${CLUSTER_NAME} spec: - bundleLookupBaseRegistry: coredgeio + bundleLookupBaseRegistry: ghcr.io/coredgeio controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 @@ -142,5 +142,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/clusterclass-quickstart.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/clusterclass-quickstart.yaml index 845a072c..3e94253f 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/clusterclass-quickstart.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/clusterclass-quickstart.yaml @@ -39,7 +39,7 @@ spec: schema: openAPIV3Schema: type: string - default: "coredgeio" + default: "ghcr.io/coredgeio" - name: controlPlaneIpAddr required: true schema: @@ -134,7 +134,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -144,7 +144,7 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s --- kind: KubeadmControlPlaneTemplate diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/md.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/md.yaml index 068ebe5f..a8b0da72 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/md.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/templates/vm/md.yaml @@ -54,5 +54,5 @@ metadata: spec: template: spec: - bundleRepo: coredgeio + bundleRepo: ghcr.io/coredgeio bundleType: k8s