-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #778 from stakater/branch-release-strat
Branch based release strategy
- Loading branch information
Showing
12 changed files
with
398 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Init Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
TARGET_BRANCH: | ||
description: 'TARGET_BRANCH on which release will be based' | ||
required: true | ||
type: string | ||
|
||
TARGET_VERSION: | ||
description: 'TARGET_VERSION to build kubernetes manifests with using Kustomize' | ||
required: true | ||
type: string | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
prepare-release: | ||
permissions: | ||
contents: write # for peter-evans/create-pull-request to create branch | ||
pull-requests: write # for peter-evans/create-pull-request to create a PR | ||
name: Automatically generate version and manifests on ${{ inputs.TARGET_BRANCH }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
ref: ${{ inputs.TARGET_BRANCH }} | ||
|
||
- name: Check if TARGET_VERSION is well formed. | ||
run: | | ||
set -xue | ||
# Target version must not contain 'v' prefix | ||
if echo "${{ inputs.TARGET_VERSION }}" | grep -e '^v'; then | ||
echo "::error::Target version '${{ inputs.TARGET_VERSION }}' should not begin with a 'v' prefix, refusing to continue." >&2 | ||
exit 1 | ||
fi | ||
- name: Create VERSION information | ||
run: | | ||
set -ue | ||
echo "Bumping version from $(cat VERSION) to ${{ inputs.TARGET_VERSION }}" | ||
echo "${{ inputs.TARGET_VERSION }}" > VERSION | ||
- name: Replace latest tag with version from input | ||
run: | | ||
set -ue | ||
VERSION=${{ inputs.TARGET_VERSION }} make update-manifests-version | ||
VERSION=${{ inputs.TARGET_VERSION }} make bump-chart | ||
git diff | ||
- name: Generate new set of manifests | ||
run: | | ||
set -ue | ||
make k8s-manifests | ||
git diff | ||
- name: Create pull request | ||
uses: peter-evans/[email protected] | ||
with: | ||
commit-message: "Bump version to ${{ inputs.TARGET_VERSION }}" | ||
title: "Bump version to ${{ inputs.TARGET_VERSION }} on ${{ inputs.TARGET_BRANCH }} branch" | ||
body: Updating VERSION and manifests to ${{ inputs.TARGET_VERSION }} | ||
branch: update-version | ||
branch-suffix: random | ||
signoff: true | ||
labels: release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Push PR Image on Label | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
types: [ labeled ] | ||
|
||
env: | ||
DOCKER_FILE_PATH: Dockerfile | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
|
||
build-and-push-pr-image: | ||
permissions: | ||
contents: read | ||
|
||
runs-on: ubuntu-latest | ||
name: Build and Push PR Image | ||
if: ${{ github.event.label.name == 'build-and-push-pr-image' }} | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{github.event.pull_request.head.sha}} | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
check-latest: true | ||
cache: true | ||
|
||
- name: Install Dependencies | ||
run: | | ||
make install | ||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v5 | ||
with: | ||
version: latest | ||
only-new-issues: false | ||
args: --timeout 10m | ||
|
||
- name: Generate Tags | ||
id: generate_tag | ||
run: | | ||
sha=${{ github.event.pull_request.head.sha }} | ||
tag="SNAPSHOT-PR-${{ github.event.pull_request.number }}-${sha:0:8}" | ||
echo "GIT_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Generate image repository path for ghcr registry | ||
run: | | ||
echo GHCR_IMAGE_REPOSITORY=${{env.REGISTRY}}/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV | ||
- name: Login to ghcr registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{env.REGISTRY}} | ||
username: stakater-user | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Build Docker Image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ${{ env.DOCKER_FILE_PATH }} | ||
pull: true | ||
push: true | ||
build-args: BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }} | ||
cache-to: type=inline | ||
platforms: linux/amd64,linux/arm,linux/arm64 | ||
tags: | | ||
${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }} | ||
labels: | | ||
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | ||
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | ||
org.opencontainers.image.revision=${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,13 @@ on: | |
- closed | ||
branches: | ||
- master | ||
- 'v**' | ||
|
||
env: | ||
DOCKER_FILE_PATH: Dockerfile | ||
DOCKER_UBI_FILE_PATH: Dockerfile.ubi | ||
KUBERNETES_VERSION: "1.19.0" | ||
KIND_VERSION: "0.17.0" | ||
KUBERNETES_VERSION: "1.30.0" | ||
KIND_VERSION: "0.23.0" | ||
HELM_REGISTRY_URL: "https://stakater.github.io/stakater-charts" | ||
REGISTRY: ghcr.io | ||
|
||
|
@@ -62,8 +63,7 @@ jobs: | |
run: | | ||
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl" | ||
sudo install ./kubectl /usr/local/bin/ && rm kubectl | ||
kubectl version --short --client | ||
kubectl version --short --client | grep -q ${KUBERNETES_VERSION} | ||
kubectl version --client=true | ||
- name: Install Kind | ||
run: | | ||
|
@@ -207,76 +207,6 @@ jobs: | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
############################## | ||
## Add steps to generate required artifacts for a release here(helm chart, operator manifest etc.) | ||
############################## | ||
|
||
# Skip pushing plain manifests till we decide what to do with them | ||
|
||
# - name: Helm Template | ||
# run: | | ||
# helm template reloader deployments/kubernetes/chart/reloader/ \ | ||
# --set reloader.deployment.resources.limits.cpu=150m \ | ||
# --set reloader.deployment.resources.limits.memory=512Mi \ | ||
# --set reloader.deployment.resources.requests.cpu=10m \ | ||
# --set reloader.deployment.resources.requests.memory=128Mi > deployments/kubernetes/reloader.yaml | ||
|
||
# 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 | ||
|
||
# - name: Remove labels and annotations from manifests | ||
# run: make remove-labels-annotations | ||
|
||
# Charts are to be pushed to a separate repo with a separate release cycle | ||
|
||
# # Publish helm chart | ||
# - name: Login to ghcr via helm | ||
# run: | | ||
# echo ${{secrets.GITHUB_TOKEN}} | helm registry login ghcr.io/stakater --username stakater-user --password-stdin | ||
|
||
# - name: Publish Helm chart to ghcr.io | ||
# run: | | ||
# helm package ./deployments/kubernetes/chart/reloader --destination ./packaged-chart | ||
# helm push ./packaged-chart/*.tgz oci://ghcr.io/stakater/charts | ||
# rm -rf ./packaged-chart | ||
|
||
# - name: Publish Helm chart to gh-pages | ||
# uses: stefanprodan/helm-gh-pages@master | ||
# with: | ||
# branch: master | ||
# repository: stakater-charts | ||
# target_dir: docs | ||
# token: ${{ secrets.STAKATER_GITHUB_TOKEN }} | ||
# charts_dir: deployments/kubernetes/chart/ | ||
# charts_url: ${{ env.HELM_REGISTRY_URL }} | ||
# owner: stakater | ||
# linting: on | ||
# commit_username: stakater-user | ||
# commit_email: [email protected] | ||
|
||
# # Commit back changes | ||
# - name: Log info about `.git` directory permissions | ||
# run: | | ||
# # Debug logging | ||
# echo "Disk usage: " | ||
# df -H | ||
|
||
# echo ".git files not owned by current user or current group:" | ||
# find .git ! -user $(id -u) -o ! -group $(id -g) | xargs ls -lah | ||
|
||
# - name: Commit files | ||
# run: | | ||
# git config --local user.email "[email protected]" | ||
# git config --local user.name "stakater-user" | ||
# git status | ||
# git add . | ||
# git commit -m "[skip-ci] Update artifacts" -a | ||
|
||
# - name: Push changes | ||
# uses: ad-m/github-push-action@master | ||
# with: | ||
# github_token: ${{ secrets.STAKATER_GITHUB_TOKEN }} | ||
# branch: ${{ github.ref }} | ||
|
||
- name: Push Latest Tag | ||
uses: anothrNick/[email protected] | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ styles/ | |
site/ | ||
/mkdocs.yml | ||
yq | ||
bin |
Oops, something went wrong.