Skip to content

Commit

Permalink
feat: add version information to CRDs (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek authored Jan 7, 2025
1 parent ccc3cad commit b4e3fb3
Show file tree
Hide file tree
Showing 42 changed files with 135 additions and 13 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ name: Create release
run-name: "Release ${{ format('{0} (branch: {1})', inputs.tag, github.ref_name) }} "

on:
workflow_call:
inputs:
tag:
description: "Tag to release (e.g. v1.0.0)"
required: true
type: string
latest:
description: "Whether to tag this release latest"
required: true
type: boolean
workflow_dispatch:
inputs:
tag:
Expand All @@ -12,7 +22,6 @@ on:
description: "Whether to tag this release latest"
required: true
type: boolean
default: false

jobs:
tests:
Expand All @@ -29,7 +38,7 @@ jobs:
- uses: mukunku/[email protected]
id: check-tag
with:
tag: ${{ github.event.inputs.tag }}
tag: ${{ inputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: fail if tag already exists
Expand All @@ -39,7 +48,7 @@ jobs:
id: parse-semver
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.event.inputs.tag }}
input_string: ${{ inputs.tag }}
version_extractor_regex: 'v(.*)$'

release:
Expand All @@ -56,16 +65,16 @@ jobs:
See [changelog] for a complete list of changes.
[changelog]: https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md#${{ github.event.inputs.tag }}
[changelog]: https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md#${{ inputs.tag }}
#### Install CRDs from all channels
```shell
kustomize build github.com/${{ github.repository }}/config/crd/gateway-operator\?ref=${{ github.event.inputs.tag }} | kubectl apply -f -
kustomize build github.com/${{ github.repository }}/config/crd/ingress-controller\?ref=${{ github.event.inputs.tag }} | kubectl apply -f -
kustomize build github.com/${{ github.repository }}/config/crd/ingress-controller-incubator\?ref=${{ github.event.inputs.tag }} | kubectl apply -f -
kustomize build github.com/${{ github.repository }}/config/crd/gateway-operator\?ref=${{ inputs.tag }} | kubectl apply -f -
kustomize build github.com/${{ github.repository }}/config/crd/ingress-controller\?ref=${{ inputs.tag }} | kubectl apply -f -
kustomize build github.com/${{ github.repository }}/config/crd/ingress-controller-incubator\?ref=${{ inputs.tag }} | kubectl apply -f -
```
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.tag }}
tag: ${{ inputs.tag }}
commit: ${{ github.sha }}
prerelease: ${{ needs.verify-tag.outputs.prerelease != '' }}
makeLatest: ${{ github.event.inputs.latest == 'true' }}
makeLatest: ${{ inputs.latest == 'true' }}
33 changes: 33 additions & 0 deletions .github/workflows/release_on_version_change.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Trigger release based on VERSION file change

on:
push:
paths:
- VERSION
branches:
- main

jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
latest: ${{ steps.version.outputs.version == 'latest' }}
steps:
- uses: actions/checkout@v4
- id: version
run: |
echo "version=$(head -1 VERSION)" >> "$GITHUB_OUTPUT"
echo "latest=$(tail -1 VERSION)" >> "$GITHUB_OUTPUT"
- name: Validate semver
uses: booxmedialtd/[email protected]
with:
input_string: ${{ steps.version.outputs.version }}
version_extractor_regex: 'v(.*)$'
trigger_release:
needs:
- version
uses: ./.github/workflows/release.yaml
with:
tag: ${{ needs.version.outputs.version }}
latest: ${{ needs.version.outputs.latest }}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ REPO_URL ?= github.com/kong/kubernetes-configuration
# NOTE: this is not neeed now before v2, but will be needed in the future.
#GO_MOD_MAJOR_VERSION ?= $(subst $(REPO_URL)/,,$(shell go list -m))
REPO_INFO ?= $(shell git config --get remote.origin.url)
VERSION ?= $(shell head -1 VERSION)

ifndef COMMIT
COMMIT := $(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -155,7 +156,7 @@ generate.apitypes-funcs:
.PHONY: generate.crds
generate.crds: controller-gen ## Generate WebhookConfiguration and CustomResourceDefinition objects.
# Use gotypesalias=0 as a workaround for https://github.com/kubernetes-sigs/controller-tools/issues/1088.
GODEBUG=gotypesalias=0 go run ./scripts/crds-generator
VERSION=$(VERSION) GODEBUG=gotypesalias=0 go run ./scripts/crds-generator

.PHONY: generate.deepcopy
generate.deepcopy: controller-gen
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,25 @@ When you add a new CRD make sure to

## How to release?

Releases are driven by changes in the [`VERSION`](./VERSION) file.
This file contains 2 lines:

- The first line is the version number (e.g. `1.0.0`).
- The second line indicates if the version should be marked as latest or not
(e.g. `latest` for latest, anything else is not marked as latest).

To release a new version:

- Pick a new version.
- Make sure a changelog is updated with the new version, the release date, and all the changes.
- Trigger a [release workflow]. This will create a tag a release in GitHub.
- Update the [`VERSION`](./VERSION) file with said version and whether the version should be marked as latest.
This can be done in a separate PR or along with the PR that introduces the changes.

The [`release_on_version_change.yaml`][release_on_change_workflow]
workflow will be triggered when a commit changing the `VERSION` file is pushed to the `main` branch.
Releases created with this approach will be marked as latest

[release workflow]: https://github.com/Kong/kubernetes-configuration/actions/workflows/release.yaml
[release_on_change_workflow]: .github/workflows/release_on_version_change.yaml

## Available custom markers

Expand Down
2 changes: 2 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
v1.0.1
latest
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcacertificates.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcertificates.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongconsumergroups.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongconsumers.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcredentialacls.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcredentialapikeys.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcredentialbasicauths.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcredentialhmacs.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcredentialjwts.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongdataplaneclientcertificates.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongkeys.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongkeysets.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: konglicenses.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongpluginbindings.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongplugins.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongroutes.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongservices.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongsnis.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongtargets.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongupstreams.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongvaults.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: konnectapiauthconfigurations.konnect.konghq.com
spec:
group: konnect.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: konnectgatewaycontrolplanes.konnect.konghq.com
spec:
group: konnect.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller-incubator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongservicefacades.incubator.ingress-controller.konghq.com
spec:
group: incubator.ingress-controller.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller
kubernetes-configuration.konghq.com/version: v1.0.1
name: ingressclassparameterses.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongclusterplugins.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongconsumergroups.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongconsumers.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongcustomentities.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller
kubernetes-configuration.konghq.com/version: v1.0.1
name: kongingresses.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator
kubernetes-configuration.konghq.com/version: v1.0.1
name: konglicenses.configuration.konghq.com
spec:
group: configuration.konghq.com
Expand Down
Loading

0 comments on commit b4e3fb3

Please sign in to comment.