Skip to content

Commit 32d5bb8

Browse files
authored
Merge pull request #778 from stakater/branch-release-strat
Branch based release strategy
2 parents 489a900 + 60a2f26 commit 32d5bb8

File tree

12 files changed

+398
-222
lines changed

12 files changed

+398
-222
lines changed
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Init Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
TARGET_BRANCH:
6+
description: 'TARGET_BRANCH on which release will be based'
7+
required: true
8+
type: string
9+
10+
TARGET_VERSION:
11+
description: 'TARGET_VERSION to build kubernetes manifests with using Kustomize'
12+
required: true
13+
type: string
14+
15+
permissions: {}
16+
17+
jobs:
18+
prepare-release:
19+
permissions:
20+
contents: write # for peter-evans/create-pull-request to create branch
21+
pull-requests: write # for peter-evans/create-pull-request to create a PR
22+
name: Automatically generate version and manifests on ${{ inputs.TARGET_BRANCH }}
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/[email protected]
27+
with:
28+
fetch-depth: 0
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
ref: ${{ inputs.TARGET_BRANCH }}
31+
32+
- name: Check if TARGET_VERSION is well formed.
33+
run: |
34+
set -xue
35+
# Target version must not contain 'v' prefix
36+
if echo "${{ inputs.TARGET_VERSION }}" | grep -e '^v'; then
37+
echo "::error::Target version '${{ inputs.TARGET_VERSION }}' should not begin with a 'v' prefix, refusing to continue." >&2
38+
exit 1
39+
fi
40+
41+
- name: Create VERSION information
42+
run: |
43+
set -ue
44+
echo "Bumping version from $(cat VERSION) to ${{ inputs.TARGET_VERSION }}"
45+
echo "${{ inputs.TARGET_VERSION }}" > VERSION
46+
47+
- name: Replace latest tag with version from input
48+
run: |
49+
set -ue
50+
VERSION=${{ inputs.TARGET_VERSION }} make update-manifests-version
51+
VERSION=${{ inputs.TARGET_VERSION }} make bump-chart
52+
git diff
53+
54+
- name: Generate new set of manifests
55+
run: |
56+
set -ue
57+
make k8s-manifests
58+
git diff
59+
60+
- name: Create pull request
61+
uses: peter-evans/[email protected]
62+
with:
63+
commit-message: "Bump version to ${{ inputs.TARGET_VERSION }}"
64+
title: "Bump version to ${{ inputs.TARGET_VERSION }} on ${{ inputs.TARGET_BRANCH }} branch"
65+
body: Updating VERSION and manifests to ${{ inputs.TARGET_VERSION }}
66+
branch: update-version
67+
branch-suffix: random
68+
signoff: true
69+
labels: release

.github/workflows/pull_request.yaml

+75-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- master
7+
- 'v**'
78
paths:
89
- '**'
910
- '!.markdownlint.yaml'
@@ -17,8 +18,8 @@ on:
1718
env:
1819
DOCKER_FILE_PATH: Dockerfile
1920
DOCKER_UBI_FILE_PATH: Dockerfile.ubi
20-
KUBERNETES_VERSION: "1.19.0"
21-
KIND_VERSION: "0.17.0"
21+
KUBERNETES_VERSION: "1.30.0"
22+
KIND_VERSION: "0.23.0"
2223
REGISTRY: ghcr.io
2324

2425
jobs:
@@ -46,6 +47,8 @@ jobs:
4647
# Setting up helm binary
4748
- name: Set up Helm
4849
uses: azure/setup-helm@v4
50+
with:
51+
version: v3.11.3
4952

5053
- name: Helm chart unit tests
5154
uses: d3adb5/helm-unittest-action@v2
@@ -86,8 +89,7 @@ jobs:
8689
run: |
8790
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
8891
sudo install ./kubectl /usr/local/bin/ && rm kubectl
89-
kubectl version --short --client
90-
kubectl version --short --client | grep -q ${KUBERNETES_VERSION}
92+
kubectl version --client=true
9193
9294
- name: Install Kind
9395
run: |
@@ -160,3 +162,72 @@ jobs:
160162
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
161163
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
162164
org.opencontainers.image.revision=${{ github.sha }}
165+
166+
- name: Check if Helm validation needs to run
167+
uses: dorny/paths-filter@v3
168+
id: filter
169+
with:
170+
filters: |
171+
chart:
172+
- 'deployments/kubernetes/chart/reloader/**'
173+
174+
outputs:
175+
helm_chart_changed: ${{ steps.filter.outputs.chart }}
176+
177+
helm-validation:
178+
permissions:
179+
contents: read
180+
181+
runs-on: ubuntu-latest
182+
name: Helm Chart Validation
183+
needs:
184+
- build
185+
186+
if: ${{ needs.build.outputs.helm_chart_changed }} == "true"
187+
steps:
188+
189+
- name: Check out code
190+
uses: actions/checkout@v4
191+
with:
192+
ref: ${{github.event.pull_request.head.sha}}
193+
fetch-depth: 0
194+
195+
# Setting up helm binary
196+
- name: Set up Helm
197+
uses: azure/setup-helm@v4
198+
with:
199+
version: v3.11.3
200+
201+
- name: Helm chart unit tests
202+
uses: d3adb5/helm-unittest-action@v2
203+
with:
204+
charts: deployments/kubernetes/chart/reloader
205+
206+
- name: Add Stakater Helm Repo
207+
run: |
208+
helm repo add stakater https://stakater.github.io/stakater-charts
209+
210+
- name: Get version for chart from helm repo
211+
id: chart_eval
212+
run: |
213+
current_chart_version=$(helm search repo stakater/reloader | tail -n 1 | awk '{print $2}')
214+
echo "CURRENT_CHART_VERSION=$(echo ${current_chart_version})" >> $GITHUB_OUTPUT
215+
216+
- name: Get Updated Chart version from Chart.yaml
217+
uses: mikefarah/yq@master
218+
id: new_chart_version
219+
with:
220+
cmd: yq e '.version' deployments/kubernetes/chart/reloader/Chart.yaml
221+
222+
- name: Check Version
223+
uses: aleoyakas/check-semver-increased-action@v1
224+
id: check-version
225+
with:
226+
current-version: ${{ steps.new_chart_version.outputs.result }}
227+
previous-version: ${{ steps.chart_eval.outputs.CURRENT_CHART_VERSION }}
228+
229+
- name: Fail if Helm Chart version isnt updated
230+
if: steps.check-version.outputs.is-version-increased != 'true'
231+
run: |
232+
echo "Helm Chart Version wasnt updated"
233+
exit 1

.github/workflows/push-pr-image.yaml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Push PR Image on Label
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types: [ labeled ]
8+
9+
env:
10+
DOCKER_FILE_PATH: Dockerfile
11+
REGISTRY: ghcr.io
12+
13+
jobs:
14+
15+
build-and-push-pr-image:
16+
permissions:
17+
contents: read
18+
19+
runs-on: ubuntu-latest
20+
name: Build and Push PR Image
21+
if: ${{ github.event.label.name == 'build-and-push-pr-image' }}
22+
steps:
23+
- name: Check out code
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{github.event.pull_request.head.sha}}
27+
fetch-depth: 0
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version-file: 'go.mod'
33+
check-latest: true
34+
cache: true
35+
36+
- name: Install Dependencies
37+
run: |
38+
make install
39+
40+
- name: Run golangci-lint
41+
uses: golangci/golangci-lint-action@v5
42+
with:
43+
version: latest
44+
only-new-issues: false
45+
args: --timeout 10m
46+
47+
- name: Generate Tags
48+
id: generate_tag
49+
run: |
50+
sha=${{ github.event.pull_request.head.sha }}
51+
tag="SNAPSHOT-PR-${{ github.event.pull_request.number }}-${sha:0:8}"
52+
echo "GIT_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT
53+
54+
- name: Set up QEMU
55+
uses: docker/setup-qemu-action@v3
56+
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
60+
- name: Generate image repository path for ghcr registry
61+
run: |
62+
echo GHCR_IMAGE_REPOSITORY=${{env.REGISTRY}}/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
63+
64+
- name: Login to ghcr registry
65+
uses: docker/login-action@v3
66+
with:
67+
registry: ${{env.REGISTRY}}
68+
username: stakater-user
69+
password: ${{secrets.GITHUB_TOKEN}}
70+
71+
- name: Build Docker Image
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
file: ${{ env.DOCKER_FILE_PATH }}
76+
pull: true
77+
push: true
78+
build-args: BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }}
79+
cache-to: type=inline
80+
platforms: linux/amd64,linux/arm,linux/arm64
81+
tags: |
82+
${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}
83+
labels: |
84+
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
85+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
86+
org.opencontainers.image.revision=${{ github.sha }}

.github/workflows/push.yaml

+4-74
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ on:
66
- closed
77
branches:
88
- master
9+
- 'v**'
910

1011
env:
1112
DOCKER_FILE_PATH: Dockerfile
1213
DOCKER_UBI_FILE_PATH: Dockerfile.ubi
13-
KUBERNETES_VERSION: "1.19.0"
14-
KIND_VERSION: "0.17.0"
14+
KUBERNETES_VERSION: "1.30.0"
15+
KIND_VERSION: "0.23.0"
1516
HELM_REGISTRY_URL: "https://stakater.github.io/stakater-charts"
1617
REGISTRY: ghcr.io
1718

@@ -62,8 +63,7 @@ jobs:
6263
run: |
6364
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
6465
sudo install ./kubectl /usr/local/bin/ && rm kubectl
65-
kubectl version --short --client
66-
kubectl version --short --client | grep -q ${KUBERNETES_VERSION}
66+
kubectl version --client=true
6767
6868
- name: Install Kind
6969
run: |
@@ -207,76 +207,6 @@ jobs:
207207
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
208208
org.opencontainers.image.revision=${{ github.sha }}
209209
210-
##############################
211-
## Add steps to generate required artifacts for a release here(helm chart, operator manifest etc.)
212-
##############################
213-
214-
# Skip pushing plain manifests till we decide what to do with them
215-
216-
# - name: Helm Template
217-
# run: |
218-
# helm template reloader deployments/kubernetes/chart/reloader/ \
219-
# --set reloader.deployment.resources.limits.cpu=150m \
220-
# --set reloader.deployment.resources.limits.memory=512Mi \
221-
# --set reloader.deployment.resources.requests.cpu=10m \
222-
# --set reloader.deployment.resources.requests.memory=128Mi > deployments/kubernetes/reloader.yaml
223-
224-
# helm template reloader deployments/kubernetes/chart/reloader/ --output-dir deployments/kubernetes/manifests && mv deployments/kubernetes/manifests/reloader/templates/* deployments/kubernetes/manifests/ && rm -r deployments/kubernetes/manifests/reloader
225-
226-
# - name: Remove labels and annotations from manifests
227-
# run: make remove-labels-annotations
228-
229-
# Charts are to be pushed to a separate repo with a separate release cycle
230-
231-
# # Publish helm chart
232-
# - name: Login to ghcr via helm
233-
# run: |
234-
# echo ${{secrets.GITHUB_TOKEN}} | helm registry login ghcr.io/stakater --username stakater-user --password-stdin
235-
236-
# - name: Publish Helm chart to ghcr.io
237-
# run: |
238-
# helm package ./deployments/kubernetes/chart/reloader --destination ./packaged-chart
239-
# helm push ./packaged-chart/*.tgz oci://ghcr.io/stakater/charts
240-
# rm -rf ./packaged-chart
241-
242-
# - name: Publish Helm chart to gh-pages
243-
# uses: stefanprodan/helm-gh-pages@master
244-
# with:
245-
# branch: master
246-
# repository: stakater-charts
247-
# target_dir: docs
248-
# token: ${{ secrets.STAKATER_GITHUB_TOKEN }}
249-
# charts_dir: deployments/kubernetes/chart/
250-
# charts_url: ${{ env.HELM_REGISTRY_URL }}
251-
# owner: stakater
252-
# linting: on
253-
# commit_username: stakater-user
254-
# commit_email: [email protected]
255-
256-
# # Commit back changes
257-
# - name: Log info about `.git` directory permissions
258-
# run: |
259-
# # Debug logging
260-
# echo "Disk usage: "
261-
# df -H
262-
263-
# echo ".git files not owned by current user or current group:"
264-
# find .git ! -user $(id -u) -o ! -group $(id -g) | xargs ls -lah
265-
266-
# - name: Commit files
267-
# run: |
268-
# git config --local user.email "[email protected]"
269-
# git config --local user.name "stakater-user"
270-
# git status
271-
# git add .
272-
# git commit -m "[skip-ci] Update artifacts" -a
273-
274-
# - name: Push changes
275-
# uses: ad-m/github-push-action@master
276-
# with:
277-
# github_token: ${{ secrets.STAKATER_GITHUB_TOKEN }}
278-
# branch: ${{ github.ref }}
279-
280210
- name: Push Latest Tag
281211
uses: anothrNick/[email protected]
282212
env:

.github/workflows/release.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
env:
88
DOCKER_FILE_PATH: Dockerfile
99
DOCKER_UBI_FILE_PATH: Dockerfile.ubi
10-
KUBERNETES_VERSION: "1.19.0"
11-
KIND_VERSION: "0.17.0"
10+
KUBERNETES_VERSION: "1.30.0"
11+
KIND_VERSION: "0.23.0"
1212
REGISTRY: ghcr.io
1313

1414
jobs:
@@ -57,8 +57,7 @@ jobs:
5757
run: |
5858
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
5959
sudo install ./kubectl /usr/local/bin/ && rm kubectl
60-
kubectl version --short --client
61-
kubectl version --short --client | grep -q ${KUBERNETES_VERSION}
60+
kubectl version --client=true
6261
6362
- name: Install Kind
6463
run: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ styles/
1616
site/
1717
/mkdocs.yml
1818
yq
19+
bin

0 commit comments

Comments
 (0)