Skip to content

Commit

Permalink
.github: Add release verification job
Browse files Browse the repository at this point in the history
Signed-off-by: timflannagan <[email protected]>
  • Loading branch information
timflannagan committed Jan 30, 2025
1 parent 10baa94 commit c56a54d
Showing 1 changed file with 110 additions and 44 deletions.
154 changes: 110 additions & 44 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
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*'
Expand Down Expand Up @@ -33,13 +42,17 @@ jobs:
- name: Set the release related variables
id: set_vars
run: |
GIT_TAG=$(git describe --tags --abbrev=0 --always)
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
VERSION="${GIT_TAG}-${GIT_SHA}"
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/}"
Expand All @@ -48,70 +61,123 @@ jobs:
VERSION="v0.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
VERSION="${GIT_TAG}-${GIT_BRANCH}-${GIT_SHA}"
echo "goreleaser_args=--snapshot --clean" >> $GITHUB_OUTPUT
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
# 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: 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: 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: 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
# - 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

# - 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"

goreleaser:
name: goreleaser
needs: [setup, helm]
# - 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]
if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.validate }}
runs-on: ubuntu-22.04
steps:
- name: Print out validate inputs
run: |
set -x
echo "validate: ${{ inputs.validate }}"
echo "version: ${{ needs.setup.outputs.version }}"
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true

- name: Log into ghcr.io
- name: Login to 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 }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.IMAGE_REGISTRY }} -u ${{ github.repository_owner }} --password-stdin

- uses: "docker/setup-qemu-action@v3"
- uses: "docker/setup-buildx-action@v3"
- name: Download module dependencies
run: make mod-download

- name: Setup kind cluster
run: ./ci/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 goreleaser
run: make release
- name: Run Conformance Tests
run: make conformance
shell: bash
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 }}

0 comments on commit c56a54d

Please sign in to comment.