From bc740db04eaa117fe811c87c1a69c4b407dbb427 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 7 Sep 2023 17:03:52 +0900 Subject: [PATCH 01/33] fix e2e test to work in a 2-version environment Signed-off-by: hlts2 --- .../determine-docker-image-tag/action.yaml | 34 ++++++++++++++++--- .../e2e-deploy-vald-helm-operator/action.yaml | 10 ++++-- .github/actions/e2e-deploy-vald/action.yaml | 10 ++++-- .github/actions/setup-e2e/action.yaml | 4 +++ .github/workflows/e2e-chaos.yaml | 4 +++ .github/workflows/e2e-max-dim.yml | 3 +- .github/workflows/e2e-profiling.yml | 1 + .github/workflows/e2e.yml | 6 ++++ .github/workflows/helm.yml | 1 + 9 files changed, 63 insertions(+), 10 deletions(-) diff --git a/.github/actions/determine-docker-image-tag/action.yaml b/.github/actions/determine-docker-image-tag/action.yaml index bdbb5128d1..2869be2728 100644 --- a/.github/actions/determine-docker-image-tag/action.yaml +++ b/.github/actions/determine-docker-image-tag/action.yaml @@ -20,6 +20,9 @@ outputs: PRIMARY_TAG: description: "Primary tag" value: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }} + DEFAULT_TAG: + description: "default tag. Tag to be used if the primary tag does not exist" + value: ${{ steps.determine_tag_name.outputs.DEFAULT_TAG }} runs: using: "composite" @@ -28,6 +31,7 @@ runs: shell: bash run: | echo "GITHUB_REF $GITHUB_REF" + echo "GITHUB_BASE_REF $GITHUB_BASE_REF" echo "GITHUB_EVENT_PATH $GITHUB_EVENT_PATH" echo "GITHUB_EVENT_NAME ${{ github.event_name }}" echo "GITHUB_EVENT_NUMBER ${{ github.event.number }}" @@ -38,20 +42,40 @@ runs: run: | if [[ "$GITHUB_REF" =~ ^refs/tags/.* ]]; then tag_name=`echo $GITHUB_REF | sed -e 's:^refs/tags/::'` + echo "${tag_name}" > versions/VALD_VERSION + primary_tag="${tag_name}" - elif [ "${{ github.event_name }}" = "pull_request" ]; then - pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"` - echo "PR-${pr_num}" > versions/VALD_VERSION - primary_tag="pr-${pr_num}" - elif [ "${{ github.event_name }}" = "pull_request_target" ]; then + default_tag="${tag_name}" + elif [[ "${{ github.event_name }}" = "pull_request" || "${{ github.event_name }}" = "pull_request_target" ]]; then pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"` echo "PR-${pr_num}" > versions/VALD_VERSION + primary_tag="pr-${pr_num}" + default_tag="nightly" + + # For pull request to the release branch, use the release branch latest tag as the default tag (vx.x). + # This is only set if the event that triggers the workflow execution is pull_request or pull_request_target. + if [[ "$GITHUB_BASE_REF" =~ ^release/v([0-9]+)\.([0-9]+)$ ]]; then + tag_name=`echo $GITHUB_BASE_REF | sed -e 's:^release/::'` + default_tag="${tag_name}" + fi elif [ "$GITHUB_REF" = "refs/heads/main" ]; then echo "nightly" > versions/VALD_VERSION + primary_tag="nightly" + default_tag="nightly" + elif [[ "$GITHUB_REF" =~ ^refs/heads/release/v([0-9]+)\.([0-9]+)$ ]]; then + tag_name=`echo $GITHUB_REF | sed -e 's:^refs/heads/release/::'` + echo "${tag_name}" > versions/VALD_VERSION + + primary_tag="${tag_name}" + default_tag="${tag_name}" else primary_tag="unknown" + default_tag="unknown" fi + echo "PRIMARY_TAG is determined: ${primary_tag}" + echo "DEFAULT_TAG is determined: ${default_tag}" echo "PRIMARY_TAG=${primary_tag}" >> $GITHUB_OUTPUT + echo "DEFAULT_TAG=${default_tag}" >> $GITHUB_OUTPUT diff --git a/.github/actions/e2e-deploy-vald-helm-operator/action.yaml b/.github/actions/e2e-deploy-vald-helm-operator/action.yaml index 215a7c0f95..0ad9e1451a 100644 --- a/.github/actions/e2e-deploy-vald-helm-operator/action.yaml +++ b/.github/actions/e2e-deploy-vald-helm-operator/action.yaml @@ -41,6 +41,10 @@ inputs: description: "If you want to use local charts, set this to true." required: false default: "true" + default_image_tag: + description: "Default image tag. e.g) nightly, vx.x, vx.x.x, pr-xxx" + required: true + default: "nightly" outputs: POD_NAME: description: "A pod name that waited for" @@ -67,12 +71,13 @@ runs: if: ${{ inputs.use_local_charts == 'false' }} run: | helm install vald-helm-operator \ - --set image.tag=nightly \ + --set image.tag=${DEFAULT_IMAGE_TAG} \ ${HELM_EXTRA_OPTIONS} \ charts/vald-helm-operator/. sleep 3 env: + DEFAULT_IMAGE_TAG: ${{ inputs.default_image_tag }} HELM_EXTRA_OPTIONS: ${{ inputs.helm_extra_options }} - name: Deploy vald helm operator from local charts @@ -80,9 +85,10 @@ runs: id: deploy_vald_helm_operator_local if: ${{ inputs.use_local_charts == 'true' }} run: | - make k8s/vald-helm-operator/deploy VERSION=nightly HELM_EXTRA_OPTIONS="${HELM_EXTRA_OPTIONS}" + make k8s/vald-helm-operator/deploy VERSION=${DEFAULT_IMAGE_TAG} HELM_EXTRA_OPTIONS="${HELM_EXTRA_OPTIONS}" sleep 3 env: + DEFAULT_IMAGE_TAG: ${{ inputs.default_image_tag }} HELM_EXTRA_OPTIONS: ${{ inputs.helm_extra_options }} - name: Deploy vald diff --git a/.github/actions/e2e-deploy-vald/action.yaml b/.github/actions/e2e-deploy-vald/action.yaml index d90ae83dc6..e7c99684c3 100644 --- a/.github/actions/e2e-deploy-vald/action.yaml +++ b/.github/actions/e2e-deploy-vald/action.yaml @@ -41,6 +41,10 @@ inputs: description: "If you want to use local charts, set this to true." required: false default: "true" + default_image_tag: + description: "Default image tag. e.g) nightly, vx.x, vx.x.x" + required: true + default: "nightly" outputs: POD_NAME: description: "A pod name that waited for" @@ -68,7 +72,7 @@ runs: run: | helm install \ --values ${VALUES} \ - --set defaults.image.tag=nightly \ + --set defaults.image.tag=${DEFAULT_IMAGE_TAG} \ ${HELM_EXTRA_OPTIONS} \ --generate-name charts/vald @@ -81,6 +85,7 @@ runs: podname=`kubectl get pods --selector=${WAIT_FOR_SELECTOR} | tail -1 | awk '{print $1}'` echo "POD_NAME=${podname}" >> $GITHUB_OUTPUT env: + DEFAULT_IMAGE_TAG: ${{ inputs.default_image_tag }} VALUES: ${{ inputs.values }} HELM_EXTRA_OPTIONS: ${{ inputs.helm_extra_options }} WAIT_FOR_SELECTOR: ${{ inputs.wait_for_selector }} @@ -91,7 +96,7 @@ runs: id: deploy_vald_local if: ${{ inputs.use_local_charts == 'true' }} run: | - make k8s/vald/deploy VERSION=nightly HELM_VALUES=${VALUES} HELM_EXTRA_OPTIONS="${HELM_EXTRA_OPTIONS}" + make k8s/vald/deploy VERSION=${DEFAULT_IMAGE_TAG} HELM_VALUES=${VALUES} HELM_EXTRA_OPTIONS="${HELM_EXTRA_OPTIONS}" sleep 3 @@ -102,6 +107,7 @@ runs: podname=`kubectl get pods --selector=${WAIT_FOR_SELECTOR} | tail -1 | awk '{print $1}'` echo "POD_NAME=${podname}" >> $GITHUB_OUTPUT env: + DEFAULT_IMAGE_TAG: ${{ inputs.default_image_tag }} VALUES: ${{ inputs.values }} HELM_EXTRA_OPTIONS: ${{ inputs.helm_extra_options }} WAIT_FOR_SELECTOR: ${{ inputs.wait_for_selector }} diff --git a/.github/actions/setup-e2e/action.yaml b/.github/actions/setup-e2e/action.yaml index 0a4e51fb8f..ba8b8cc2c5 100644 --- a/.github/actions/setup-e2e/action.yaml +++ b/.github/actions/setup-e2e/action.yaml @@ -47,6 +47,10 @@ outputs: IMAGE_TAGS: description: "Specifies E2E target image tags" value: ${{ steps.specify_container_versions.outputs.IMAGE_TAGS }} + DEFAULT_IMAGE_TAG: + description: "Default E2E target image tag" + value: ${{ steps.determine_tag_name.outputs.DEFAULT_TAG }} + runs: using: "composite" steps: diff --git a/.github/workflows/e2e-chaos.yaml b/.github/workflows/e2e-chaos.yaml index 7fd2566e58..348e797331 100644 --- a/.github/workflows/e2e-chaos.yaml +++ b/.github/workflows/e2e-chaos.yaml @@ -60,6 +60,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: ${{ env.VALUES }} wait_for_selector: app=vald-lb-gateway @@ -104,6 +105,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: ${{ env.VALUES }} wait_for_selector: app=vald-lb-gateway @@ -148,6 +150,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: ${{ env.VALUES }} wait_for_selector: app=vald-lb-gateway @@ -192,6 +195,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: ${{ env.VALUES }} wait_for_selector: app=vald-lb-gateway diff --git a/.github/workflows/e2e-max-dim.yml b/.github/workflows/e2e-max-dim.yml index 8bf6433873..49f3bbfcd2 100644 --- a/.github/workflows/e2e-max-dim.yml +++ b/.github/workflows/e2e-max-dim.yml @@ -67,7 +67,7 @@ jobs: fi export HELM_EXTRA_OPTIOINS="--set agent.ngt.dimension=${DIM}" - make k8s/vald/deploy VERSION="nightly" HELM_VALUES=${VALUES} HELM_EXTRA_OPTIONS="${HELM_EXTRA_OPTIOINS}" + make k8s/vald/deploy VERSION=${DEFAULT_IMAGE_TAG} HELM_VALUES=${VALUES} HELM_EXTRA_OPTIONS="${HELM_EXTRA_OPTIOINS}" sleep 3 @@ -105,6 +105,7 @@ jobs: echo "MAX_BIT=${BIT}" >> $GITHUB_OUTPUT echo "MAX_BIT=${BIT}" env: + DEFAULT_IMAGE_TAG: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} WAIT_FOR_SELECTOR: app=vald-agent-ngt WAIT_FOR_TIMEOUT: 29m VALUES: .github/helm/values/values-max-dim.yaml diff --git a/.github/workflows/e2e-profiling.yml b/.github/workflows/e2e-profiling.yml index 60f37e53b8..8046d22db8 100644 --- a/.github/workflows/e2e-profiling.yml +++ b/.github/workflows/e2e-profiling.yml @@ -56,6 +56,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: .github/helm/values/values-profile.yaml wait_for_selector: app=vald-lb-gateway diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 20a9e60c8c..8c46dd5b09 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -55,6 +55,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: .github/helm/values/values-lb.yaml wait_for_selector: app=vald-lb-gateway @@ -106,6 +107,7 @@ jobs: - name: Merge Docker image tag run: | + yq e ".spec.defaults.image.tag=\"${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }}\"" -i ./.github/valdrelease/valdrelease.yaml IMAGE_TAGS=(${{ steps.setup_e2e.outputs.IMAGE_TAGS }}) for IMAGE_TAG in "${IMAGE_TAGS[@]}" @@ -122,6 +124,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald-helm-operator with: + default_image_tag: ${{ steps.vald_helm_operator.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.vald_helm_operator.outputs.HELM_EXTRA_OPTIONS }} valdrelease: ./.github/valdrelease/valdrelease.yaml wait_for_selector: app=vald-lb-gateway @@ -165,6 +168,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: .github/helm/values/values-lb.yaml wait_for_selector: app=vald-lb-gateway @@ -208,6 +212,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: .github/helm/values/values-lb.yaml wait_for_selector: app=vald-lb-gateway @@ -285,6 +290,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} require_minio: "true" helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: .github/helm/values/values-agent-sidecar.yaml diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 90d37756d5..7e272112ba 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -157,6 +157,7 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: + default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: .github/helm/values/values-lb.yaml wait_for_selector: app=vald-lb-gateway From ca2c6699d0ee77fdb2f8d33a8fb65d6538d3c061 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 7 Sep 2023 17:13:54 +0900 Subject: [PATCH 02/33] add workflow to create backport pr Signed-off-by: hlts2 --- .github/workflows/pr.yaml | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/pr.yaml diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000000..669f62eac8 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,56 @@ +name: "Run backport PR creation" +on: + pull_request: + types: + - "labeled" + +jobs: + dump-contexts-to-log: + runs-on: ubuntu-latest + if: ${{ github.event.action == 'labeled' && startsWith( github.event.label.name, 'actions/backport/' ) }} # e.g.) actions/backport/v1.7 + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/dump-context + + create: + runs-on: ubuntu-latest + needs: [dump-contexts-to-log] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set Git config + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + + - name: Set Github context + id: set_context + run: | + RELEASE_BASE=`echo "${HOOKED_LABEL_NAME}" | sed -e "s:^${TARGET_LABEL_NAME_PREFIX}::"` # e.g) vx.x + RELEASE_BRANCH_NAME=release/${RELEASE_BASE} # e.g) release/vx.x + BACKPORT_BRANCH_NAME=backport/${RELEASE_BASE}/${GITHUB_HEAD_REF} # e.g) backport/vx.x/{current branch name} + + echo "RELEASE_BASE=${RELEASE_BASE}" >> $GITHUB_OUTPUT + echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" >> $GITHUB_OUTPUT + echo "BACKPORT_BRANCH_NAME=${BACKPORT_BRANCH_NAME}" >> $GITHUB_OUTPUT + + echo "${RELEASE_BASE}" + echo "${RELEASE_BRANCH_NAME}" + echo "${BACKPORT_BRANCH_NAME}" + env: + TARGET_LABEL_NAME_PREFIX: 'actions/backport/' + HOOKED_LABEL_NAME: ${{ github.event.label.name }} + + - name: Create PR + run: | + git checkout -b ${BACKPORT_BRANCH_NAME} + git push origin ${BACKPORT_BRANCH_NAME} + gh pr create --base ${RELEASE_BRANCH_NAME} \ + --title "Backport to release/${RELEASE_BASE}" \ + --body "" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_BASE: ${{ steps.set_context.outputs.RELEASE_BASE }} + RELEASE_BRANCH_NAME: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} + BACKPORT_BRANCH_NAME: ${{ steps.set_context.outputs.BACKPORT_BRANCH_NAME }} From 9813973a5f87a8fbc92c8b4dd405a343b0860b7f Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 7 Sep 2023 17:29:34 +0900 Subject: [PATCH 03/33] add reusable workflow to detect ci container image tag Signed-off-by: hlts2 --- .github/workflows/_detect-ci-container.yml | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/_detect-ci-container.yml diff --git a/.github/workflows/_detect-ci-container.yml b/.github/workflows/_detect-ci-container.yml new file mode 100644 index 0000000000..5b4a8a034d --- /dev/null +++ b/.github/workflows/_detect-ci-container.yml @@ -0,0 +1,55 @@ +name: "Detect CI container image tag" +on: + workflow_call: + outputs: + TAG_NAME: + description: "The docker image tag name" + value: ${{ jobs.detect.outputs.TAG_NAME }} + +env: + TARGET_IMAGE: vdaas/vald-ci-container + +jobs: + detect: + runs-on: ubuntu-latest + outputs: + TAG_NAME: ${{ steps.merge_detection_results.outputs.TAG_NAME }} + steps: + - uses: actions/checkout@v3 + + - name: Determine Docker image tag + id: determine_tag_name + uses: ./.github/actions/determine-docker-image-tag + + - name: Detect Docker image tag for primary + id: detect_primary_tag_name + uses: ./.github/actions/detect-docker-image-tags + with: + images: ${{ env.TARGET_IMAGE }} + tag_name: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }} + + - name: Detect Docker image tag for default + id: detect_default_tag_name + uses: ./.github/actions/detect-docker-image-tags + with: + images: ${{ env.TARGET_IMAGE }} + tag_name: ${{ steps.determine_tag_name.outputs.DEFAULT_TAG }} + + - name: Merge Docker image tag detection results + id: merge_detection_results + run: | + TAG_NAME="nightly" + + if [ -n "${DEFAULT_TAG_RESULT}" ]; then + TAG_NAME=${{ steps.determine_tag_name.outputs.DEFAULT_TAG }} + fi + + if [ -n "${PRIMARY_TAG_RESULT}" ]; then + TAG_NAME=${{ steps.determine_tag_name.outputs.PRIMARY_TAG }} + fi + + echo "TAG_NAME=${TAG_NAME}" + echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT + env: + PRIMARY_TAG_RESULT: ${{ steps.detect_primary_tag_name.outputs.IMAGE_TAGS }} + DEFAULT_TAG_RESULT: ${{ steps.detect_default_tag_name.outputs.IMAGE_TAGS }} From 239f8d59f82e0b94b9cf554f4875f92b1dffea77 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 7 Sep 2023 18:08:48 +0900 Subject: [PATCH 04/33] use dynamic ci container image tag Signed-off-by: hlts2 --- .github/workflows/unit-test.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 28ab8f4b29..b6ef30eece 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -41,11 +41,15 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/dump-context + detect-ci-container: + uses: ./.github/workflows/_detect-ci-container.yml + test-cmd: name: Run tests for cmd packages runs-on: ubuntu-latest + needs: [detect-ci-container] container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} steps: - uses: actions/checkout@v3 @@ -64,8 +68,9 @@ jobs: test-internal: name: Run tests for internal packages runs-on: ubuntu-latest + needs: [detect-ci-container] container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} steps: - uses: actions/checkout@v3 @@ -84,8 +89,9 @@ jobs: test-pkg: name: Run tests for pkg packages runs-on: ubuntu-latest + needs: [detect-ci-container] container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} steps: - uses: actions/checkout@v3 From a929bc51839935cb61bcefb5ab45f85fac88b3c2 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 7 Sep 2023 19:30:24 +0900 Subject: [PATCH 05/33] add workflow execution rule Signed-off-by: hlts2 --- .github/workflows/dockers-agent-ngt-image.yml | 2 ++ .github/workflows/dockers-agent-sidecar-image.yml | 2 ++ .github/workflows/dockers-ci-container-image.yml | 2 ++ .github/workflows/dockers-dev-container-image.yml | 2 ++ .github/workflows/dockers-discoverer-k8s-image.yml | 2 ++ .github/workflows/dockers-gateway-filter-image.yml | 2 ++ .github/workflows/dockers-gateway-lb-image.yml | 2 ++ .github/workflows/dockers-helm-operator-image.yml | 2 ++ .github/workflows/dockers-loadtest-image.yml | 2 ++ .github/workflows/dockers-manager-index-image.yml | 2 ++ 10 files changed, 20 insertions(+) diff --git a/.github/workflows/dockers-agent-ngt-image.yml b/.github/workflows/dockers-agent-ngt-image.yml index 9daae29dba..2c0db16356 100644 --- a/.github/workflows/dockers-agent-ngt-image.yml +++ b/.github/workflows/dockers-agent-ngt-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" diff --git a/.github/workflows/dockers-agent-sidecar-image.yml b/.github/workflows/dockers-agent-sidecar-image.yml index 27be8d942f..483cde66a0 100644 --- a/.github/workflows/dockers-agent-sidecar-image.yml +++ b/.github/workflows/dockers-agent-sidecar-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" diff --git a/.github/workflows/dockers-ci-container-image.yml b/.github/workflows/dockers-ci-container-image.yml index 0b487775d3..a61af65c48 100644 --- a/.github/workflows/dockers-ci-container-image.yml +++ b/.github/workflows/dockers-ci-container-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" paths: - ".github/actions/docker-build/actions.yaml" - ".github/workflows/_docker-image.yaml" diff --git a/.github/workflows/dockers-dev-container-image.yml b/.github/workflows/dockers-dev-container-image.yml index 06fa55b581..c8e4920eea 100644 --- a/.github/workflows/dockers-dev-container-image.yml +++ b/.github/workflows/dockers-dev-container-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" paths: - ".github/actions/docker-build/actions.yaml" - ".github/workflows/_docker-image.yaml" diff --git a/.github/workflows/dockers-discoverer-k8s-image.yml b/.github/workflows/dockers-discoverer-k8s-image.yml index 1522ac8b00..b53de3c2c1 100644 --- a/.github/workflows/dockers-discoverer-k8s-image.yml +++ b/.github/workflows/dockers-discoverer-k8s-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" diff --git a/.github/workflows/dockers-gateway-filter-image.yml b/.github/workflows/dockers-gateway-filter-image.yml index ad90f6ecbb..111c983b4f 100644 --- a/.github/workflows/dockers-gateway-filter-image.yml +++ b/.github/workflows/dockers-gateway-filter-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" diff --git a/.github/workflows/dockers-gateway-lb-image.yml b/.github/workflows/dockers-gateway-lb-image.yml index 5ade1a7686..d06b8bcad9 100644 --- a/.github/workflows/dockers-gateway-lb-image.yml +++ b/.github/workflows/dockers-gateway-lb-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" diff --git a/.github/workflows/dockers-helm-operator-image.yml b/.github/workflows/dockers-helm-operator-image.yml index df2a8d84b3..90b5ad07bd 100644 --- a/.github/workflows/dockers-helm-operator-image.yml +++ b/.github/workflows/dockers-helm-operator-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" diff --git a/.github/workflows/dockers-loadtest-image.yml b/.github/workflows/dockers-loadtest-image.yml index 3e6e443628..d2a27afbdc 100644 --- a/.github/workflows/dockers-loadtest-image.yml +++ b/.github/workflows/dockers-loadtest-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" diff --git a/.github/workflows/dockers-manager-index-image.yml b/.github/workflows/dockers-manager-index-image.yml index 7ee8c713fe..a9e2a6a19e 100644 --- a/.github/workflows/dockers-manager-index-image.yml +++ b/.github/workflows/dockers-manager-index-image.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" From a3f40199fc6374e68f46025d7fa60dade7a2952a Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 14:53:57 +0900 Subject: [PATCH 06/33] deleted unnecessary workflow execution rule Signed-off-by: hlts2 --- .github/workflows/dockers-ci-container-image.yml | 2 -- .github/workflows/dockers-dev-container-image.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/dockers-ci-container-image.yml b/.github/workflows/dockers-ci-container-image.yml index a61af65c48..2425f34b97 100644 --- a/.github/workflows/dockers-ci-container-image.yml +++ b/.github/workflows/dockers-ci-container-image.yml @@ -49,8 +49,6 @@ on: - "Makefile.d/**" - "versions/GO_VERSION" - "versions/NGT_VERSION" - schedule: - - cron: "0 1 * * *" jobs: build: diff --git a/.github/workflows/dockers-dev-container-image.yml b/.github/workflows/dockers-dev-container-image.yml index c8e4920eea..5293904057 100644 --- a/.github/workflows/dockers-dev-container-image.yml +++ b/.github/workflows/dockers-dev-container-image.yml @@ -49,8 +49,6 @@ on: - "Makefile.d/**" - "versions/GO_VERSION" - "versions/NGT_VERSION" - schedule: - - cron: "0 1 * * *" jobs: build: From ed1ccd47f410761557b863e42f9927d26a3001ea Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 16:16:19 +0900 Subject: [PATCH 07/33] add new workflow to build docker images when release branch is created Signed-off-by: hlts2 --- .github/workflows/_docker-image.yaml | 8 +- .../dockers-release-branch-image.yaml | 79 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dockers-release-branch-image.yaml diff --git a/.github/workflows/_docker-image.yaml b/.github/workflows/_docker-image.yaml index ee48dfabf6..0850369865 100644 --- a/.github/workflows/_docker-image.yaml +++ b/.github/workflows/_docker-image.yaml @@ -40,7 +40,13 @@ jobs: build: runs-on: ubuntu-latest - if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) || (github.event.pull_request.head.repo.fork == true && github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'ci/approved')) || (github.event_name == 'push' && github.ref == 'refs/heads/main') || startsWith( github.ref, 'refs/tags/') }} + if: >- + ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) || + (github.event.pull_request.head.repo.fork == true && github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'ci/approved')) || + (github.event_name == 'push' && github.ref == 'refs/heads/main') || + (github.event_name == 'push' && startsWith( github.ref, 'refs/heads/release/v')) || + startsWith( github.ref, 'refs/tags/') + }} steps: - name: Get ref id: ref diff --git a/.github/workflows/dockers-release-branch-image.yaml b/.github/workflows/dockers-release-branch-image.yaml new file mode 100644 index 0000000000..6af2f250b6 --- /dev/null +++ b/.github/workflows/dockers-release-branch-image.yaml @@ -0,0 +1,79 @@ +name: Build docker images when the Release branch is created +on: + push: + branches: + - "release/v*.*" + - "!release/v*.*.*" + +jobs: + dump-contexts-to-log: + if: github.event.created + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/dump-context + + agent-ngt: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: agent-ngt + secrets: inherit + + agent-sidecar: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: agent-sidecar + secrets: inherit + + discoverer-k8s: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: discoverer-k8s + secrets: inherit + + manager-index: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: manager-index + secrets: inherit + + operator-helm: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: operator/helm + secrets: inherit + + gateway-lb: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: gateway-lb + secrets: inherit + + gateway-filter: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: gateway-filter + secrets: inherit + + loadtest: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: loadtest + platforms: linux/amd64 + secrets: inherit + + ci-container: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: ci-container + platforms: linux/amd64 + secrets: inherit From 4cb78ed1c161d2bcf1cd48bdd4d222b022f4bdad Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 16:35:20 +0900 Subject: [PATCH 08/33] refactor curl command Signed-off-by: hlts2 --- .github/workflows/_update-protobuf.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_update-protobuf.yaml b/.github/workflows/_update-protobuf.yaml index f8e8f77dca..2d99b952ff 100644 --- a/.github/workflows/_update-protobuf.yaml +++ b/.github/workflows/_update-protobuf.yaml @@ -29,7 +29,10 @@ jobs: steps: - name: Dispatch run: | - curl --fail -u "${USER}:${TOKEN}" -X POST https://api.github.com/repos/vdaas/${REPO}/dispatches -H 'Accept: application/vnd.github.everest-preview+json' --data '{"event_type": "update-protobuf"}' + curl --fail -u "${USER}:${TOKEN}" \ + -X POST https://api.github.com/repos/vdaas/${REPO}/dispatches \ + -H 'Accept: application/vnd.github.everest-preview+json' \ + --data '{"event_type": "update-protobuf"}' env: REPO: ${{ inputs.repo }} USER: ${{ secrets.DISPATCH_USER }} From 4b4eb63965f7ce863b12ee93cb1f7268e958ad0d Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 17:09:29 +0900 Subject: [PATCH 09/33] use dynamic ci container image for unit test and hack test Signed-off-by: hlts2 --- .github/workflows/test-hack.yml | 8 +++++++- .github/workflows/unit-test.yaml | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-hack.yml b/.github/workflows/test-hack.yml index e1561b513c..d1b793f27a 100644 --- a/.github/workflows/test-hack.yml +++ b/.github/workflows/test-hack.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" paths: - "go.mod" - "go.sum" @@ -48,11 +50,15 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/dump-context + detect-ci-container: + uses: ./.github/workflows/_detect-ci-container.yml + test-hack: name: Run tests for hack packages runs-on: ubuntu-latest + needs: [detect-ci-container] container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} defaults: run: working-directory: ${{ env.GOPATH }}/${{ env.PROJECT_ROOT_DIR }} diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index b6ef30eece..83572502d3 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" paths: - "go.mod" - "go.sum" From 79c269af82d6055faf856d6c7a08efe080e7ad7e Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 17:29:23 +0900 Subject: [PATCH 10/33] add new workflow execution rule to codeql and protobuf build Signed-off-by: hlts2 --- .github/workflows/build-protobuf.yml | 2 ++ .github/workflows/codeql-analysis.yml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build-protobuf.yml b/.github/workflows/build-protobuf.yml index 173d541431..9c03977465 100644 --- a/.github/workflows/build-protobuf.yml +++ b/.github/workflows/build-protobuf.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" paths: - "apis/proto/**" - "versions/GO_VERSION" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 611c3dc418..a9fe4e2290 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,6 +18,8 @@ on: push: branches: - main + - "release/v*.*" + - "!release/v*.*.*" tags: - "*.*.*" - "v*.*.*" @@ -26,6 +28,8 @@ on: pull_request: branches: - main + - "release/v*.*" + - "!release/v*.*.*" paths: - ".github/workflows/codeql-analysis.yml" - "**.go" From 624a628bcdf68ecde098d5e3691e06017604de57 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 17:34:50 +0900 Subject: [PATCH 11/33] add workflow to release Signed-off-by: hlts2 --- .github/workflows/release.yml | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..ca5dc47dc6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,116 @@ +# +# Copyright (C) 2019-2023 vdaas.org vald team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +name: Run release +on: + push: + branches: + - "release/v*.*" + - "!release/v*.*.*" + +jobs: + dump-contexts-to-log: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/dump-context + + detect-ci-container: + uses: ./.github/workflows/_detect-ci-container.yml + secrets: inherit + + semver-auto: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set Github context + id: set_context + run: | + RELEASE_BRANCH_NAME=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` + BRANCH_LATEST_TAG=`git tag | grep ${RELEASE_BRANCH_NAME} | tail -n 1` + RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(major|minor|patch)\].*:\1:p'` + + echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" >> $GITHUB_OUTPUT # e.g) vx.x + echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x or empty + echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor or patch or empty + + echo "${RELEASE_BRANCH_NAME}" + echo "${BRANCH_LATEST_TAG}" + echo "${RELEASE_KIND}" + + - name: Upgrade semver + if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }} + env: + RELEASE_BRANCH_NAME: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} + BRANCH_LATEST_TAG: ${{ steps.set_context.outputs.BRANCH_LATEST_TAG }} + RELEASE_KIND: ${{ steps.set_context.outputs.RELEASE_KIND }} + run: | + if [ -z "${BRANCH_LATEST_TAG}" ]; then + case ${RELEASE_KIND} in + major | minor) RELEASE_TAG="${RELEASE_BRANCH_NAME}.0"; ;; + *) echo "not supported semver kind"; exit 1; ;; + esac + else + IFS=. read -r version minor patch <<< "${BRANCH_LATEST_TAG}" + + case ${RELEASE_KIND} in + patch) RELEASE_TAG="$version.$minor.$((patch+1))"; ;; + *) echo "not supported semver kind"; exit 1; ;; + esac + fi + + if [ `git tag | grep "${RELEASE_TAG}"` ] || [ `cat versions/VALD_VERSION` = "${RELEASE_TAG}" ]; then + echo "release already exists: ${RELEASE_TAG}" + exit 1 + fi + + echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT # e.g) vx.x.x + echo "${RELEASE_TAG}" + + release: + needs: + - detect-ci-container + - semver-auto + runs-on: ubuntu-latest + container: + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set Git config + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + + - name: Update for new release + run: | + git branch + + LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` + PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` + + PREVIOUS_VERSION=`cat versions/VALD_VERSION` + + echo "${GITWERK_RESULT}" > versions/VALD_VERSION + + # TODO + echo "${PR_NUM}" + echo "${LAST_COMMIT_MESSAGE}" + echo "${PREVIOUS_VERSION}" + cat versions/VALD_VERSION From 3a96489a7c94bc5b41db6ce12f197000072bba86 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 18:03:12 +0900 Subject: [PATCH 12/33] make format Signed-off-by: hlts2 --- .github/workflows/_detect-ci-container.yml | 15 +++++++++++++++ .../workflows/dockers-release-branch-image.yaml | 15 +++++++++++++++ .github/workflows/pr.yaml | 17 ++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_detect-ci-container.yml b/.github/workflows/_detect-ci-container.yml index 5b4a8a034d..a7005ef344 100644 --- a/.github/workflows/_detect-ci-container.yml +++ b/.github/workflows/_detect-ci-container.yml @@ -1,3 +1,18 @@ +# +# Copyright (C) 2019-2023 vdaas.org vald team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# name: "Detect CI container image tag" on: workflow_call: diff --git a/.github/workflows/dockers-release-branch-image.yaml b/.github/workflows/dockers-release-branch-image.yaml index 6af2f250b6..e00d670402 100644 --- a/.github/workflows/dockers-release-branch-image.yaml +++ b/.github/workflows/dockers-release-branch-image.yaml @@ -1,3 +1,18 @@ +# +# Copyright (C) 2019-2023 vdaas.org vald team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# name: Build docker images when the Release branch is created on: push: diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 669f62eac8..6e6998262e 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,3 +1,18 @@ +# +# Copyright (C) 2019-2023 vdaas.org vald team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# name: "Run backport PR creation" on: pull_request: @@ -39,7 +54,7 @@ jobs: echo "${RELEASE_BRANCH_NAME}" echo "${BACKPORT_BRANCH_NAME}" env: - TARGET_LABEL_NAME_PREFIX: 'actions/backport/' + TARGET_LABEL_NAME_PREFIX: "actions/backport/" HOOKED_LABEL_NAME: ${{ github.event.label.name }} - name: Create PR From 284275602e4368672fb8ed1abbbe4054d56f0042 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 18:22:32 +0900 Subject: [PATCH 13/33] deleted unnecessary code Signed-off-by: hlts2 --- .github/workflows/release.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca5dc47dc6..ea968c2110 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,15 +100,9 @@ jobs: - name: Update for new release run: | - git branch - LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` - PREVIOUS_VERSION=`cat versions/VALD_VERSION` - - echo "${GITWERK_RESULT}" > versions/VALD_VERSION - # TODO echo "${PR_NUM}" echo "${LAST_COMMIT_MESSAGE}" From 3eeca3da2c6ce582429188df7e641013fbb0a700 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 18:39:41 +0900 Subject: [PATCH 14/33] add step to create release tag and release commit Signed-off-by: hlts2 --- .github/workflows/release.yml | 50 +++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea968c2110..1b679036c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,8 @@ jobs: semver-auto: runs-on: ubuntu-latest + outputs: + RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} steps: - uses: actions/checkout@v3 with: @@ -54,6 +56,7 @@ jobs: echo "${RELEASE_KIND}" - name: Upgrade semver + id: upgrade_semver if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }} env: RELEASE_BRANCH_NAME: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} @@ -89,6 +92,8 @@ jobs: runs-on: ubuntu-latest container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} + env: + RELEASE_TAG: ${{ needs.semver-auto.outputs.RELEASE_TAG }} steps: - uses: actions/checkout@v3 with: @@ -103,8 +108,43 @@ jobs: LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` - # TODO - echo "${PR_NUM}" - echo "${LAST_COMMIT_MESSAGE}" - echo "${PREVIOUS_VERSION}" - cat versions/VALD_VERSION + make helm/docs/vald + make helm/docs/vald-helm-operator + + make helm/schema/vald + make helm/schema/vald-helm-operator + + BODY="" + if [ ! -z "${PR_NUM}" ]; then + BODY=`curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUM}" | jq -r '.body'` + fi + + if [ -z "$BODY" ]; then + BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..main | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"` + fi + + CHANGELOG=`make changelog/next/print BODY="$BODY"` + make changelog/update BODY="$BODY" + + git add \ + versions/VALD_VERSION \ + charts/vald/Chart.yaml \ + charts/vald/values.yaml \ + charts/vald/values.schema.json \ + charts/vald/README.md \ + charts/vald-helm-operator/Chart.yaml \ + charts/vald-helm-operator/values.yaml \ + charts/vald-helm-operator/values.schema.json \ + charts/vald-helm-operator/README.md \ + CHANGELOG.md + git commit -S --signoff -m ":bookmark: :robot: Release ${GITWERK_RESULT}" + + git tag ${RELEASE_TAG} + + git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + + git push origin main + git push origin ${RELEASE_TAG} + + echo "RELEASE=true" >> $GITHUB_OUTPUT + echo "VERSION=${RELEASE_TAG}" >> $GITHUB_OUTPUT From 41c341800dff4049ee20b067c1df49ba3760f5af Mon Sep 17 00:00:00 2001 From: hlts2 Date: Fri, 8 Sep 2023 18:41:58 +0900 Subject: [PATCH 15/33] deleted invalid environment variable Signed-off-by: hlts2 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b679036c5..028b37fa39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -137,7 +137,7 @@ jobs: charts/vald-helm-operator/values.schema.json \ charts/vald-helm-operator/README.md \ CHANGELOG.md - git commit -S --signoff -m ":bookmark: :robot: Release ${GITWERK_RESULT}" + git commit -S --signoff -m ":bookmark: :robot: Release ${RELEASE_TAG}" git tag ${RELEASE_TAG} From 4b182819df8f74f19049c5f9a8391a627ca765d5 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 11 Sep 2023 10:37:35 +0900 Subject: [PATCH 16/33] add release logic and auto generate code for release Signed-off-by: hlts2 --- .../determine-docker-image-tag/action.yaml | 4 +- .github/workflows/dockers-agent-ngt-image.yml | 2 +- .../workflows/dockers-agent-sidecar-image.yml | 2 +- .../workflows/dockers-ci-container-image.yml | 2 +- .../workflows/dockers-dev-container-image.yml | 2 +- .../dockers-discoverer-k8s-image.yml | 2 +- .../dockers-gateway-filter-image.yml | 2 +- .../workflows/dockers-gateway-lb-image.yml | 2 +- .../workflows/dockers-helm-operator-image.yml | 2 +- .github/workflows/dockers-loadtest-image.yml | 2 +- .../workflows/dockers-manager-index-image.yml | 2 +- .../dockers-release-branch-image.yaml | 2 +- .github/workflows/release.yml | 51 +++++++++++++++---- 13 files changed, 55 insertions(+), 22 deletions(-) diff --git a/.github/actions/determine-docker-image-tag/action.yaml b/.github/actions/determine-docker-image-tag/action.yaml index 2869be2728..ab7c94e67d 100644 --- a/.github/actions/determine-docker-image-tag/action.yaml +++ b/.github/actions/determine-docker-image-tag/action.yaml @@ -45,7 +45,7 @@ runs: echo "${tag_name}" > versions/VALD_VERSION primary_tag="${tag_name}" - default_tag="${tag_name}" + default_tag="nightly" elif [[ "${{ github.event_name }}" = "pull_request" || "${{ github.event_name }}" = "pull_request_target" ]]; then pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"` echo "PR-${pr_num}" > versions/VALD_VERSION @@ -69,7 +69,7 @@ runs: echo "${tag_name}" > versions/VALD_VERSION primary_tag="${tag_name}" - default_tag="${tag_name}" + default_tag="nightly" else primary_tag="unknown" default_tag="unknown" diff --git a/.github/workflows/dockers-agent-ngt-image.yml b/.github/workflows/dockers-agent-ngt-image.yml index 2c0db16356..b84fc5d123 100644 --- a/.github/workflows/dockers-agent-ngt-image.yml +++ b/.github/workflows/dockers-agent-ngt-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: agent-ngt" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-agent-sidecar-image.yml b/.github/workflows/dockers-agent-sidecar-image.yml index 483cde66a0..ca3dcf3aeb 100644 --- a/.github/workflows/dockers-agent-sidecar-image.yml +++ b/.github/workflows/dockers-agent-sidecar-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: agent-sidecar" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-ci-container-image.yml b/.github/workflows/dockers-ci-container-image.yml index 2425f34b97..97139d77a4 100644 --- a/.github/workflows/dockers-ci-container-image.yml +++ b/.github/workflows/dockers-ci-container-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: ci-container" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" paths: diff --git a/.github/workflows/dockers-dev-container-image.yml b/.github/workflows/dockers-dev-container-image.yml index 5293904057..7b617a24e8 100644 --- a/.github/workflows/dockers-dev-container-image.yml +++ b/.github/workflows/dockers-dev-container-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: dev-container" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" paths: diff --git a/.github/workflows/dockers-discoverer-k8s-image.yml b/.github/workflows/dockers-discoverer-k8s-image.yml index b53de3c2c1..e6eccf5f73 100644 --- a/.github/workflows/dockers-discoverer-k8s-image.yml +++ b/.github/workflows/dockers-discoverer-k8s-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: discoverer-k8s" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-gateway-filter-image.yml b/.github/workflows/dockers-gateway-filter-image.yml index 111c983b4f..0d85ee0214 100644 --- a/.github/workflows/dockers-gateway-filter-image.yml +++ b/.github/workflows/dockers-gateway-filter-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: gateway-filter" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-gateway-lb-image.yml b/.github/workflows/dockers-gateway-lb-image.yml index d06b8bcad9..9bf73f1f05 100644 --- a/.github/workflows/dockers-gateway-lb-image.yml +++ b/.github/workflows/dockers-gateway-lb-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: gateway-lb" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-helm-operator-image.yml b/.github/workflows/dockers-helm-operator-image.yml index 90b5ad07bd..c720cfd3c6 100644 --- a/.github/workflows/dockers-helm-operator-image.yml +++ b/.github/workflows/dockers-helm-operator-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: helm-operator" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-loadtest-image.yml b/.github/workflows/dockers-loadtest-image.yml index d2a27afbdc..3204d394b6 100644 --- a/.github/workflows/dockers-loadtest-image.yml +++ b/.github/workflows/dockers-loadtest-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: loadtest" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-manager-index-image.yml b/.github/workflows/dockers-manager-index-image.yml index a9e2a6a19e..1b8080b111 100644 --- a/.github/workflows/dockers-manager-index-image.yml +++ b/.github/workflows/dockers-manager-index-image.yml @@ -17,7 +17,7 @@ name: "Build docker image: manager-index" on: push: branches: - - main + - "main" - "release/v*.*" - "!release/v*.*.*" tags: diff --git a/.github/workflows/dockers-release-branch-image.yaml b/.github/workflows/dockers-release-branch-image.yaml index e00d670402..0aa7c40be7 100644 --- a/.github/workflows/dockers-release-branch-image.yaml +++ b/.github/workflows/dockers-release-branch-image.yaml @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: Build docker images when the Release branch is created +name: Build docker images when the release branch is created on: push: branches: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 028b37fa39..74f153a8e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,7 @@ jobs: semver-auto: runs-on: ubuntu-latest outputs: + RELEASE_BRANCH_NAME_PREFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} steps: - uses: actions/checkout@v3 @@ -43,15 +44,15 @@ jobs: - name: Set Github context id: set_context run: | - RELEASE_BRANCH_NAME=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` - BRANCH_LATEST_TAG=`git tag | grep ${RELEASE_BRANCH_NAME} | tail -n 1` + RELEASE_BRANCH_NAME_PREFIX=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` + BRANCH_LATEST_TAG=`git tag | grep ${RELEASE_BRANCH_NAME_PREFIX} | tail -n 1` RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(major|minor|patch)\].*:\1:p'` - echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" >> $GITHUB_OUTPUT # e.g) vx.x - echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x or empty - echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor or patch or empty + echo "RELEASE_BRANCH_NAME_PREFIX=${RELEASE_BRANCH_NAME_PREFIX}" >> $GITHUB_OUTPUT # e.g) vx.x + echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x or empty + echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor or patch or empty - echo "${RELEASE_BRANCH_NAME}" + echo "${RELEASE_BRANCH_NAME_PREFIX}" echo "${BRANCH_LATEST_TAG}" echo "${RELEASE_KIND}" @@ -59,13 +60,13 @@ jobs: id: upgrade_semver if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }} env: - RELEASE_BRANCH_NAME: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} + RELEASE_BRANCH_NAME_PREFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_PREFIX }} BRANCH_LATEST_TAG: ${{ steps.set_context.outputs.BRANCH_LATEST_TAG }} RELEASE_KIND: ${{ steps.set_context.outputs.RELEASE_KIND }} run: | if [ -z "${BRANCH_LATEST_TAG}" ]; then case ${RELEASE_KIND} in - major | minor) RELEASE_TAG="${RELEASE_BRANCH_NAME}.0"; ;; + major | minor) RELEASE_TAG="${RELEASE_BRANCH_NAME_PREFIX}.0"; ;; *) echo "not supported semver kind"; exit 1; ;; esac else @@ -93,6 +94,7 @@ jobs: container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} env: + RELEASE_BRANCH_NAME: release/${{ steps.semver-auto.outputs.RELEASE_BRANCH_NAME_PREFIX }} RELEASE_TAG: ${{ needs.semver-auto.outputs.RELEASE_TAG }} steps: - uses: actions/checkout@v3 @@ -104,10 +106,21 @@ jobs: git config --global --add safe.directory ${GITHUB_WORKSPACE} - name: Update for new release + id: update_for_new_release run: | + # git checkout ${RELEASE_BRANCH_NAME} // TODO Check in the vald-ci-labs + LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` + PREVIOUS_VERSION=`cat versions/VALD_VERSION` + echo "${RELEASE_TAG}" > versions/VALD_VERSION + + sed -i -e "s/^version: .*$/version: ${RELEASE_TAG}/" charts/vald/Chart.yaml + sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${RELEASE_TAG}/" charts/vald/values.yaml + sed -i -e "s/^version: .*$/version: ${RELEASE_TAG}/" charts/vald-helm-operator/Chart.yaml + sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${RELEASE_TAG}/" charts/vald-helm-operator/values.yaml + make helm/docs/vald make helm/docs/vald-helm-operator @@ -143,8 +156,28 @@ jobs: git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - git push origin main + git push origin ${RELEASE_BRANCH_NAME} git push origin ${RELEASE_TAG} echo "RELEASE=true" >> $GITHUB_OUTPUT echo "VERSION=${RELEASE_TAG}" >> $GITHUB_OUTPUT + env: + GITHUB_USER: ${{ secrets.DISPATCH_USER }} + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + + - name: Create release + if: steps.update_for_new_release.outputs.RELEASE == 'true' + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + with: + tag_name: ${{ steps.update_for_new_release.outputs.VERSION }} + release_name: Release ${{ steps.update_for_new_release.outputs.VERSION }} + body: | + See [CHANGELOG.md](https://github.com/vdaas/vald/blob/${{ steps.update_for_new_release.outputs.VERSION }}/CHANGELOG.md) for details. + draft: false + prerelease: false + + - name: Add the version to goproxy + run: | + curl "https://proxy.golang.org/github.com/vdaas/vald/@v/${{ steps.update_for_new_release.outputs.VERSION }}.info" From 71df66e0f9ec8be49d761e77ad9529dde14bb80a Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 11 Sep 2023 13:13:32 +0900 Subject: [PATCH 17/33] deleted unnecessary code Signed-off-by: hlts2 --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 74f153a8e3..1a6c89593e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -108,8 +108,6 @@ jobs: - name: Update for new release id: update_for_new_release run: | - # git checkout ${RELEASE_BRANCH_NAME} // TODO Check in the vald-ci-labs - LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` From cff1398c6e29da2930d7dd7a6379f3a05dce8e9f Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 11 Sep 2023 14:28:26 +0900 Subject: [PATCH 18/33] bugfix branch specification Signed-off-by: hlts2 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a6c89593e..f6dc85f215 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -131,7 +131,7 @@ jobs: fi if [ -z "$BODY" ]; then - BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..main | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"` + BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..${RELEASE_BRANCH_NAME} | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"` fi CHANGELOG=`make changelog/next/print BODY="$BODY"` From b54e74cda19f500c42cb70761d2c6b98a278ee40 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 11 Sep 2023 15:43:23 +0900 Subject: [PATCH 19/33] bugfix release logic Signed-off-by: hlts2 --- .github/workflows/release.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6dc85f215..2201e9f117 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,6 +36,7 @@ jobs: outputs: RELEASE_BRANCH_NAME_PREFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} + RELEASE: ${{ steps.upgrade_semver.outputs.RELEASE }} steps: - uses: actions/checkout@v3 with: @@ -83,7 +84,9 @@ jobs: exit 1 fi + echo "RELEASE=true" >> $GITHUB_OUTPUT echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT # e.g) vx.x.x + echo "${RELEASE_TAG}" release: @@ -91,10 +94,11 @@ jobs: - detect-ci-container - semver-auto runs-on: ubuntu-latest + if: ${{ needs.semver-auto.outputs.RELEASE == 'true' }} container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} env: - RELEASE_BRANCH_NAME: release/${{ steps.semver-auto.outputs.RELEASE_BRANCH_NAME_PREFIX }} + RELEASE_BRANCH_NAME: release/${{ needs.semver-auto.outputs.RELEASE_BRANCH_NAME_PREFIX }} RELEASE_TAG: ${{ needs.semver-auto.outputs.RELEASE_TAG }} steps: - uses: actions/checkout@v3 @@ -157,20 +161,18 @@ jobs: git push origin ${RELEASE_BRANCH_NAME} git push origin ${RELEASE_TAG} - echo "RELEASE=true" >> $GITHUB_OUTPUT echo "VERSION=${RELEASE_TAG}" >> $GITHUB_OUTPUT env: GITHUB_USER: ${{ secrets.DISPATCH_USER }} GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} - name: Create release - if: steps.update_for_new_release.outputs.RELEASE == 'true' uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} with: tag_name: ${{ steps.update_for_new_release.outputs.VERSION }} - release_name: Release ${{ steps.update_for_new_release.outputs.VERSION }} + name: Release ${{ steps.update_for_new_release.outputs.VERSION }} body: | See [CHANGELOG.md](https://github.com/vdaas/vald/blob/${{ steps.update_for_new_release.outputs.VERSION }}/CHANGELOG.md) for details. draft: false From 76b2f6de2ae9b33a9e45cb8a85223ca35d18295c Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 12 Sep 2023 10:57:11 +0900 Subject: [PATCH 20/33] add checkout to release branch Signed-off-by: hlts2 --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2201e9f117..9e7c03107a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,6 +112,8 @@ jobs: - name: Update for new release id: update_for_new_release run: | + git checkout ${RELEASE_BRANCH_NAME} + LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` From d64f734aa713a9643ef5f2c0fc0125fc75196967 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 12 Sep 2023 11:04:16 +0900 Subject: [PATCH 21/33] bugfix set step result and add gpg import step Signed-off-by: hlts2 --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e7c03107a..02552bbeb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: semver-auto: runs-on: ubuntu-latest outputs: - RELEASE_BRANCH_NAME_PREFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} + RELEASE_BRANCH_NAME_PREFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_PREFIX }} RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} RELEASE: ${{ steps.upgrade_semver.outputs.RELEASE }} steps: @@ -109,6 +109,12 @@ jobs: run: | git config --global --add safe.directory ${GITHUB_WORKSPACE} + - uses: crazy-max/ghaction-import-gpg@v4 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + git_user_signingkey: true + git_commit_gpgsign: true + - name: Update for new release id: update_for_new_release run: | From e0afbae4554e0cb4d1c2d0182bc86dce91ef9d38 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 12 Sep 2023 19:05:49 +0900 Subject: [PATCH 22/33] fix typo Signed-off-by: hlts2 --- .github/workflows/release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02552bbeb3..77f1196a4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: semver-auto: runs-on: ubuntu-latest outputs: - RELEASE_BRANCH_NAME_PREFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_PREFIX }} + RELEASE_BRANCH_NAME_SUFFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_SUFFIX }} RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} RELEASE: ${{ steps.upgrade_semver.outputs.RELEASE }} steps: @@ -45,15 +45,15 @@ jobs: - name: Set Github context id: set_context run: | - RELEASE_BRANCH_NAME_PREFIX=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` - BRANCH_LATEST_TAG=`git tag | grep ${RELEASE_BRANCH_NAME_PREFIX} | tail -n 1` + RELEASE_BRANCH_NAME_SUFFIX=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` + BRANCH_LATEST_TAG=`git tag | grep ${RELEASE_BRANCH_NAME_SUFFIX} | tail -n 1` RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(major|minor|patch)\].*:\1:p'` - echo "RELEASE_BRANCH_NAME_PREFIX=${RELEASE_BRANCH_NAME_PREFIX}" >> $GITHUB_OUTPUT # e.g) vx.x + echo "RELEASE_BRANCH_NAME_SUFFIX=${RELEASE_BRANCH_NAME_SUFFIX}" >> $GITHUB_OUTPUT # e.g) vx.x echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x or empty echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor or patch or empty - echo "${RELEASE_BRANCH_NAME_PREFIX}" + echo "${RELEASE_BRANCH_NAME_SUFFIX}" echo "${BRANCH_LATEST_TAG}" echo "${RELEASE_KIND}" @@ -61,13 +61,13 @@ jobs: id: upgrade_semver if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }} env: - RELEASE_BRANCH_NAME_PREFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_PREFIX }} + RELEASE_BRANCH_NAME_SUFFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_SUFFIX }} BRANCH_LATEST_TAG: ${{ steps.set_context.outputs.BRANCH_LATEST_TAG }} RELEASE_KIND: ${{ steps.set_context.outputs.RELEASE_KIND }} run: | if [ -z "${BRANCH_LATEST_TAG}" ]; then case ${RELEASE_KIND} in - major | minor) RELEASE_TAG="${RELEASE_BRANCH_NAME_PREFIX}.0"; ;; + major | minor) RELEASE_TAG="${RELEASE_BRANCH_NAME_SUFFIX}.0"; ;; *) echo "not supported semver kind"; exit 1; ;; esac else @@ -98,7 +98,7 @@ jobs: container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} env: - RELEASE_BRANCH_NAME: release/${{ needs.semver-auto.outputs.RELEASE_BRANCH_NAME_PREFIX }} + RELEASE_BRANCH_NAME: release/${{ needs.semver-auto.outputs.RELEASE_BRANCH_NAME_SUFFIX }} RELEASE_TAG: ${{ needs.semver-auto.outputs.RELEASE_TAG }} steps: - uses: actions/checkout@v3 From 9e392cf8375edb3588f85a0787304b3929919c5b Mon Sep 17 00:00:00 2001 From: hlts2 Date: Wed, 20 Sep 2023 14:03:51 +0900 Subject: [PATCH 23/33] add new workflow for two version support Signed-off-by: hlts2 --- .../detect-docker-image-tags/action.yaml | 1 + .github/actions/setup-e2e/action.yaml | 16 +- .github/workflows/_release-pr.yml | 133 +++++++++++++++ .../workflows/dockers-ci-container-image.yml | 5 + .../dockers-release-branch-image.yaml | 2 +- .github/workflows/helm.yml | 65 -------- .github/workflows/pr.yaml | 70 +++++--- .github/workflows/release.yml | 150 +++-------------- .github/workflows/semver-major-minor.yaml | 109 ++++++++++++ .github/workflows/semver-patch.yaml | 83 ++++++++++ .github/workflows/semver.yml | 156 ------------------ 11 files changed, 410 insertions(+), 380 deletions(-) create mode 100644 .github/workflows/_release-pr.yml create mode 100644 .github/workflows/semver-major-minor.yaml create mode 100644 .github/workflows/semver-patch.yaml delete mode 100644 .github/workflows/semver.yml diff --git a/.github/actions/detect-docker-image-tags/action.yaml b/.github/actions/detect-docker-image-tags/action.yaml index 42c254a5d2..48f0b2fa8d 100644 --- a/.github/actions/detect-docker-image-tags/action.yaml +++ b/.github/actions/detect-docker-image-tags/action.yaml @@ -50,6 +50,7 @@ runs: ["vdaas/vald-lb-gateway"]="gateway.lb.image.tag" ["vdaas/vald-manager-index"]="manager.index.image.tag" ["vdaas/vald-helm-operator"]="image.tag" + ["vdaas/vald-ci-container"]="" ) for image in ${IMAGES} diff --git a/.github/actions/setup-e2e/action.yaml b/.github/actions/setup-e2e/action.yaml index ba8b8cc2c5..c5af540b45 100644 --- a/.github/actions/setup-e2e/action.yaml +++ b/.github/actions/setup-e2e/action.yaml @@ -15,6 +15,7 @@ # name: "Setup E2E environment" description: "A action to set up the environment for executing E2E test" + inputs: require_libhdf5: description: "If libhdf5 is not required, set this to false" @@ -39,7 +40,11 @@ inputs: target_images: description: "Image names" required: false - default: "vdaas/vald-agent-ngt vdaas/vald-discoverer-k8s vdaas/vald-lb-gateway vdaas/vald-manager-index" + default: "vdaas/vald-agent-ngt \ + vdaas/vald-discoverer-k8s \ + vdaas/vald-lb-gateway \ + vdaas/vald-manager-index" + outputs: HELM_EXTRA_OPTIONS: description: "Helm extra options that specifies E2E target image tags" @@ -60,32 +65,39 @@ runs: run: | sudo apt-get update sudo apt-get install -y libhdf5-dev + - name: Setup Go environment if: ${{ inputs.require_go == 'true' }} uses: ./.github/actions/setup-go + - name: Setup Helm environment if: ${{ inputs.require_helm == 'true' }} uses: ./.github/actions/setup-helm + - name: Wait for target Docker images if: startsWith( github.ref, 'refs/tags/') uses: ./.github/actions/wait-for-docker-image with: images: ${{ inputs.target_images }} + - name: Determine Docker image tag id: determine_tag_name uses: ./.github/actions/determine-docker-image-tag + - name: Specify container versions id: specify_container_versions uses: ./.github/actions/detect-docker-image-tags with: tag_name: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }} images: ${{ inputs.target_images }} + - uses: ./.github/actions/setup-k3d if: ${{ inputs.require_k3d == 'true' }} with: agents: 3 ingress_port: ${{ inputs.ingress_port }} + - name: Check Kubernetes cluster shell: bash run: | - kubectl cluster-info dump + kubectl cluster-info diff --git a/.github/workflows/_release-pr.yml b/.github/workflows/_release-pr.yml new file mode 100644 index 0000000000..1f85113629 --- /dev/null +++ b/.github/workflows/_release-pr.yml @@ -0,0 +1,133 @@ +# +# Copyright (C) 2019-2023 vdaas.org vald team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +name: "Create release PR" +on: + workflow_call: + inputs: + release_branch_name: + type: string + description: "The release branch name. e.g release/v1.7" + required: true + release_tag: + type: string + description: "The release tag" + required: true + +jobs: + dump-contexts-to-log: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/dump-context + + detect-ci-container: + uses: ./.github/workflows/_detect-ci-container.yml + secrets: inherit + + create: + needs: + - dump-contexts-to-log + - detect-ci-container + runs-on: ubuntu-latest + container: + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} + env: + RELEASE_BRANCH_NAME: ${{ inputs.release_branch_name }} + PREPARE_RELEASE_BRANCH_NAME: prepare/${{ inputs.release_branch_name }} + RELEASE_TAG: ${{ inputs.release_tag }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.DISPATCH_TOKEN }} + + - name: Set Git config + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + + - uses: crazy-max/ghaction-import-gpg@v4 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + git_user_signingkey: true + git_commit_gpgsign: true + + - name: Update for new release + id: update_for_new_release + run: | + git checkout ${RELEASE_BRANCH_NAME} + git checkout -b ${PREPARE_RELEASE_BRANCH_NAME} && git push origin ${PREPARE_RELEASE_BRANCH_NAME} + + LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` + PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` + + PREVIOUS_VERSION=`cat versions/VALD_VERSION` + echo "${RELEASE_TAG}" > versions/VALD_VERSION + + sed -i -e "s/^version: .*$/version: ${RELEASE_TAG}/" charts/vald/Chart.yaml + sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${RELEASE_TAG}/" charts/vald/values.yaml + sed -i -e "s/^version: .*$/version: ${RELEASE_TAG}/" charts/vald-helm-operator/Chart.yaml + sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${RELEASE_TAG}/" charts/vald-helm-operator/values.yaml + + make helm/schema/vald + make helm/schema/vald-helm-operator + make helm/schema/crd/vald + make helm/schema/crd/vald-helm-operator + make k8s/manifest/update + make k8s/manifest/helm-operator/update + make helm/docs/vald + make helm/docs/vald-helm-operator + + BODY="" + if [ ! -z "${PR_NUM}" ]; then + BODY=`curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUM}" | jq -r '.body'` + fi + + if [ -z "$BODY" ]; then + BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..${RELEASE_BRANCH_NAME} | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"` + fi + + CHANGELOG=`make changelog/next/print BODY="$BODY"` + make changelog/update BODY="$BODY" + + make format + + git add \ + CHANGELOG.md \ + charts/vald-helm-operator/Chart.yaml \ + charts/vald-helm-operator/README.md \ + charts/vald-helm-operator/values.schema.json \ + charts/vald-helm-operator/values.yaml \ + charts/vald/Chart.yaml \ + charts/vald/README.md \ + charts/vald/values.schema.json \ + charts/vald/values.yaml \ + k8s \ + versions/VALD_VERSION + git commit -S --signoff -m ":bookmark: :robot: Release ${RELEASE_TAG}" + git push -u origin ${PREPARE_RELEASE_BRANCH_NAME} + + curl --include --verbose --fail \ + -H "Accept: application/json" \ + -H "Content-Type:application/json" \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + --request POST \ + --data "{\"title\": \"Release ${RELEASE_TAG}\", \"head\": \"${PREPARE_RELEASE_BRANCH_NAME}\", \"base\": \"${RELEASE_BRANCH_NAME}\", \"body\": \"Release PR for ${RELEASE_TAG}.\", \"maintainer_can_modify\": true}" \ + $API_URL + + env: + GITHUB_USER: ${{ secrets.DISPATCH_USER }} + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + API_URL: https://api.github.com/repos/vdaas/vald/pulls diff --git a/.github/workflows/dockers-ci-container-image.yml b/.github/workflows/dockers-ci-container-image.yml index 97139d77a4..8b37e5cf2f 100644 --- a/.github/workflows/dockers-ci-container-image.yml +++ b/.github/workflows/dockers-ci-container-image.yml @@ -20,6 +20,11 @@ on: - "main" - "release/v*.*" - "!release/v*.*.*" + tags: + - "*.*.*" + - "v*.*.*" + - "*.*.*-*" + - "v*.*.*-*" paths: - ".github/actions/docker-build/actions.yaml" - ".github/workflows/_docker-image.yaml" diff --git a/.github/workflows/dockers-release-branch-image.yaml b/.github/workflows/dockers-release-branch-image.yaml index 0aa7c40be7..7905dd6c16 100644 --- a/.github/workflows/dockers-release-branch-image.yaml +++ b/.github/workflows/dockers-release-branch-image.yaml @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: Build docker images when the release branch is created +name: "Build docker images when the release branch is created" on: push: branches: diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 7e272112ba..b0d616785a 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -29,70 +29,6 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/dump-context - update-k8s-manifest: - name: Update k8s manifest - runs-on: ubuntu-latest - container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set Git config - run: | - git config --global --add safe.directory ${GITHUB_WORKSPACE} - - - uses: crazy-max/ghaction-import-gpg@v4 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - git_user_signingkey: true - git_commit_gpgsign: true - - - name: Setup Helm environment - uses: ./.github/actions/setup-helm - - - name: Switch new branch - id: switch_to_new_branch - run: | - TIMESTAMP=$(date +%Y%m%d_%H%M%S_%3N) - BRANCH_NAME="documentation/k8s-manifests/update_k8s_manifests_${TIMESTAMP}" - git checkout main - git checkout -b ${BRANCH_NAME} - echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT - - - name: Update k8s-dir - run: | - make k8s/manifest/update - make k8s/manifest/helm-operator/update - - - name: Run formatter and license.go - run: | - make format/yaml - make license - - - name: Push to main - continue-on-error: true - run: | - git add k8s - git commit -S --signoff -m ":robot: Automatically update k8s manifests" - - git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - git push -u origin ${BRANCH_NAME} - - curl --include --verbose --fail \ - -H "Accept: application/json" \ - -H "Content-Type:application/json" \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - --request POST \ - --data "{\"title\": \"Update K8s manifests\", \"head\": \"${BRANCH_NAME}\", \"base\": \"main\", \"body\": \"K8s manifests are updated.\", \"maintainer_can_modify\": true}" \ - $API_URL - env: - GITHUB_USER: ${{ secrets.DISPATCH_USER }} - GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} - API_URL: https://api.github.com/repos/vdaas/vald/pulls - BRANCH_NAME: ${{ steps.switch_to_new_branch.outputs.BRANCH_NAME }} - update-helm-chart: name: Update Helm chart runs-on: ubuntu-latest @@ -157,7 +93,6 @@ jobs: id: deploy_vald uses: ./.github/actions/e2e-deploy-vald with: - default_image_tag: ${{ steps.setup_e2e.outputs.DEFAULT_IMAGE_TAG }} helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }} values: .github/helm/values/values-lb.yaml wait_for_selector: app=vald-lb-gateway diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 6e6998262e..50ade297f7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -13,16 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: "Run backport PR creation" +name: "Run backport PR" on: pull_request: types: - - "labeled" + - "closed" + +env: + TARGET_LABEL_NAME_PREFIX: "actions/backport/" + BACKPORT_BRANCH_NAME_PREFIX: "backport" jobs: dump-contexts-to-log: runs-on: ubuntu-latest - if: ${{ github.event.action == 'labeled' && startsWith( github.event.label.name, 'actions/backport/' ) }} # e.g.) actions/backport/v1.7 + if: ${{ github.event.pull_request.merged == true }} steps: - uses: actions/checkout@v3 - uses: ./.github/actions/dump-context @@ -30,42 +34,54 @@ jobs: create: runs-on: ubuntu-latest needs: [dump-contexts-to-log] + steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + token: ${{ secrets.DISPATCH_TOKEN }} - name: Set Git config run: | git config --global --add safe.directory ${GITHUB_WORKSPACE} - - name: Set Github context + - uses: crazy-max/ghaction-import-gpg@v4 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + git_user_signingkey: true + git_commit_gpgsign: true + + - name: Set context id: set_context run: | - RELEASE_BASE=`echo "${HOOKED_LABEL_NAME}" | sed -e "s:^${TARGET_LABEL_NAME_PREFIX}::"` # e.g) vx.x - RELEASE_BRANCH_NAME=release/${RELEASE_BASE} # e.g) release/vx.x - BACKPORT_BRANCH_NAME=backport/${RELEASE_BASE}/${GITHUB_HEAD_REF} # e.g) backport/vx.x/{current branch name} - - echo "RELEASE_BASE=${RELEASE_BASE}" >> $GITHUB_OUTPUT - echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" >> $GITHUB_OUTPUT - echo "BACKPORT_BRANCH_NAME=${BACKPORT_BRANCH_NAME}" >> $GITHUB_OUTPUT + LABEL_NAMES=`cat ${GITHUB_EVENT_PATH} | jq -r --arg PREFIX $TARGET_LABEL_NAME_PREFIX '[.pull_request.labels[]? | select(.name | startswith($PREFIX)) | .name] | join(" ")'` - echo "${RELEASE_BASE}" - echo "${RELEASE_BRANCH_NAME}" - echo "${BACKPORT_BRANCH_NAME}" - env: - TARGET_LABEL_NAME_PREFIX: "actions/backport/" - HOOKED_LABEL_NAME: ${{ github.event.label.name }} + echo "LABEL_NAMES=${LABEL_NAMES}" >> $GITHUB_OUTPUT # e.g.) actions/backport/v1.7 actions/backport/v1.8 + echo "${LABEL_NAMES}" - name: Create PR - run: | - git checkout -b ${BACKPORT_BRANCH_NAME} - git push origin ${BACKPORT_BRANCH_NAME} - gh pr create --base ${RELEASE_BRANCH_NAME} \ - --title "Backport to release/${RELEASE_BASE}" \ - --body "" + if: ${{ steps.set_context.outputs.LABEL_NAMES != '' }} env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_BASE: ${{ steps.set_context.outputs.RELEASE_BASE }} - RELEASE_BRANCH_NAME: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME }} - BACKPORT_BRANCH_NAME: ${{ steps.set_context.outputs.BACKPORT_BRANCH_NAME }} + LABEL_NAMES: ${{ steps.set_context.outputs.LABEL_NAMES }} + GITHUB_USER: ${{ secrets.DISPATCH_USER }} + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + run: | + for LABEL_NAME in ${LABEL_NAMES}; do + BRANCH_NAME=`echo "${LABEL_NAME}" | sed -e "s:^${TARGET_LABEL_NAME_PREFIX}::"` # e.g) release/vx.x, main + BACKPORT_BRANCH_NAME="${BACKPORT_BRANCH_NAME_PREFIX}/${BRANCH_NAME}/${GITHUB_HEAD_REF}" # e.g) backport/release/vx.x/{current branch name} + + echo "BRANCH_NAME=${BRANCH_NAME}" + echo "BACKPORT_BRANCH_NAME=${BACKPORT_BRANCH_NAME}" + echo "SHA=${GITHUB_SHA}" + + git checkout ${BRANCH_NAME} + git checkout -b ${BACKPORT_BRANCH_NAME} + + # Force cherry-pick. The conflicts will be modified within the backport PR. + git cherry-pick $GITHUB_SHA || (git add -A && git cherry-pick --continue --no-edit) + git push origin ${BACKPORT_BRANCH_NAME} + + gh pr create --base ${BRANCH_NAME} \ + --title "Backport to ${BRANCH_NAME}" \ + --body-file .github/PULL_REQUEST_TEMPLATE.md + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77f1196a4e..3747222000 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,97 +13,33 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: Run release +name: "Run release" on: - push: + pull_request: branches: - "release/v*.*" - "!release/v*.*.*" + types: + - "closed" jobs: dump-contexts-to-log: + if: >- + ${{ github.event.pull_request.merged == true && startsWith(github.event.head_commit.message, ':bookmark: :robot: Release') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: ./.github/actions/dump-context - detect-ci-container: - uses: ./.github/workflows/_detect-ci-container.yml - secrets: inherit - - semver-auto: - runs-on: ubuntu-latest - outputs: - RELEASE_BRANCH_NAME_SUFFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_SUFFIX }} - RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} - RELEASE: ${{ steps.upgrade_semver.outputs.RELEASE }} - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set Github context - id: set_context - run: | - RELEASE_BRANCH_NAME_SUFFIX=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` - BRANCH_LATEST_TAG=`git tag | grep ${RELEASE_BRANCH_NAME_SUFFIX} | tail -n 1` - RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(major|minor|patch)\].*:\1:p'` - - echo "RELEASE_BRANCH_NAME_SUFFIX=${RELEASE_BRANCH_NAME_SUFFIX}" >> $GITHUB_OUTPUT # e.g) vx.x - echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x or empty - echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor or patch or empty - - echo "${RELEASE_BRANCH_NAME_SUFFIX}" - echo "${BRANCH_LATEST_TAG}" - echo "${RELEASE_KIND}" - - - name: Upgrade semver - id: upgrade_semver - if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }} - env: - RELEASE_BRANCH_NAME_SUFFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_SUFFIX }} - BRANCH_LATEST_TAG: ${{ steps.set_context.outputs.BRANCH_LATEST_TAG }} - RELEASE_KIND: ${{ steps.set_context.outputs.RELEASE_KIND }} - run: | - if [ -z "${BRANCH_LATEST_TAG}" ]; then - case ${RELEASE_KIND} in - major | minor) RELEASE_TAG="${RELEASE_BRANCH_NAME_SUFFIX}.0"; ;; - *) echo "not supported semver kind"; exit 1; ;; - esac - else - IFS=. read -r version minor patch <<< "${BRANCH_LATEST_TAG}" - - case ${RELEASE_KIND} in - patch) RELEASE_TAG="$version.$minor.$((patch+1))"; ;; - *) echo "not supported semver kind"; exit 1; ;; - esac - fi - - if [ `git tag | grep "${RELEASE_TAG}"` ] || [ `cat versions/VALD_VERSION` = "${RELEASE_TAG}" ]; then - echo "release already exists: ${RELEASE_TAG}" - exit 1 - fi - - echo "RELEASE=true" >> $GITHUB_OUTPUT - echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT # e.g) vx.x.x - - echo "${RELEASE_TAG}" - release: needs: - - detect-ci-container - - semver-auto + - dump-contexts-to-log runs-on: ubuntu-latest - if: ${{ needs.semver-auto.outputs.RELEASE == 'true' }} - container: - image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} - env: - RELEASE_BRANCH_NAME: release/${{ needs.semver-auto.outputs.RELEASE_BRANCH_NAME_SUFFIX }} - RELEASE_TAG: ${{ needs.semver-auto.outputs.RELEASE_TAG }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + token: ${{ secrets.DISPATCH_TOKEN }} - name: Set Git config run: | @@ -115,77 +51,33 @@ jobs: git_user_signingkey: true git_commit_gpgsign: true - - name: Update for new release - id: update_for_new_release + - name: Create release tag + id: create_release_tag + env: + GITHUB_USER: ${{ secrets.DISPATCH_USER }} + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} run: | - git checkout ${RELEASE_BRANCH_NAME} - - LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` - PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` - - PREVIOUS_VERSION=`cat versions/VALD_VERSION` - echo "${RELEASE_TAG}" > versions/VALD_VERSION - - sed -i -e "s/^version: .*$/version: ${RELEASE_TAG}/" charts/vald/Chart.yaml - sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${RELEASE_TAG}/" charts/vald/values.yaml - sed -i -e "s/^version: .*$/version: ${RELEASE_TAG}/" charts/vald-helm-operator/Chart.yaml - sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${RELEASE_TAG}/" charts/vald-helm-operator/values.yaml - - make helm/docs/vald - make helm/docs/vald-helm-operator - - make helm/schema/vald - make helm/schema/vald-helm-operator + VERSION=`cat versions/VALD_VERSION` - BODY="" - if [ ! -z "${PR_NUM}" ]; then - BODY=`curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUM}" | jq -r '.body'` - fi - - if [ -z "$BODY" ]; then - BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..${RELEASE_BRANCH_NAME} | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"` - fi - - CHANGELOG=`make changelog/next/print BODY="$BODY"` - make changelog/update BODY="$BODY" - - git add \ - versions/VALD_VERSION \ - charts/vald/Chart.yaml \ - charts/vald/values.yaml \ - charts/vald/values.schema.json \ - charts/vald/README.md \ - charts/vald-helm-operator/Chart.yaml \ - charts/vald-helm-operator/values.yaml \ - charts/vald-helm-operator/values.schema.json \ - charts/vald-helm-operator/README.md \ - CHANGELOG.md - git commit -S --signoff -m ":bookmark: :robot: Release ${RELEASE_TAG}" - - git tag ${RELEASE_TAG} + git tag ${VERSION} git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - git push origin ${RELEASE_BRANCH_NAME} - git push origin ${RELEASE_TAG} - - echo "VERSION=${RELEASE_TAG}" >> $GITHUB_OUTPUT - env: - GITHUB_USER: ${{ secrets.DISPATCH_USER }} - GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + git push origin ${VERSION} + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - name: Create release uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} with: - tag_name: ${{ steps.update_for_new_release.outputs.VERSION }} - name: Release ${{ steps.update_for_new_release.outputs.VERSION }} + tag_name: ${{ steps.create_release_tag.outputs.VERSION }} + name: Release ${{ steps.create_release_tag.outputs.VERSION }} body: | - See [CHANGELOG.md](https://github.com/vdaas/vald/blob/${{ steps.update_for_new_release.outputs.VERSION }}/CHANGELOG.md) for details. + See [CHANGELOG.md](https://github.com/vdaas/vald/blob/${{ steps.create_release_tag.outputs.VERSION }}/CHANGELOG.md) for details. draft: false prerelease: false - name: Add the version to goproxy run: | - curl "https://proxy.golang.org/github.com/vdaas/vald/@v/${{ steps.update_for_new_release.outputs.VERSION }}.info" + curl "https://proxy.golang.org/github.com/vdaas/vald/@v/${{ steps.create_release_tag.outputs.VERSION }}.info" diff --git a/.github/workflows/semver-major-minor.yaml b/.github/workflows/semver-major-minor.yaml new file mode 100644 index 0000000000..ff147bd3df --- /dev/null +++ b/.github/workflows/semver-major-minor.yaml @@ -0,0 +1,109 @@ +# +# Copyright (C) 2019-2023 vdaas.org vald team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +name: "Run [major/minor] Release" +on: + push: + branches: + - "main" +env: + BACKPORT_LABEL_PREFIX: "actions/backport/" + +jobs: + dump-contexts-to-log: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/dump-context + + semver-auto: + runs-on: ubuntu-latest + needs: [dump-contexts-to-log] + outputs: + RELEASE_BRANCH_NAME: ${{ steps.upgrade_semver.outputs.RELEASE_BRANCH_NAME }} + RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} + RELEASE: ${{ steps.setup_for_release.outputs.RELEASE }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.DISPATCH_TOKEN }} + + - name: Set Git config + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + + - name: Set context + id: set_context + run: | + LATEST_TAG=`git tag --sort=v:refname | tail -n 1` + UNSUPPORTED_VERSION=`git tag --sort=v:refname | sed -E 's/^v([0-9]+\.[0-9]+).*$/v\1/' | uniq | tail -n 2 | head -n 1` + RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(major|minor)\].*:\1:p'` + + echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) v1.7.6 + echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor + echo "UNSUPPORTED_VERSION=${UNSUPPORTED_VERSION}" >> $GITHUB_OUTPUT # e.g) v1.6 + + echo "LATEST_TAG=${LATEST_TAG}" + echo "RELEASE_KIND=${RELEASE_KIND}" + echo "UNSUPPORTED_VERSION=${UNSUPPORTED_VERSION}" + + - name: Upgrade semver + id: upgrade_semver + if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }} + env: + LATEST_TAG: ${{ steps.set_context.outputs.LATEST_TAG }} + RELEASE_KIND: ${{ steps.set_context.outputs.RELEASE_KIND }} + run: | + IFS=. read -r version minor patch <<< `echo "${LATEST_TAG}" | sed -e 's:^v::'` # e.g) version=1, minor=7, patch=7 + + case ${RELEASE_KIND} in + major) RELEASE_TAG="v$((version+1)).0.0"; RELEASE_BRANCH_NAME="release/v$((version+1)).0"; ;; + minor) RELEASE_TAG="v$version.$((minor+1)).0"; RELEASE_BRANCH_NAME="release/v$version.$((minor+1))"; ;; + *) echo "no need to update"; exit 0; ;; + esac + + echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_OUTPUT + echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" >> $GITHUB_OUTPUT + + echo "RELEASE_TAG=${RELEASE_TAG}" + echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" + + - name: Setup for release + id: setup_for_release + if: ${{ steps.upgrade_semver.outputs.RELEASE_TAG != '' }} + env: + RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} + RELEASE_BRANCH_NAME: ${{ steps.upgrade_semver.outputs.RELEASE_BRANCH_NAME }} + GITHUB_USER: ${{ secrets.DISPATCH_USER }} + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + run: | + git checkout -b ${RELEASE_BRANCH_NAME} && git push origin ${RELEASE_BRANCH_NAME} + gh label create "${BACKPORT_LABEL_PREFIX}${RELEASE_BRANCH_NAME}" # e.g) actions/backport/release/v1.8 + + echo "RELEASE=true" >> $GITHUB_OUTPUT + echo "RELEASE_TAG=${RELEASE_TAG}" + echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" + echo "LABEL_NAME=${BACKPORT_LABEL_PREFIX}${RELEASE_BRANCH_NAME}" + + release-pr: + if: ${{ needs.semver-auto.outputs.RELEASE == 'true' }} + needs: + - semver-auto + uses: ./.github/workflows/_release-pr.yml + with: + release_branch_name: ${{ needs.semver-auto.outputs.RELEASE_BRANCH_NAME }} + release_tag: ${{ needs.semver-auto.outputs.RELEASE_TAG }} + secrets: inherit diff --git a/.github/workflows/semver-patch.yaml b/.github/workflows/semver-patch.yaml new file mode 100644 index 0000000000..d0b4d2ed1c --- /dev/null +++ b/.github/workflows/semver-patch.yaml @@ -0,0 +1,83 @@ +# +# Copyright (C) 2019-2023 vdaas.org vald team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +name: "Run [patch] release" +on: + push: + branches: + - "release/v*.*" + - "!release/v*.*.*" + +jobs: + dump-contexts-to-log: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/dump-context + + semver-auto: + runs-on: ubuntu-latest + outputs: + RELEASE_BRANCH_NAME_SUFFIX: ${{ steps.set_context.outputs.RELEASE_BRANCH_NAME_SUFFIX }} + RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }} + RELEASE: ${{ steps.upgrade_semver.outputs.RELEASE }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set context + id: set_context + run: | + RELEASE_BRANCH_NAME_SUFFIX=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` + BRANCH_LATEST_TAG=`git tag --sort=v:refname | grep ${RELEASE_BRANCH_NAME_SUFFIX} | tail -n 1` + RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(patch)\].*:\1:p'` + + echo "RELEASE_BRANCH_NAME_SUFFIX=${RELEASE_BRANCH_NAME_SUFFIX}" >> $GITHUB_OUTPUT # e.g) vx.x + echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x or empty + echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) patch or empty + + echo "RELEASE_BRANCH_NAME_SUFFIX=${RELEASE_BRANCH_NAME_SUFFIX}" + echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" + echo "RELEASE_KIND=${RELEASE_KIND}" + + - name: Upgrade semver + id: upgrade_semver + if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }} + env: + BRANCH_LATEST_TAG: ${{ steps.set_context.outputs.BRANCH_LATEST_TAG }} + RELEASE_KIND: ${{ steps.set_context.outputs.RELEASE_KIND }} + run: | + IFS=. read -r version minor patch <<< "${BRANCH_LATEST_TAG}" # e.g) version=v1, minor=7, patch=7 + + case ${RELEASE_KIND} in + patch) RELEASE_TAG="$version.$minor.$((patch+1))"; ;; + *) echo "not supported semver kind"; exit 1; ;; + esac + + echo "RELEASE=true" >> $GITHUB_OUTPUT + echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x + + echo "RELEASE_TAG=${RELEASE_TAG}" + + release-pr: + if: ${{ needs.semver-auto.outputs.RELEASE == 'true' }} + needs: + - semver-auto + uses: ./.github/workflows/_release-pr.yml + with: + release_branch_name: "release/${{ needs.semver-auto.outputs.RELEASE_BRANCH_NAME_SUFFIX }}" + release_tag: ${{ needs.semver-auto.outputs.RELEASE_TAG }} + secrets: inherit diff --git a/.github/workflows/semver.yml b/.github/workflows/semver.yml deleted file mode 100644 index cfac7c7b1a..0000000000 --- a/.github/workflows/semver.yml +++ /dev/null @@ -1,156 +0,0 @@ -# -# Copyright (C) 2019-2023 vdaas.org vald team -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# You may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -name: Run semver -on: - push: - branches: - - main -jobs: - dump-contexts-to-log: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/dump-context - semver-auto: - name: Run semver-auto - runs-on: ubuntu-latest - container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - token: ${{ secrets.DISPATCH_TOKEN }} - - name: Set Git config - run: | - git config --global --add safe.directory ${GITHUB_WORKSPACE} - - uses: crazy-max/ghaction-import-gpg@v4 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - git_user_signingkey: true - git_commit_gpgsign: true - - name: Get latest gitwerk - run: | - curl -fsSLO \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - https://github.com/rinx/gitwerk/releases/latest/download/gitwerk-linux-amd64.zip - unzip gitwerk-linux-amd64.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Run gitwerk semver-auto - id: semver - run: | - GITWERK_RESULT=`./gitwerk --stdin sv << EOF - (defn sv [] - (let [repo (git/repo ".") - message (-> repo - (git/latest-log) - :full-message) - tag (or (-> repo - (git/tags) - (semver/latest-tag)) - (semver/default-version-str)) - new-tag (semver/contextual-semver message tag)] - (if (not (= tag new-tag)) - new-tag - "not-updated"))) - EOF` - if [ "${GITWERK_RESULT}" = "not-updated" ]; then - echo "version not updated" - exit 0 - fi - echo "version updated: ${GITWERK_RESULT}" - - git checkout main - - LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` - PR_NUM=`echo "$LAST_COMMIT_MESSAGE" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` - - PREVIOUS_VERSION=`cat versions/VALD_VERSION` - - echo "${GITWERK_RESULT}" > versions/VALD_VERSION - - sed -i -e "s/^version: .*$/version: ${GITWERK_RESULT}/" charts/vald/Chart.yaml - sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${GITWERK_RESULT}/" charts/vald/values.yaml - sed -i -e "s/^version: .*$/version: ${GITWERK_RESULT}/" charts/vald-helm-operator/Chart.yaml - sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${GITWERK_RESULT}/" charts/vald-helm-operator/values.yaml - - make helm/schema/vald - make helm/schema/vald-helm-operator - make helm/schema/crd/vald - make helm/schema/crd/vald-helm-operator - make k8s/manifest/update - make k8s/manifest/helm-operator/update - make helm/docs/vald - make helm/docs/vald-helm-operator - - BODY="" - if [ ! -z "${PR_NUM}" ]; then - BODY=`curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUM}" | jq -r '.body'` - fi - - if [ -z "$BODY" ]; then - BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..main | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"` - fi - - CHANGELOG=`make changelog/next/print BODY="$BODY"` - make changelog/update BODY="$BODY" - - make format - - git add \ - CHANGELOG.md \ - charts/vald-helm-operator/Chart.yaml \ - charts/vald-helm-operator/README.md \ - charts/vald-helm-operator/values.schema.json \ - charts/vald-helm-operator/values.yaml \ - charts/vald/Chart.yaml \ - charts/vald/README.md \ - charts/vald/values.schema.json \ - charts/vald/values.yaml \ - k8s \ - versions/VALD_VERSION - - git commit -S --signoff -m ":bookmark: :robot: Release ${GITWERK_RESULT}" - - git tag ${GITWERK_RESULT} - - git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - - git push origin main - git push origin ${GITWERK_RESULT} - - echo "RELEASE=true" >> $GITHUB_OUTPUT - echo "VERSION=${GITWERK_RESULT}" >> $GITHUB_OUTPUT - env: - GITHUB_USER: ${{ secrets.DISPATCH_USER }} - GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} - - name: Create release - if: steps.semver.outputs.RELEASE == 'true' - id: create_release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} - with: - tag_name: ${{ steps.semver.outputs.VERSION }} - release_name: Release ${{ steps.semver.outputs.VERSION }} - body: | - See [CHANGELOG.md](https://github.com/vdaas/vald/blob/${{ steps.semver.outputs.VERSION }}/CHANGELOG.md) for details. - draft: false - prerelease: false - - name: Add the version to goproxy - run: | - curl "https://proxy.golang.org/github.com/vdaas/vald/@v/${{ steps.semver.outputs.VERSION }}.info" From e1a1749688da532854456e4df670c31059d0a5d2 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Wed, 20 Sep 2023 14:09:25 +0900 Subject: [PATCH 24/33] add space to improve readability Signed-off-by: hlts2 --- .github/actions/deploy-chaos-mesh/action.yaml | 3 +++ .github/actions/setup-e2e/action.yaml | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/deploy-chaos-mesh/action.yaml b/.github/actions/deploy-chaos-mesh/action.yaml index 40cb61c580..fd6b60d014 100644 --- a/.github/actions/deploy-chaos-mesh/action.yaml +++ b/.github/actions/deploy-chaos-mesh/action.yaml @@ -36,15 +36,18 @@ runs: echo "version=${CHAOS_MESH_VERSION}" >> $GITHUB_OUTPUT env: CHAOS_MESH_VERSION: ${{ inputs.chaos_mesh_version }} + - name: Check k3d shell: bash id: check_k3d run: | kubectl cluster-info dump + - name: Check Helm shell: bash run: | helm version + - name: Deploy Chaos Mesh shell: bash run: | diff --git a/.github/actions/setup-e2e/action.yaml b/.github/actions/setup-e2e/action.yaml index c5af540b45..febac602f4 100644 --- a/.github/actions/setup-e2e/action.yaml +++ b/.github/actions/setup-e2e/action.yaml @@ -40,10 +40,7 @@ inputs: target_images: description: "Image names" required: false - default: "vdaas/vald-agent-ngt \ - vdaas/vald-discoverer-k8s \ - vdaas/vald-lb-gateway \ - vdaas/vald-manager-index" + default: "vdaas/vald-agent-ngt vdaas/vald-discoverer-k8s vdaas/vald-lb-gateway vdaas/vald-manager-index" outputs: HELM_EXTRA_OPTIONS: From 82e66ee5883a2aab571a24c4524e361b91e1d046 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Wed, 20 Sep 2023 14:11:34 +0900 Subject: [PATCH 25/33] deleted unnecessary line Signed-off-by: hlts2 --- .github/workflows/_release-pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/_release-pr.yml b/.github/workflows/_release-pr.yml index 1f85113629..4ad038e3fb 100644 --- a/.github/workflows/_release-pr.yml +++ b/.github/workflows/_release-pr.yml @@ -126,7 +126,6 @@ jobs: --request POST \ --data "{\"title\": \"Release ${RELEASE_TAG}\", \"head\": \"${PREPARE_RELEASE_BRANCH_NAME}\", \"base\": \"${RELEASE_BRANCH_NAME}\", \"body\": \"Release PR for ${RELEASE_TAG}.\", \"maintainer_can_modify\": true}" \ $API_URL - env: GITHUB_USER: ${{ secrets.DISPATCH_USER }} GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} From bfe2f726d29b96f41b6ed1975e7ceec15f0c526e Mon Sep 17 00:00:00 2001 From: hlts2 Date: Wed, 20 Sep 2023 18:19:44 +0900 Subject: [PATCH 26/33] bugfix github object error for release pr Signed-off-by: hlts2 --- .github/workflows/_release-pr.yml | 3 ++- .github/workflows/release.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_release-pr.yml b/.github/workflows/_release-pr.yml index 4ad038e3fb..3e3ac9be70 100644 --- a/.github/workflows/_release-pr.yml +++ b/.github/workflows/_release-pr.yml @@ -124,8 +124,9 @@ jobs: -H "Content-Type:application/json" \ -H "Authorization: token ${GITHUB_TOKEN}" \ --request POST \ - --data "{\"title\": \"Release ${RELEASE_TAG}\", \"head\": \"${PREPARE_RELEASE_BRANCH_NAME}\", \"base\": \"${RELEASE_BRANCH_NAME}\", \"body\": \"Release PR for ${RELEASE_TAG}.\", \"maintainer_can_modify\": true}" \ + --data "{\"title\": \":bookmark: :robot: Release ${RELEASE_TAG}\", \"head\": \"${PREPARE_RELEASE_BRANCH_NAME}\", \"base\": \"${RELEASE_BRANCH_NAME}\", \"body\": \"Release PR for ${RELEASE_TAG}.\", \"maintainer_can_modify\": true}" \ $API_URL + env: GITHUB_USER: ${{ secrets.DISPATCH_USER }} GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3747222000..b5ac7a3450 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ on: jobs: dump-contexts-to-log: if: >- - ${{ github.event.pull_request.merged == true && startsWith(github.event.head_commit.message, ':bookmark: :robot: Release') }} + ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, ':bookmark: :robot: Release') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 40f72912ce4630f8231eca0a4c3226dec8e0ae3b Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 25 Sep 2023 17:19:33 +0900 Subject: [PATCH 27/33] add cluster-info dump Signed-off-by: hlts2 --- .github/actions/setup-e2e/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-e2e/action.yaml b/.github/actions/setup-e2e/action.yaml index febac602f4..46efd9b433 100644 --- a/.github/actions/setup-e2e/action.yaml +++ b/.github/actions/setup-e2e/action.yaml @@ -97,4 +97,4 @@ runs: - name: Check Kubernetes cluster shell: bash run: | - kubectl cluster-info + kubectl cluster-info dump From 095bae9d7bb191a8635865881041cca0da142bd9 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 26 Sep 2023 17:37:07 +0900 Subject: [PATCH 28/33] change workflow name Signed-off-by: hlts2 --- .github/workflows/{pr.yaml => backport.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{pr.yaml => backport.yml} (100%) diff --git a/.github/workflows/pr.yaml b/.github/workflows/backport.yml similarity index 100% rename from .github/workflows/pr.yaml rename to .github/workflows/backport.yml From c386808abf8c5409258bfcb7dca1855b46486248 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 24 Oct 2023 14:51:17 +0900 Subject: [PATCH 29/33] fix: apply latest workflow changes and fix actionlint warning Signed-off-by: hlts2 --- .github/workflows/_update-protobuf.yaml | 1 - .github/workflows/chatops.yml | 2 +- .github/workflows/format.yml | 9 +++++++-- .github/workflows/semver-major-minor.yaml | 2 +- .github/workflows/semver-patch.yaml | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/_update-protobuf.yaml b/.github/workflows/_update-protobuf.yaml index 2d99b952ff..74f7f75b00 100644 --- a/.github/workflows/_update-protobuf.yaml +++ b/.github/workflows/_update-protobuf.yaml @@ -21,7 +21,6 @@ on: type: string description: "Dispatch target repository" required: true - default: "" jobs: dispatch: diff --git a/.github/workflows/chatops.yml b/.github/workflows/chatops.yml index 9e7b714ced..c42ecc2854 100644 --- a/.github/workflows/chatops.yml +++ b/.github/workflows/chatops.yml @@ -358,7 +358,7 @@ jobs: git_commit_gpgsign: true - uses: ./.github/actions/setup-go - if: steps.check_comments_gen_test.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' + if: steps.check_comments_format.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' - name: update and push id: format_push diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 620d1a31ea..2975b7aad9 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -27,11 +27,15 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/dump-context + detect-ci-container: + uses: ./.github/workflows/_detect-ci-container.yml + format: if: ${{ github.event_name == 'push' }} runs-on: ubuntu-latest + needs: [detect-ci-container] container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} steps: - uses: actions/checkout@v3 with: @@ -95,8 +99,9 @@ jobs: check-format-diff: if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false }} runs-on: ubuntu-latest + needs: [detect-ci-container] container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG_NAME }} steps: - uses: actions/checkout@v3 with: diff --git a/.github/workflows/semver-major-minor.yaml b/.github/workflows/semver-major-minor.yaml index ff147bd3df..52ce068e68 100644 --- a/.github/workflows/semver-major-minor.yaml +++ b/.github/workflows/semver-major-minor.yaml @@ -50,7 +50,7 @@ jobs: run: | LATEST_TAG=`git tag --sort=v:refname | tail -n 1` UNSUPPORTED_VERSION=`git tag --sort=v:refname | sed -E 's/^v([0-9]+\.[0-9]+).*$/v\1/' | uniq | tail -n 2 | head -n 1` - RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(major|minor)\].*:\1:p'` + RELEASE_KIND=`git log --pretty=format:%s -1 | sed -n -E 's:^\[(major|minor)\].*:\1:p'` echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) v1.7.6 echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor diff --git a/.github/workflows/semver-patch.yaml b/.github/workflows/semver-patch.yaml index d0b4d2ed1c..b362de53a6 100644 --- a/.github/workflows/semver-patch.yaml +++ b/.github/workflows/semver-patch.yaml @@ -43,7 +43,7 @@ jobs: run: | RELEASE_BRANCH_NAME_SUFFIX=`echo '${{ github.ref }}' | sed -e 's:^refs/heads/release/::'` BRANCH_LATEST_TAG=`git tag --sort=v:refname | grep ${RELEASE_BRANCH_NAME_SUFFIX} | tail -n 1` - RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(patch)\].*:\1:p'` + RELEASE_KIND=`git log --pretty=format:%s -1 | sed -n -E 's:^\[(patch)\].*:\1:p'` echo "RELEASE_BRANCH_NAME_SUFFIX=${RELEASE_BRANCH_NAME_SUFFIX}" >> $GITHUB_OUTPUT # e.g) vx.x echo "BRANCH_LATEST_TAG=${BRANCH_LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) vx.x.x or empty From e45d41f7cf4a37b67e2f087e3148bebddefb7338 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 7 Dec 2023 15:33:37 +0900 Subject: [PATCH 30/33] fix: add new line for readability Signed-off-by: hlts2 --- .github/actions/docker-build/action.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/docker-build/action.yaml b/.github/actions/docker-build/action.yaml index be53a2b784..f7adfe7870 100644 --- a/.github/actions/docker-build/action.yaml +++ b/.github/actions/docker-build/action.yaml @@ -15,6 +15,7 @@ # name: "Build Docker images" description: "A action to build Docker images and publish them" + inputs: target: description: "Build target" @@ -44,6 +45,7 @@ outputs: EXTRA_TAGS: description: "Extra tags" value: ${{ steps.add_extra_tags.outputs.EXTRA_TAGS }} + runs: using: "composite" steps: @@ -60,9 +62,11 @@ runs: echo "ALTER_IMAGE_NAME=${alter_image_name}" >> $GITHUB_OUTPUT env: TARGET: ${{ inputs.target }} + - name: Determine tag name id: determine_tag_name uses: ./.github/actions/determine-docker-image-tag + - name: Determine platforms shell: bash id: determine_platforms @@ -82,6 +86,7 @@ runs: echo "PLATFORMS=${platforms}" >> $GITHUB_OUTPUT env: TARGET_PLATFORMS: ${{ inputs.platforms }} + - name: Add extra tags shell: bash id: add_extra_tags @@ -97,6 +102,7 @@ runs: IMAGE_NAME: ${{ steps.image_name.outputs.IMAGE_NAME }} ALTER_IMAGE_NAME: ${{ steps.image_name.outputs.ALTER_IMAGE_NAME }} PRIMARY_TAG: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }} + - name: Build and Push shell: bash id: build_and_push From 4ccfc7c493f4409835515d1a24aa8eebdfedf8f3 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 12 Dec 2023 11:22:53 +0900 Subject: [PATCH 31/33] fix: deleted unnecessary file Signed-off-by: hlts2 --- .github/workflows/semver.yml | 156 ----------------------------------- 1 file changed, 156 deletions(-) delete mode 100644 .github/workflows/semver.yml diff --git a/.github/workflows/semver.yml b/.github/workflows/semver.yml deleted file mode 100644 index e5669f439f..0000000000 --- a/.github/workflows/semver.yml +++ /dev/null @@ -1,156 +0,0 @@ -# -# Copyright (C) 2019-2023 vdaas.org vald team -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# You may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -name: Run semver -on: - push: - branches: - - main -jobs: - dump-contexts-to-log: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/dump-context - semver-auto: - name: Run semver-auto - runs-on: ubuntu-latest - container: - image: ghcr.io/vdaas/vald/vald-ci-container:nightly - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.DISPATCH_TOKEN }} - - name: Set Git config - run: | - git config --global --add safe.directory ${GITHUB_WORKSPACE} - - uses: crazy-max/ghaction-import-gpg@v4 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - git_user_signingkey: true - git_commit_gpgsign: true - - name: Get latest gitwerk - run: | - curl -fsSLO \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - https://github.com/rinx/gitwerk/releases/latest/download/gitwerk-linux-amd64.zip - unzip gitwerk-linux-amd64.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Run gitwerk semver-auto - id: semver - run: | - GITWERK_RESULT=`./gitwerk --stdin sv << EOF - (defn sv [] - (let [repo (git/repo ".") - message (-> repo - (git/latest-log) - :full-message) - tag (or (-> repo - (git/tags) - (semver/latest-tag)) - (semver/default-version-str)) - new-tag (semver/contextual-semver message tag)] - (if (not (= tag new-tag)) - new-tag - "not-updated"))) - EOF` - if [ "${GITWERK_RESULT}" = "not-updated" ]; then - echo "version not updated" - exit 0 - fi - echo "version updated: ${GITWERK_RESULT}" - - git checkout main - - LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1` - PR_NUM=`echo "$LAST_COMMIT_MESSAGE" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1` - - PREVIOUS_VERSION=`cat versions/VALD_VERSION` - - echo "${GITWERK_RESULT}" > versions/VALD_VERSION - - sed -i -e "s/^version: .*$/version: ${GITWERK_RESULT}/" charts/vald/Chart.yaml - sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${GITWERK_RESULT}/" charts/vald/values.yaml - sed -i -e "s/^version: .*$/version: ${GITWERK_RESULT}/" charts/vald-helm-operator/Chart.yaml - sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${GITWERK_RESULT}/" charts/vald-helm-operator/values.yaml - - make helm/schema/vald - make helm/schema/vald-helm-operator - make helm/schema/crd/vald - make helm/schema/crd/vald-helm-operator - make k8s/manifest/update - make k8s/manifest/helm-operator/update - make helm/docs/vald - make helm/docs/vald-helm-operator - - BODY="" - if [ ! -z "${PR_NUM}" ]; then - BODY=`curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUM}" | jq -r '.body'` - fi - - if [ -z "$BODY" ]; then - BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..main | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"` - fi - - CHANGELOG=`make changelog/next/print BODY="$BODY"` - make changelog/update BODY="$BODY" - - make format - - git add \ - CHANGELOG.md \ - charts/vald-helm-operator/Chart.yaml \ - charts/vald-helm-operator/README.md \ - charts/vald-helm-operator/values.schema.json \ - charts/vald-helm-operator/values.yaml \ - charts/vald/Chart.yaml \ - charts/vald/README.md \ - charts/vald/values.schema.json \ - charts/vald/values.yaml \ - k8s \ - versions/VALD_VERSION - - git commit -S --signoff -m ":bookmark: :robot: Release ${GITWERK_RESULT}" - - git tag ${GITWERK_RESULT} - - git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - - git push origin main - git push origin ${GITWERK_RESULT} - - echo "RELEASE=true" >> $GITHUB_OUTPUT - echo "VERSION=${GITWERK_RESULT}" >> $GITHUB_OUTPUT - env: - GITHUB_USER: ${{ secrets.DISPATCH_USER }} - GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} - - name: Create release - if: steps.semver.outputs.RELEASE == 'true' - id: create_release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} - with: - tag_name: ${{ steps.semver.outputs.VERSION }} - release_name: Release ${{ steps.semver.outputs.VERSION }} - body: | - See [CHANGELOG.md](https://github.com/vdaas/vald/blob/${{ steps.semver.outputs.VERSION }}/CHANGELOG.md) for details. - draft: false - prerelease: false - - name: Add the version to goproxy - run: | - curl "https://proxy.golang.org/github.com/vdaas/vald/@v/${{ steps.semver.outputs.VERSION }}.info" From cf93296bfedabd70083b4acd7d2496338bc424b4 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 12 Dec 2023 11:33:51 +0900 Subject: [PATCH 32/33] feat: add release branch image creation logic for new component Signed-off-by: hlts2 --- .github/workflows/_docker-image-scan.yaml | 3 ++ .github/workflows/_docker-image.yaml | 11 ++++ .github/workflows/dockers-image-scan.yml | 14 ++++++ .../dockers-release-branch-image.yaml | 50 +++++++++++++++---- 4 files changed, 67 insertions(+), 11 deletions(-) diff --git a/.github/workflows/_docker-image-scan.yaml b/.github/workflows/_docker-image-scan.yaml index d71c6cdf2f..89d90501ae 100644 --- a/.github/workflows/_docker-image-scan.yaml +++ b/.github/workflows/_docker-image-scan.yaml @@ -26,9 +26,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set Git config run: | git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Build the Docker image id: build_image run: | @@ -45,6 +47,7 @@ jobs: TARGET: ${{ inputs.target }} LABEL_OPTS: "--label org.opencontainers.image.url=${{ github.event.repository.html_url }} --label org.opencontainers.image.source=${{ github.event.repository.html_url }} --label org.opencontainers.image.revision=${{ github.sha }}" PRIMARY_TAG: ${{ github.sha }} + - name: Scan the Docker image uses: ./.github/actions/scan-docker-image with: diff --git a/.github/workflows/_docker-image.yaml b/.github/workflows/_docker-image.yaml index 3f7ce3d9c0..aa6ca00e8c 100644 --- a/.github/workflows/_docker-image.yaml +++ b/.github/workflows/_docker-image.yaml @@ -26,9 +26,11 @@ on: description: "If it is specified, specified platforms will be used." required: false default: "" + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref != 'refs/heads/main' && github.ref || github.sha }}-${{ github.event_name }}-${{ inputs.target }} cancel-in-progress: true + jobs: dump-contexts-to-log: runs-on: ubuntu-latest @@ -53,17 +55,21 @@ jobs: else echo ref=${{ github.sha }} >> $GITHUB_OUTPUT fi + - uses: actions/checkout@v4 with: ref: ${{ steps.ref.outputs.ref }} + - name: Set Git config run: | git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Setup QEMU uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:master platforms: linux/amd64,linux/arm64 + - name: Setup Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 @@ -74,11 +80,13 @@ jobs: image=moby/buildkit:master network=host buildkitd-flags: "--debug --oci-worker-gc=false" + - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USER }} password: ${{ secrets.DOCKERHUB_PASS }} + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -87,6 +95,7 @@ jobs: # password: ${{ secrets.GITHUB_TOKEN }} username: ${{ secrets.PACKAGE_USER }} password: ${{ secrets.PACKAGE_TOKEN }} + - name: Build and Publish id: build_and_publish uses: ./.github/actions/docker-build @@ -94,6 +103,7 @@ jobs: target: ${{ inputs.target }} platforms: ${{ inputs.platforms }} builder: ${{ steps.buildx.outputs.name }} + - name: Scan the Docker image if: startsWith( github.ref, 'refs/tags/') uses: ./.github/actions/scan-docker-image @@ -105,6 +115,7 @@ jobs: if: github.ref == 'refs/heads/main' || startsWith( github.ref, 'refs/tags/') steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/notify-slack with: author_name: ${{ inputs.target }} image build diff --git a/.github/workflows/dockers-image-scan.yml b/.github/workflows/dockers-image-scan.yml index 44414247c4..f229ec4ba9 100644 --- a/.github/workflows/dockers-image-scan.yml +++ b/.github/workflows/dockers-image-scan.yml @@ -26,58 +26,72 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/dump-context + agent-ngt: uses: ./.github/workflows/_docker-image-scan.yaml with: target: agent-ngt + agent-sidecar: uses: ./.github/workflows/_docker-image-scan.yaml with: target: agent-sidecar + ci-container: uses: ./.github/workflows/_docker-image-scan.yaml with: target: ci-container + dev-container: uses: ./.github/workflows/_docker-image-scan.yaml with: target: dev-container + discoverer-k8s: uses: ./.github/workflows/_docker-image-scan.yaml with: target: discoverer-k8s + gateway-lb: uses: ./.github/workflows/_docker-image-scan.yaml with: target: gateway-lb + gateway-filter: uses: ./.github/workflows/_docker-image-scan.yaml with: target: gateway-filter + index-correction: uses: ./.github/workflows/_docker-image-scan.yaml with: target: index-correction + index-creation: uses: ./.github/workflows/_docker-image-scan.yaml with: target: index-creation + index-save: uses: ./.github/workflows/_docker-image-scan.yaml with: target: index-save + loadtest: uses: ./.github/workflows/_docker-image-scan.yaml with: target: loadtest + manager-index: uses: ./.github/workflows/_docker-image-scan.yaml with: target: manager-index + operator-helm: uses: ./.github/workflows/_docker-image-scan.yaml with: target: operator/helm + readreplica-rotate: uses: ./.github/workflows/_docker-image-scan.yaml with: diff --git a/.github/workflows/dockers-release-branch-image.yaml b/.github/workflows/dockers-release-branch-image.yaml index 7905dd6c16..a28819e0ad 100644 --- a/.github/workflows/dockers-release-branch-image.yaml +++ b/.github/workflows/dockers-release-branch-image.yaml @@ -42,6 +42,14 @@ jobs: target: agent-sidecar secrets: inherit + ci-container: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: ci-container + platforms: linux/amd64 + secrets: inherit + discoverer-k8s: needs: [dump-contexts-to-log] uses: ./.github/workflows/_docker-image.yaml @@ -49,32 +57,39 @@ jobs: target: discoverer-k8s secrets: inherit - manager-index: + gateway-lb: needs: [dump-contexts-to-log] uses: ./.github/workflows/_docker-image.yaml with: - target: manager-index + target: gateway-lb secrets: inherit - operator-helm: + gateway-filter: needs: [dump-contexts-to-log] uses: ./.github/workflows/_docker-image.yaml with: - target: operator/helm + target: gateway-filter secrets: inherit - gateway-lb: + index-correction: needs: [dump-contexts-to-log] uses: ./.github/workflows/_docker-image.yaml with: - target: gateway-lb + target: index-correction secrets: inherit - gateway-filter: + index-creation: needs: [dump-contexts-to-log] uses: ./.github/workflows/_docker-image.yaml with: - target: gateway-filter + target: index-creation + secrets: inherit + + index-save: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: index-save secrets: inherit loadtest: @@ -85,10 +100,23 @@ jobs: platforms: linux/amd64 secrets: inherit - ci-container: + manager-index: needs: [dump-contexts-to-log] uses: ./.github/workflows/_docker-image.yaml with: - target: ci-container - platforms: linux/amd64 + target: manager-index + secrets: inherit + + operator-helm: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: operator/helm + secrets: inherit + + readreplica-rotate: + needs: [dump-contexts-to-log] + uses: ./.github/workflows/_docker-image.yaml + with: + target: readreplica-rotate secrets: inherit From 3d12458717d1f2731c981084cd5820e5cde614fc Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 9 Jan 2024 11:35:47 +0900 Subject: [PATCH 33/33] fix: execute make format to update license Signed-off-by: hlts2 --- .github/workflows/_detect-ci-container.yml | 2 +- .github/workflows/_release-pr.yml | 2 +- .github/workflows/backport.yml | 2 +- .github/workflows/dockers-release-branch-image.yaml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/semver-major-minor.yaml | 2 +- .github/workflows/semver-patch.yaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/_detect-ci-container.yml b/.github/workflows/_detect-ci-container.yml index a7005ef344..4b70527e17 100644 --- a/.github/workflows/_detect-ci-container.yml +++ b/.github/workflows/_detect-ci-container.yml @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 vdaas.org vald team +# Copyright (C) 2019-2024 vdaas.org vald team # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. diff --git a/.github/workflows/_release-pr.yml b/.github/workflows/_release-pr.yml index 3e3ac9be70..369813b220 100644 --- a/.github/workflows/_release-pr.yml +++ b/.github/workflows/_release-pr.yml @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 vdaas.org vald team +# Copyright (C) 2019-2024 vdaas.org vald team # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 50ade297f7..5bad8d1dcd 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 vdaas.org vald team +# Copyright (C) 2019-2024 vdaas.org vald team # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. diff --git a/.github/workflows/dockers-release-branch-image.yaml b/.github/workflows/dockers-release-branch-image.yaml index a28819e0ad..56a29a7c1e 100644 --- a/.github/workflows/dockers-release-branch-image.yaml +++ b/.github/workflows/dockers-release-branch-image.yaml @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 vdaas.org vald team +# Copyright (C) 2019-2024 vdaas.org vald team # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b5ac7a3450..e6129f6fa3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 vdaas.org vald team +# Copyright (C) 2019-2024 vdaas.org vald team # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. diff --git a/.github/workflows/semver-major-minor.yaml b/.github/workflows/semver-major-minor.yaml index 52ce068e68..70791df5fd 100644 --- a/.github/workflows/semver-major-minor.yaml +++ b/.github/workflows/semver-major-minor.yaml @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 vdaas.org vald team +# Copyright (C) 2019-2024 vdaas.org vald team # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. diff --git a/.github/workflows/semver-patch.yaml b/.github/workflows/semver-patch.yaml index b362de53a6..9164d0dbde 100644 --- a/.github/workflows/semver-patch.yaml +++ b/.github/workflows/semver-patch.yaml @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 vdaas.org vald team +# Copyright (C) 2019-2024 vdaas.org vald team # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License.