push charts to dockerHub

Signed-off-by: Poor12 <shentiecheng@huawei.com>
This commit is contained in:
Poor12 2023-03-14 11:53:39 +08:00
parent c7b2ba5af5
commit 943d2201bb
6 changed files with 84 additions and 14 deletions

View File

@ -0,0 +1,34 @@
name: latest chart to DockerHub
on:
push:
branches:
- master
jobs:
publish-chart-to-dockerhub:
name: publish to DockerHub
# prevent job running from forked repository, otherwise
# 1. running on the forked repository would fail as missing necessary secret.
# 2. running on the forked repository would use unnecessary GitHub Action time.
if: ${{ github.repository == 'karmada-io/karmada' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v3
with:
# fetch-depth:
# 0 indicates all history for all branches and tags.
# for `git describe --tags` in Makefile.
fetch-depth: 0
- name: login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: package chart
env:
VERSION: 0.0.0
run: make package-chart
- name: push chart
env:
VERSION: 0.0.0
run: make push-chart

View File

@ -0,0 +1,30 @@
name: released chart to DockerHub
on:
release:
types:
- published
jobs:
publish-chart-to-dockerhub:
name: publish to DockerHub
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v3
with:
# fetch-depth:
# 0 indicates all history for all branches and tags.
# for `git describe --tags` in Makefile.
fetch-depth: 0
- name: login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: package chart
env:
VERSION: ${{ github.ref_name }}
run: make package-chart
- name: push chart
env:
VERSION: ${{ github.ref_name }}
run: make push-chart

View File

@ -30,7 +30,9 @@ jobs:
GOARCH: ${{ matrix.arch }}
run: make release-${{ matrix.target }}
- name: Making helm charts
run: make release-chart
env:
VERSION: ${{ github.ref_name }}
run: make package-chart
- name: Uploading assets...
if: ${{ !env.ACT }}
uses: softprops/action-gh-release@v1
@ -38,8 +40,8 @@ jobs:
files: |
_output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz
_output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz.sha256
_output/release/karmada-chart-*.tgz
_output/release/karmada-chart-*.tgz.sha256
_output/charts/karmada-chart-${{ github.ref_name }}.tgz
_output/charts/karmada-chart-${{ github.ref_name }}.tgz.sha256
update-krew-index:
needs: release-assests
name: Update krew-index

View File

@ -92,9 +92,13 @@ update:
verify:
hack/verify-all.sh
.PHONY: release-chart
release-chart:
hack/release-helm-chart.sh $(VERSION)
.PHONY: package-chart
package-chart:
hack/package-helm-chart.sh $(VERSION)
.PHONY: push-chart
push-chart:
helm push _output/charts/karmada-chart-${VERSION}.tgz oci://docker.io/karmada
.PHONY: test
test:

View File

@ -20,12 +20,13 @@ kubeVersion: ">= 1.16.0-0"
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.5
# We use `0.0.0` as the latest chart version.
version: 0.0.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: v1.1.0
appVersion: latest
# This is karmada dependencies
dependencies:

View File

@ -6,12 +6,11 @@ set -o pipefail
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${REPO_ROOT}"/hack/util.sh
# keep v1.x.x forms
version=${1%%-*}
version=${1}
output_dir="${REPO_ROOT}/_output/charts"
release_dir="${REPO_ROOT}/_output/release"
tar_file="karmada-chart-${version}.tgz"
mkdir -p "${release_dir}"
mkdir -p "${output_dir}"
# install helm
echo -n "Preparing: 'helm' existence check - "
@ -23,8 +22,8 @@ else
fi
echo "Starting to package into a Karmada chart archive"
helm package ./charts/karmada --version "${version}" -d "${release_dir}" -u
cd "${release_dir}"
helm package ./charts/karmada --version "${version}" -d "${output_dir}" -u
cd "${output_dir}"
mv "karmada-${version}.tgz" ${tar_file}
echo "Rename karmada-${version}.tgz to ${tar_file}"
sha256sum "${tar_file}" > "${tar_file}.sha256"