remove pike (#10761) #819
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
validate: | |
type: boolean | |
default: false | |
description: "Validate the release artifacts" | |
version: | |
type: string | |
required: false | |
description: "Override the default version (e.g. v0.0.0-manual-<git-sha>)" | |
push: | |
tags: | |
- 'v*' | |
- '!v2.0.0-main' | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
setup: | |
name: Setup release inputs | |
runs-on: ubuntu-22.04 | |
outputs: | |
version: ${{ steps.set_vars.outputs.version }} | |
goreleaser_args: ${{ steps.set_vars.outputs.goreleaser_args }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set the release related variables | |
id: set_vars | |
run: | | |
set -x | |
GIT_SHA=$(git rev-parse --short HEAD) | |
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -e "s/\//-/g") | |
# Set version based on event type | |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then | |
if [[ -n "${{ inputs.version }}" ]]; then | |
VERSION="${{ inputs.version }}" | |
else | |
VERSION="v0.0.0-manual-${GIT_SHA}" | |
fi | |
echo "goreleaser_args=--clean --skip=validate" >> $GITHUB_OUTPUT | |
elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION="${GITHUB_REF#refs/tags/}" | |
echo "goreleaser_args=--clean" >> $GITHUB_OUTPUT | |
elif [[ $GITHUB_REF == refs/heads/main ]]; then | |
VERSION="v2.0.0-main" | |
echo "goreleaser_args=--clean --skip=validate" >> $GITHUB_OUTPUT | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
GIT_TAG=$(git describe --tags --abbrev=0) | |
PR_NUM=$(echo "${GITHUB_REF}" | sed -E 's|refs/pull/([^/]+)/?.*|\1|') | |
VERSION="${GIT_TAG}-pr.${PR_NUM}-${GIT_SHA}" | |
echo "goreleaser_args=--snapshot --clean" >> $GITHUB_OUTPUT | |
else | |
echo "Unknown event type" | |
exit 1 | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
helm: | |
name: Package helm charts | |
needs: setup | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Helm login to ${{ env.IMAGE_REGISTRY }} | |
if: ${{ github.event_name != 'pull_request' }} | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.IMAGE_REGISTRY }} -u ${{ github.repository_owner }} --password-stdin | |
- name: Lint kgateway chart on PRs | |
if: ${{ github.event_name == 'pull_request' }} | |
run: helm lint install/helm/kgateway | |
- name: Package kgateway chart | |
run: make package-kgateway-chart | |
env: | |
VERSION: ${{ needs.setup.outputs.version }} | |
- name: Push kgateway chart to registry | |
if: ${{ github.event_name != 'pull_request' }} | |
run: | | |
helm push _test/kgateway-${{ needs.setup.outputs.version }}.tgz oci://${{ env.IMAGE_REGISTRY }}/charts | |
goreleaser: | |
name: goreleaser | |
needs: [setup, helm] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
# We publish a rolling main release for every commit to main. Deleting the release | |
# ensures that the tagged commit is not stale. Goreleaser will create a new tag | |
# and release for the tagged commit. | |
- name: Delete v2.0.0-main release if it exists | |
if: ${{ github.ref == 'refs/heads/main' }} | |
continue-on-error: true | |
run: | | |
set -x | |
echo "Deleting the v2.0.0-main release" | |
gh release delete v2.0.0-main --repo ${{ github.repository }} --yes --cleanup-tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Log into ghcr.io | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: "docker/setup-qemu-action@v3" | |
- uses: "docker/setup-buildx-action@v3" | |
- name: Run goreleaser | |
run: make release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
VERSION: ${{ needs.setup.outputs.version }} | |
IMAGE_REGISTRY: ${{ env.IMAGE_REGISTRY }} | |
GORELEASER_ARGS: ${{ needs.setup.outputs.goreleaser_args }} | |
GORELEASER_CURRENT_TAG: ${{ needs.setup.outputs.version }} | |
validate: | |
name: Validate release artifacts | |
needs: [setup, helm, goreleaser] | |
if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.validate }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Login to ghcr.io | |
if: ${{ github.event_name != 'pull_request' }} | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.IMAGE_REGISTRY }} -u ${{ github.repository_owner }} --password-stdin | |
- name: Download module dependencies | |
run: make mod-download | |
- name: Setup kind cluster | |
run: ./hack/kind/setup-kind.sh | |
env: | |
VERSION: ${{ needs.setup.outputs.version }} | |
SKIP_DOCKER: "true" | |
CONFORMANCE: "true" | |
- name: Install the released chart | |
run: | | |
helm install --create-namespace --namespace kgateway-system kgateway \ | |
oci://${{ env.IMAGE_REGISTRY }}/charts/kgateway \ | |
--version ${{ needs.setup.outputs.version }} \ | |
--set controller.image.registry=${{ env.IMAGE_REGISTRY }} \ | |
--set gateway.envoyContainer.image.registry=${{ env.IMAGE_REGISTRY }} \ | |
--set gateway.sdsContainer.image.registry=${{ env.IMAGE_REGISTRY }} \ | |
--wait --timeout 5m | |
- name: Wait for the kgateway deployment to be ready | |
run: | | |
kubectl wait --for=condition=available --timeout=5m deployment/kgateway -n kgateway-system | |
- name: Run Conformance Tests | |
run: make conformance | |
shell: bash | |
env: | |
VERSION: ${{ needs.setup.outputs.version }} |