diff --git a/.github/workflows/dockerhub-latest-chart.yml b/.github/workflows/dockerhub-latest-chart.yml new file mode 100644 index 000000000..1603e4e5e --- /dev/null +++ b/.github/workflows/dockerhub-latest-chart.yml @@ -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 diff --git a/.github/workflows/dockerhub-released-chart.yml b/.github/workflows/dockerhub-released-chart.yml new file mode 100644 index 000000000..9d3a4a62f --- /dev/null +++ b/.github/workflows/dockerhub-released-chart.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6f2e9916e..82548642f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/Makefile b/Makefile index b43a6489b..4626015b8 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/charts/karmada/Chart.yaml b/charts/karmada/Chart.yaml index e19a4e9e6..9d0e22c9f 100644 --- a/charts/karmada/Chart.yaml +++ b/charts/karmada/Chart.yaml @@ -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: diff --git a/hack/release-helm-chart.sh b/hack/package-helm-chart.sh similarity index 73% rename from hack/release-helm-chart.sh rename to hack/package-helm-chart.sh index 00c0b5d51..607e5ee6f 100755 --- a/hack/release-helm-chart.sh +++ b/hack/package-helm-chart.sh @@ -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"