Skip to content

Commit af59c1b

Browse files
authored
Merge pull request #11 from weaviate/auto-update-to-latest
Add automation to enable automatic weaviate-operator release
2 parents 6a9ad0c + 2cc9ddc commit af59c1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+296
-4504
lines changed

.github/workflows/docker-push.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: Weaviate Operator Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release'
8+
required: true
9+
helm_chart_version:
10+
description: 'Weaviate Helm chart version to use (default: latest)'
11+
required: false
12+
default: 'latest'
13+
draft:
14+
description: 'Create as draft release'
15+
required: false
16+
default: true
17+
type: boolean
18+
push:
19+
tags:
20+
- 'v*'
21+
22+
jobs:
23+
release:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
packages: write
27+
contents: write
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v3
31+
32+
# Set version based on input or tag
33+
- name: Set version
34+
id: set_version
35+
run: |
36+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
37+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
38+
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
39+
echo "IS_DRAFT=${{ github.event.inputs.draft }}" >> $GITHUB_OUTPUT
40+
else
41+
VERSION=${GITHUB_REF#refs/tags/v}
42+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
43+
echo "TAG_NAME=v$VERSION" >> $GITHUB_OUTPUT
44+
echo "IS_DRAFT=false" >> $GITHUB_OUTPUT
45+
fi
46+
47+
- name: Set up Helm
48+
uses: azure/setup-helm@v3
49+
with:
50+
version: 'latest'
51+
52+
- name: Add Weaviate Helm repository
53+
run: |
54+
if ! helm repo list | grep -q "weaviate"; then
55+
echo "Adding Weaviate Helm repository..."
56+
helm repo add weaviate https://weaviate.github.io/weaviate-helm/
57+
else
58+
echo "Weaviate Helm repository already exists."
59+
fi
60+
61+
- name: Update Helm repositories
62+
run: helm repo update
63+
64+
# Determine Helm chart version
65+
- name: Fetch Weaviate Helm chart
66+
run: |
67+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
68+
HELM_VERSION="${{ github.event.inputs.helm_chart_version }}"
69+
else
70+
HELM_VERSION="latest"
71+
fi
72+
73+
if [ "$HELM_VERSION" = "latest" ]; then
74+
HELM_VERSION=$(helm search repo weaviate/weaviate -o json | jq -r '.[0].version')
75+
echo "Using latest Helm chart version: $HELM_VERSION"
76+
fi
77+
78+
# Remove existing chart
79+
rm -rf helm-charts/weaviate
80+
81+
# Pull the chart
82+
mkdir -p helm-charts
83+
helm pull weaviate/weaviate --version $HELM_VERSION --untar --untardir helm-charts
84+
85+
echo "Downloaded Weaviate Helm chart version $HELM_VERSION"
86+
echo "HELM_VERSION=$HELM_VERSION" >> $GITHUB_OUTPUT
87+
id: fetch_chart
88+
89+
- name: Set up operator-sdk
90+
run: |
91+
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
92+
export OS=$(uname | awk '{print tolower($0)}')
93+
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.36.0
94+
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
95+
chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk
96+
97+
- name: Update VERSION in Makefile
98+
run: |
99+
sed -i "s/VERSION ?= .*/VERSION ?= ${{ steps.set_version.outputs.VERSION }}/" Makefile
100+
101+
- name: Generate operator.yaml
102+
run: make generate-operator-yaml
103+
104+
# Create a tag for non-draft manual releases
105+
- name: Create and push tag
106+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.draft == false }}
107+
run: |
108+
git config --global user.name "GitHub Actions Bot"
109+
git config --global user.email "actions@github.com"
110+
git tag -a ${{ steps.set_version.outputs.TAG_NAME }} -m "Release ${{ steps.set_version.outputs.TAG_NAME }}"
111+
git push origin ${{ steps.set_version.outputs.TAG_NAME }}
112+
113+
- name: Create Release
114+
id: create_release
115+
uses: softprops/action-gh-release@v1
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
with:
119+
tag_name: ${{ steps.set_version.outputs.TAG_NAME }}
120+
name: Release ${{ steps.set_version.outputs.TAG_NAME }}
121+
draft: ${{ steps.set_version.outputs.IS_DRAFT }}
122+
body: |
123+
Weaviate Operator ${{ steps.set_version.outputs.TAG_NAME }}
124+
125+
This release includes:
126+
- Weaviate Helm chart version: ${{ steps.fetch_chart.outputs.HELM_VERSION }}
127+
128+
## Installation
129+
130+
```bash
131+
kubectl apply -f https://github.com/weaviate/weaviate-operator/releases/download/${{ steps.set_version.outputs.TAG_NAME }}/operator.yaml
132+
```
133+
134+
- name: Upload Release Artifact
135+
uses: actions/upload-release-asset@v1
136+
env:
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
with:
139+
upload_url: ${{ steps.create_release.outputs.upload_url }}
140+
asset_path: ./operator.yaml
141+
asset_name: operator.yaml
142+
asset_content_type: application/yaml
143+
144+
# Only run the Docker build job for non-draft releases
145+
docker-build:
146+
needs: release
147+
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.draft == false) }}
148+
runs-on: ubuntu-latest
149+
permissions:
150+
packages: write
151+
contents: read
152+
steps:
153+
- name: Checkout code
154+
uses: actions/checkout@v3
155+
with:
156+
ref: ${{ github.ref }} # Ensure we're using the tagged commit
157+
158+
- name: Set version
159+
id: set_version
160+
run: |
161+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
162+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
163+
else
164+
# Remove 'v' prefix if present
165+
TAG=${GITHUB_REF#refs/tags/}
166+
VERSION=${TAG#v}
167+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
168+
fi
169+
echo "Building Docker image for version: ${{ steps.set_version.outputs.VERSION }}"
170+
171+
- name: Update VERSION in Makefile
172+
run: |
173+
sed -i "s/VERSION ?= .*/VERSION ?= ${{ steps.set_version.outputs.VERSION }}/" Makefile
174+
175+
- name: Set up Docker Buildx
176+
uses: docker/setup-buildx-action@v2
177+
178+
- name: Log in to Docker Hub
179+
uses: docker/login-action@v2
180+
with:
181+
username: ${{ secrets.DOCKER_USERNAME }}
182+
password: ${{ secrets.DOCKER_PASSWORD }}
183+
184+
- name: Build and push Docker image
185+
uses: docker/build-push-action@v5
186+
with:
187+
context: .
188+
push: true
189+
platforms: linux/amd64,linux/arm64
190+
tags: |
191+
semitechnologies/weaviate-operator:${{ steps.set_version.outputs.VERSION }}
192+
semitechnologies/weaviate-operator:latest

.github/workflows/stage-release.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/tests.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@ name: Run Tests
33
on:
44
push:
55
branches:
6-
- main
6+
- main
77

88
jobs:
99
test:
1010
runs-on: ubuntu-latest
1111

1212
steps:
1313
- name: Checkout Repository
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1515

1616
- name: Set up Kind Cluster
1717
uses: helm/kind-action@v1
1818
with:
1919
cluster_name: test-cluster
20-
20+
21+
- name: Retrieve latest helm charts
22+
run: ./update-helm-chart.sh
23+
2124
- name: Build the Weaviate Operator image
2225
run: make docker-build
2326

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@
1919

2020
# Go workspace file
2121
go.work
22+
23+
# Helm charts directory - downloaded during build
24+
helm-charts/
25+
26+
# Generated operator.yaml
27+
operator.yaml

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.0.2
6+
VERSION ?= 0.0.3
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")

README.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ There are multiple ways to run the `weaviate-operator`:
4444
1. The easiest way is to apply the one-single-command Manifest:
4545

4646
```shell
47-
kubectl apply -f https://github.com/weaviate/weaviate-operator/releases/download/0.0.2/operator.yaml
47+
kubectl apply -f https://github.com/weaviate/weaviate-operator/releases/latest/download/operator.yaml
4848
```
4949

50+
5051
Other alternative ways to install it is:
5152

5253
1. Run the operator locally outside the cluster by executing the following command inside the `weaviate-operator` repository:
@@ -173,3 +174,55 @@ make undeploy
173174
```
174175

175176
or simply stop the process if you started it via `make install run`.
177+
178+
## Development
179+
180+
### Updating the Helm Chart
181+
182+
The operator is based on the [Weaviate Helm Chart](https://github.com/weaviate/weaviate-helm). To update the Helm chart to the latest version, you can use the provided script:
183+
184+
```shell
185+
./update-helm-chart.sh
186+
```
187+
188+
To update to a specific version of the Helm chart:
189+
190+
```shell
191+
./update-helm-chart.sh 1.2.3
192+
```
193+
194+
After updating the Helm chart, you can generate the operator.yaml:
195+
196+
```shell
197+
make generate-operator-yaml
198+
```
199+
200+
### Release Process
201+
202+
The operator uses a single GitHub workflow with sequential jobs for the release process:
203+
204+
1. **Release Job**: Handles creating releases and updating the Helm chart
205+
- Updates to the specified Helm chart version
206+
- Generates the operator.yaml
207+
- Creates a GitHub release with the operator.yaml attached
208+
- For non-draft manual releases, creates and pushes a tag
209+
210+
2. **Docker Build Job**: Runs after the Release job completes
211+
- Builds and pushes the Docker image with the appropriate version tag
212+
- Only runs for non-draft releases
213+
214+
The workflow can be triggered in two ways:
215+
216+
- **Manual Trigger**: Through the GitHub UI
217+
- Go to Actions → Weaviate Operator Release → Run workflow
218+
- Enter the version number and configure options:
219+
- Helm chart version (defaults to latest)
220+
- Draft mode (create as draft release)
221+
222+
- **Automatic Trigger**: When a tag is pushed
223+
- Create and push a tag: `git tag v1.2.3 && git push origin v1.2.3`
224+
- This will create a published release and build the Docker image
225+
226+
#### Note on Helm Chart Updates
227+
228+
The Helm charts directory is excluded from git tracking to avoid committing large changes with each update. The charts are downloaded during the release process.

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: semitechnologies/weaviate-operator
8-
newTag: 0.0.2
8+
newTag: 0.0.3

helm-charts/weaviate/Chart.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)