forked from kgateway-dev/kgateway
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (159 loc) · 5.95 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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*'
- '!v0.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="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
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
# - 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]
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
- 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: ./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 Conformance Tests
run: make conformance
shell: bash
env:
VERSION: ${{ needs.setup.outputs.version }}