Skip to content

Commit

Permalink
build(release): add release workflow
Browse files Browse the repository at this point in the history
Release workflow will:
- Create and push a release tag
- Produce release using goreleaser with binaries and helm charts
- Build docs from docs_new
- Publish docs and helm charts index in the github pages
  • Loading branch information
hairyhum committed Apr 18, 2024
1 parent 988f4f3 commit 8f911fa
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 64 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Release
on:
## FIXME: replace with on_merge
workflow_dispatch:
inputs:
release_tag:
description: 'Image tag in the format x.x.x(-rcx)'
required: true
type: string

env:
RELEASE_TAG: ${{ inputs.release_tag }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
create_tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
## FIXME: change to master
ref: ci-release
- run: |
git config --global user.name 'Kasten Production'
git config --global user.email '[email protected]'
git tag -a "${RELEASE_TAG}" -m "Release version"
git push origin "${RELEASE_TAG}"
release_packages:
runs-on: ubuntu-latest
needs: create_tag
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ inputs.release_tag }}
- name: build helm charts
run: |
export PACKAGE_FOLDER=helm_package
export HELM_RELEASE_REPO_URL=https://github.com/kanisterio/kanister/releases/download/${RELEASE_TAG}
export HELM_RELEASE_REPO_INDEX=https://charts.kanister.io/
make package-helm VERSION=${RELEASE_TAG}
- name: show files
run: du -hd5 /
- name: gorelease
run: |
export GITHUB_TOKEN="${GH_TOKEN}"
docker login https://ghcr.io -u kanisterio -p ${GHCR_TOKEN}
make gorelease
## Upload to use in docs publishing
- uses: actions/upload-artifact@v4
with:
name: helm-index
path: helm_package/index.yaml

release_docs_and_charts:
runs-on: ubuntu-latest
needs: release_packages
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ inputs.release_tag }}
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: pnpm install
- name: Build with VitePress
run: pnpm docs:build
- name: download helm helm
uses: actions/download-artifact@v4
with:
name: helm-index
path: docs/.vitepress/dist/helm_charts/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

publish_docs_and_charts:
needs: release_docs_and_charts

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action

# release_example_docker_images:
# needs: release_packages
# steps:
# - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
# with:
# ref: ${{ inputs.release_tag }}
# - run: ./build/build_example_images.sh


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/dist
**/*.swp
/.idea
/helm_package
136 changes: 72 additions & 64 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ project_name: kanister
before:
hooks:
- go mod download
release:
## FIXME: remove that after testing
draft: true
replace_existing_draft: true
prerelease: auto
extra_files:
- glob: 'helm_package/kanister-operator-*.tgz'
- glob: 'helm_package/profile-*.tgz'
builds:
- id: kanctl
binary: kanctl
Expand Down Expand Up @@ -74,75 +82,75 @@ dockers:
- "--build-arg=kopia_repo_org=kopia"
extra_files:
- 'LICENSE'
- ids:
- kando
image_templates:
- 'ghcr.io/kanisterio/postgres-kanister-tools:{{ .Tag }}'
dockerfile: 'docker/postgres-kanister-tools/Dockerfile'
build_flag_templates:
- "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
- image_templates:
- 'ghcr.io/kanisterio/postgresql:{{ .Tag }}'
dockerfile: 'docker/postgresql/Dockerfile'
build_flag_templates:
- "--pull"
- ids:
- kando
image_templates:
- 'ghcr.io/kanisterio/es-sidecar:{{ .Tag }}'
dockerfile: 'docker/kanister-elasticsearch/image/Dockerfile'
build_flag_templates:
- "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
- ids:
- kando
image_templates:
- 'ghcr.io/kanisterio/mysql-sidecar:{{ .Tag }}'
dockerfile: 'docker/kanister-mysql/image/Dockerfile'
build_flag_templates:
- "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
- image_templates:
- 'ghcr.io/kanisterio/kanister-kubectl-1.18:{{ .Tag }}'
dockerfile: 'docker/kanister-kubectl/Dockerfile'
build_flag_templates:
- "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
- ids:
- kando
image_templates:
- 'ghcr.io/kanisterio/mongodb:{{ .Tag }}'
dockerfile: 'docker/mongodb/Dockerfile'
build_flag_templates:
- "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
- ids:
- kando
image_templates:
- 'ghcr.io/kanisterio/cassandra:{{ .Tag }}'
dockerfile: 'docker/cassandra/Dockerfile'
build_flag_templates:
- "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
- image_templates:
- 'ghcr.io/kanisterio/kafka-adobe-s3-source-connector:{{ .Tag }}'
dockerfile: 'docker/kafka-adobes3Connector/image/adobeSource.Dockerfile'
extra_files:
- 'docker/kafka-adobes3Connector/image/adobe-monitorsource.sh'
- 'docker/kafka-adobes3Connector/image/cleans3.py'
build_flag_templates:
- "--pull"
- ids:
- kando
image_templates:
- 'ghcr.io/kanisterio/kafka-adobe-s3-sink-connector:{{ .Tag }}'
dockerfile: 'docker/kafka-adobes3Connector/image/adobeSink.Dockerfile'
extra_files:
- 'docker/kafka-adobes3Connector/image/adobe-monitorsink.sh'
build_flag_templates:
- "--pull"
- ids:
- kando
image_templates:
- 'ghcr.io/kanisterio/mssql-tools:{{ .Tag }}'
dockerfile: 'docker/mssql-tools/Dockerfile'
build_flag_templates:
- "--pull"
# - ids:
# - kando
# image_templates:
# - 'ghcr.io/kanisterio/postgres-kanister-tools:{{ .Tag }}'
# dockerfile: 'docker/postgres-kanister-tools/Dockerfile'
# build_flag_templates:
# - "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
# - image_templates:
# - 'ghcr.io/kanisterio/postgresql:{{ .Tag }}'
# dockerfile: 'docker/postgresql/Dockerfile'
# build_flag_templates:
# - "--pull"
# - ids:
# - kando
# image_templates:
# - 'ghcr.io/kanisterio/es-sidecar:{{ .Tag }}'
# dockerfile: 'docker/kanister-elasticsearch/image/Dockerfile'
# build_flag_templates:
# - "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
# - ids:
# - kando
# image_templates:
# - 'ghcr.io/kanisterio/mysql-sidecar:{{ .Tag }}'
# dockerfile: 'docker/kanister-mysql/image/Dockerfile'
# build_flag_templates:
# - "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
# - ids:
# - kando
# image_templates:
# - 'ghcr.io/kanisterio/mongodb:{{ .Tag }}'
# dockerfile: 'docker/mongodb/Dockerfile'
# build_flag_templates:
# - "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
# - ids:
# - kando
# image_templates:
# - 'ghcr.io/kanisterio/cassandra:{{ .Tag }}'
# dockerfile: 'docker/cassandra/Dockerfile'
# build_flag_templates:
# - "--build-arg=TOOLS_IMAGE=ghcr.io/kanisterio/kanister-tools:{{ .Tag }}"
# - image_templates:
# - 'ghcr.io/kanisterio/kafka-adobe-s3-source-connector:{{ .Tag }}'
# dockerfile: 'docker/kafka-adobes3Connector/image/adobeSource.Dockerfile'
# extra_files:
# - 'docker/kafka-adobes3Connector/image/adobe-monitorsource.sh'
# - 'docker/kafka-adobes3Connector/image/cleans3.py'
# build_flag_templates:
# - "--pull"
# - ids:
# - kando
# image_templates:
# - 'ghcr.io/kanisterio/kafka-adobe-s3-sink-connector:{{ .Tag }}'
# dockerfile: 'docker/kafka-adobes3Connector/image/adobeSink.Dockerfile'
# extra_files:
# - 'docker/kafka-adobes3Connector/image/adobe-monitorsink.sh'
# build_flag_templates:
# - "--pull"
# - ids:
# - kando
# image_templates:
# - 'ghcr.io/kanisterio/mssql-tools:{{ .Tag }}'
# dockerfile: 'docker/mssql-tools/Dockerfile'
# build_flag_templates:
# - "--pull"
snapshot:
name_template: '{{ .Tag }}'
checksum:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ release-docs: docs
release-helm:
@/bin/bash ./build/release_helm.sh $(VERSION)

package-helm:
@$(MAKE) run CMD="PACKAGE_FOLDER=${PACKAGE_FOLDER} HELM_RELEASE_REPO_URL=${HELM_RELEASE_REPO_URL} HELM_RELEASE_REPO_INDEX=${HELM_RELEASE_REPO_INDEX} ./build/package_helm.sh $(VERSION)"

gorelease:
@$(MAKE) run CMD="./build/gorelease.sh"

Expand Down
52 changes: 52 additions & 0 deletions build/package_helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Copyright 2024 The Kanister Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


set -o errexit
set -o nounset
set -o xtrace
set -o pipefail

PACKAGE_FOLDER=${PACKAGE_FOLDER:?"PACKAGE_FOLDER not specified"}
HELM_RELEASE_REPO_URL=${HELM_RELEASE_REPO_URL:?"HELM_RELEASE_REPO_URL not specified"}
HELM_RELEASE_REPO_INDEX=${HELM_RELEASE_REPO_INDEX:?"HELM_RELEASE_REPO_INDEX not specified"}

main() {
version=${1:?"chart version not specified"}

## Cleanup old package folder
if [[ -d ${PACKAGE_FOLDER} ]]
then
rm -fr ${PACKAGE_FOLDER}
fi
mkdir ${PACKAGE_FOLDER}

# Build profile chart archive
helm package helm/profile --version ${version} -d ${PACKAGE_FOLDER}

# Build kanister-operator chart archive
helm package helm/kanister-operator --version ${version} -d ${PACKAGE_FOLDER}

local repo_args="--url ${HELM_RELEASE_REPO_URL}"

if curl ${HELM_RELEASE_REPO_INDEX} -o ${PACKAGE_FOLDER}/cur_index.yaml
then
repo_args="${repo_args} --merge ${PACKAGE_FOLDER}/cur_index.yaml"
fi

helm repo index ${PACKAGE_FOLDER} ${repo_args}
}

main $@

0 comments on commit 8f911fa

Please sign in to comment.