Skip to content

Commit

Permalink
add workflow to build chart tag and image (#309)
Browse files Browse the repository at this point in the history
Signed-off-by: calvin <wen.chen@daocloud.io>
Co-authored-by: calvin <wen.chen@daocloud.io>
  • Loading branch information
calvin0327 and calvin committed Jul 25, 2024
1 parent 92acc44 commit 87bd0fa
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 9 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build-helm-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release helm

on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*

jobs:
helm-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.7.1

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

71 changes: 71 additions & 0 deletions .github/workflows/build-image-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build & Release Image

env:
IMAGE_REPO: ${{ github.repository }}
REGISTRY: ghcr.io
IMAGE_ROOT_PATH: docker
BUILD_PLATFORM: linux/amd64,linux/arm64
REGISTER_USER: ${{ github.actor }}
REGISTER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

on:
workflow_dispatch:
push:
branches:
- master
tags:
- v*

jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Get the version
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then
VERSION=latest
fi
echo ::set-output name=VERSION::${VERSION}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login registry
run: |
echo "${{ env.REGISTER_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u ${{ env.REGISTER_USER }} --password-stdin
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:master

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}

- name: Build & Pushing hami image
uses: docker/build-push-action@v5.1.0
with:
context: .
file: ${{ env.IMAGE_ROOT_PATH }}/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.BUILD_PLATFORM }}
build-args: |
VERSION=${{ steps.get_version.outputs.VERSION }}
GOLANG_IMAGE=golang:1.21-bullseye
NVIDIA_IMAGE=nvidia/cuda:12.2.0-devel-ubuntu20.04
DEST_DIR=/usr/local
tags: ${{ steps.meta.outputs.tags }}
push: true
github-token: ${{ env.REGISTER_PASSWORD }}

24 changes: 24 additions & 0 deletions .github/workflows/lint-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Chart Lint

on:
pull_request:
push:
branches: ["master"]

jobs:
chart-lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.7.1

- name: Check chart version
run: bash ./hack/verify-chart-version.sh

7 changes: 0 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,3 @@ jobs:
# run: make proto
- run: SHORT_VERSION="${BRANCH_NAME}" bash ./hack/build.sh

- name: Publish Helm charts
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ secrets.GITHUB_TOKEN }}



5 changes: 3 additions & 2 deletions charts/hami/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: hami
version: 2.0.0
version: 2.3.11
kubeVersion: ">= 1.16.0"
description: Heterogeneous AI Computing Virtualization Middleware
keywords:
Expand All @@ -10,4 +10,5 @@ type: application
maintainers:
- name: limengxuan
email: limengxuan@4paradigm.com
appVersion: 0.0.2
appVersion: "2.3.11"

29 changes: 29 additions & 0 deletions docs/CHANGELOG/CHANGELOG-0.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [v0.0.0](#v000)
- [Downloads for v0.0.0](#downloads-for-v000)
- [Changelog since v0.0.0](#changelog-since-v000)
- [Changes by Kind](#changes-by-kind)
- [Bug Fixes](#bug-fixes)
- [Others](#others)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# v0.0.0
## Downloads for v0.0.0

Download v0.0.0 in the [v0.0.0 release page](https://github.com/Project-HAMi/HAMi/releases/tag/v0.0.0).

## Changelog since v0.0.0
### Changes by Kind
#### Bug Fixes
None.

### Deprecation
None.

#### Others
None.

27 changes: 27 additions & 0 deletions docs/release-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This document documents the regular release process, including image building, chart package building, artifact publishing, changelog writing, etc.

1. Update Changelog

Currently, there is no automated way to generate the changelog. The changelog file needs to be updated manually. Its directory is `/docs/CHANGELOG`, and a new file needs to be created for each minor version. For example, all changelogs for version 1.2.x are placed in the CHANGELOG-1.2.md file. You can refer to the specific format in CHANGELOG-0.0.0.md.

2. Modify Version

Modify the latest version of the chart by modifying the `charts/hami/Chart.yaml` file. Please update both version and appVersion. Currently, there is a CI workflow that checks whether these two fields are consistent. If they are inconsistent, CI will report an error.

Modify the version in the `charts/hami/values` file to the latest version.
When the chart's version is updated, it will automatically trigger CI to release the chart version, automatically build the tag package, update the index file under the gh-page branch, and automatically generate a release and assert.

3. Create a release branch
After the above changes are merged into the `master` branch, based on the master branch, create a new release branch with the prefix release and only the `x` and `y` version numbers. For example, release-1.1. In version 1.1, all version releases including the z releases will be based on this branch.

4. Generate a New Tag

Based on relase branch, a new tag can be created. Its name must start with `v`. When a new tag is created, it will trigger the building of a new image and upload it to the `ghcr` image repository.

5. Update Release Description

The release description will be automatically generated in the second step, and we can add more release content. For example, link to the changelog file. e.g: See [the CHANGELOG](./CHANGELOG/CHANGELOG-0.0.0.md) for details.

6. Release the z version
Before releasing the z version, you need to ensure that all changes have been merged into the release branch, including the changelogs for the new z version release. All the changelogs for z relases should be put in one changelog file, then based on the latest relase branch generate a new tag.

6 changes: 6 additions & 0 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ function util::verify_go_version {
exit 1
fi
}

# util::install_helm will install the helm command
function util::install_helm {
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
}

43 changes: 43 additions & 0 deletions hack/verify-chart-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Copyright 2024 The HAMi 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 pipefail

REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${REPO_ROOT}"

source "${REPO_ROOT}"/hack/util.sh

# install helm
echo -n "Preparing: 'helm' existence check - "
if util::cmd_exist helm; then
echo "passed"
else
echo "installing helm"
util::install_helm
fi

APP_VERSION=$(helm show chart ./charts/hami | grep '^appVersion' |grep -E '[0-9].*.[0-9]' | awk -F ':' '{print $2}' | tr -d ' ')
VERSION=$(helm show chart ./charts/hami | grep '^version' |grep -E '[0-9].*.[0-9]' | awk -F ':' '{print $2}' | tr -d ' ')

if [[ ${APP_VERSION} != ${VERSION} ]]; then
echo "AppVersion of HAMi is ${APP_VERSION}, but version is ${VERSION}!"
exit 1
fi

echo "Both appVersion and version is ${APP_VERSION}."

0 comments on commit 87bd0fa

Please sign in to comment.