feat: update release configuration and add download script (#2815)

- Changed the archive name template in .goreleaser.yaml for better clarity.
- Added a new section in README files to document the UI installation process for versions v4.0.0 and above.
- Removed the old release workflow file and updated the releaser.yaml to include artifact synchronization to OSS.
- Introduced a new script (downloadKubekey.sh) for downloading binaries with UI support.

Signed-off-by: redscholar <blacktiledhouse@gmail.com>
This commit is contained in:
liujian 2025-10-17 19:51:53 +08:00 committed by redscholar
parent 7363febbf6
commit 3af5e91aa4
No known key found for this signature in database
GPG Key ID: 5A4D7C7DB5D38D49
11 changed files with 258 additions and 85 deletions

View File

@ -1,46 +0,0 @@
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: create draft release
runs-on: ubuntu-latest
steps:
- name: Set env
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install go
uses: actions/setup-go@v5
with:
go-version: '^1.23'
- name: generate release artifacts
run: |
make release
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
files: out/*
- name: Get Version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Synchronize artifacts to OSS
run: |
rm -rf qsctl_v2.4.3_linux_amd64.tar.gz
wget https://attack-on-titan.gd2.qingstor.com/qsctl/v2.4.3/qsctl_v2.4.3_linux_amd64.tar.gz
tar -zxvf qsctl_v2.4.3_linux_amd64.tar.gz
rm -rf qsctl_v2.4.3_linux_amd64.tar.gz
mv qsctl_v2.4.3_linux_amd64 /usr/local/bin/qsctl
echo "access_key_id: ${{secrets.KS_QSCTL_ACCESS_KEY_ID}}" > qsctl-config.yaml
echo "secret_access_key: ${{ secrets.KS_QSCTL_SECRET_ACCESS_KEY }}" >> qsctl-config.yaml
qsctl cp out/kubekey-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz qs://kubernetes/kubekey/releases/download/${{ steps.get_version.outputs.VERSION }}/kubekey-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz -c qsctl-config.yaml
qsctl cp out/kubekey-${{ steps.get_version.outputs.VERSION }}-linux-arm64.tar.gz qs://kubernetes/kubekey/releases/download/${{ steps.get_version.outputs.VERSION }}/kubekey-${{ steps.get_version.outputs.VERSION }}-linux-arm64.tar.gz -c qsctl-config.yaml
rm -rf qsctl-config.yaml

View File

@ -49,5 +49,26 @@ jobs:
REGISTRY=docker.io/kubespheredev TAG=$tag make generate
fi
gh release upload "$TAG" config/capkk/release/* --clobber
gh release upload "$TAG" hack/downloadKubekey.sh --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Synchronize artifacts to OSS
run: |
# Check if the current Git reference is a valid semantic version tag (e.g., v1.2.3)
if [[ ! ${GITHUB_REF#refs/*/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Skipping artifact synchronization: not a release tag."
return 0
fi
rm -rf qsctl_v2.4.3_linux_amd64.tar.gz
wget https://attack-on-titan.gd2.qingstor.com/qsctl/v2.4.3/qsctl_v2.4.3_linux_amd64.tar.gz
tar -zxvf qsctl_v2.4.3_linux_amd64.tar.gz
rm -rf qsctl_v2.4.3_linux_amd64.tar.gz
mv qsctl_v2.4.3_linux_amd64 /usr/local/bin/qsctl
echo "access_key_id: ${{secrets.KS_QSCTL_ACCESS_KEY_ID}}" > qsctl-config.yaml
echo "secret_access_key: ${{ secrets.KS_QSCTL_SECRET_ACCESS_KEY }}" >> qsctl-config.yaml
qsctl -c qsctl-config.yaml cp dist/kubekey-${{ steps.prepare.outputs.version }}-linux-amd64.tar.gz qs://kubekey/github.com/kubesphere/kubekey/releases/download/${{ steps.prepare.outputs.version }}/kubekey-${{ steps.prepare.outputs.version }}-linux-amd64.tar.gz
qsctl -c qsctl-config.yaml cp dist/kubekey-${{ steps.prepare.outputs.version }}-linux-arm64.tar.gz qs://kubekey/github.com/kubesphere/kubekey/releases/download/${{ steps.prepare.outputs.version }}/kubekey-${{ steps.prepare.outputs.version }}-linux-arm64.tar.gz
rm -rf qsctl-config.yaml

View File

@ -26,7 +26,7 @@ builds:
archives:
- format: tar.gz
name_template: "{{ .Binary }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}"
name_template: "kubekey-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
files:
- none*

View File

@ -28,6 +28,17 @@ helm upgrade --install --create-namespace -n kubekey-system kubekey config/kubek
## Binary
Get the corresponding binary files from the [release](https://github.com/kubesphere/kubekey/releases) page.
## Download Binary with UI
**UI only support after v4.0.0**
```shell
VERSION=v4.0.0 WEB_INSTALLER_VERSION=v1.0.0 hack/downloadKubekey.sh
# run with UI
kk web --schema-path schema -ui-path dist
```
> If there is a config.yaml file in the current directory, running `./package.sh config.yaml` to build an offline package.
# Deploy Kubernetes
- Supported deployment environments: Linux distributions

View File

@ -28,6 +28,17 @@ helm upgrade --install --create-namespace -n kubekey-system kubekey config/kubek
## 二进制
在 [release](https://github.com/kubesphere/kubekey/releases) 页面获取对应的二进制文件。
## 包含UI页面的kubekey
**UI 页面仅在 v4.0.0 及以上版本提供支持**
```shell
VERSION=v4.0.0 WEB_INSTALLER_VERSION=v1.0.0 hack/downloadKubekey.sh
# run with UI
kk web --schema-path schema -ui-path dist
```
> 如果当前目录有config.yaml文件。执行`./package.sh config.yaml`来构建离线包
# 部署kubernetes
- 支持部署环境Linux发行版

View File

@ -22,12 +22,28 @@ import (
"github.com/kubesphere/kubekey/v4/version"
)
// VersionOptions holds the flags for the version command.
type VersionOptions struct {
Short bool // Short determines if only the version number is printed.
}
// newVersionCommand creates the cobra command for printing KubeSphere's version information.
func newVersionCommand() *cobra.Command {
return &cobra.Command{
o := &VersionOptions{}
cmd := &cobra.Command{
Use: "version",
Short: "Print the version of KubeSphere controller-manager",
Run: func(cmd *cobra.Command, _ []string) {
// Print the short or full version info based on the --short flag.
if o.Short {
cmd.Println(version.Get().GitVersion)
} else {
cmd.Println(version.Get())
}
},
}
cmd.Flags().BoolVarP(&o.Short, "short", "s", false, "Print just the version number")
return cmd
}

177
hack/downloadKubekey.sh Executable file
View File

@ -0,0 +1,177 @@
#!/bin/sh
# Copyright 2020 The KubeSphere 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.
ISLINUX=true
OSTYPE="linux"
check_version() {
version="$1"
if echo "$version" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' >/dev/null; then
return 0
else
return 1
fi
}
if [ "x$(uname)" != "xLinux" ]; then
echo ""
echo 'Warning: Non-Linux operating systems are not supported! After downloading, please copy the tar.gz file to linux.'
ISLINUX=false
fi
# Fetch latest version of 3.x
if [ "x${VERSION}" = "x" ]; then
VERSION="$(curl -sL https://api.github.com/repos/kubesphere/kubekey/releases |
grep -o 'download/v3*.[0-9]*.[0-9]*/' |
sort --version-sort |
tail -1 | awk -F'/' '{ print $2}')"
VERSION="${VERSION##*/}"
fi
if [ -z "${ARCH}" ]; then
case "$(uname -m)" in
x86_64)
ARCH=amd64
;;
armv8*)
ARCH=arm64
;;
aarch64*)
ARCH=arm64
;;
*)
echo "${ARCH}, isn't supported"
exit 1
;;
esac
fi
if [ "x${VERSION}" = "x" ]; then
echo "Unable to get latest Kubekey version. Set VERSION env var and re-run. For example: export VERSION=v1.0.0"
echo ""
exit
fi
DOWNLOAD_URL="https://github.com/kubesphere/kubekey/releases/download/${VERSION}/kubekey-${VERSION}-${OSTYPE}-${ARCH}.tar.gz"
if [ "x${KKZONE}" = "xcn" ] && check_version "${VERSION}"; then
if echo "$VERSION" | grep -E '^v3\.[0-9]+\.[0-9]+$' >/dev/null; then
DOWNLOAD_URL="https://kubernetes.pek3b.qingstor.com/kubekey/releases/download/${VERSION}/kubekey-${VERSION}-${OSTYPE}-${ARCH}.tar.gz"
else
DOWNLOAD_URL="https://kubekey.pek3b.qingstor.com/github.com/kubesphere/kubekey/releases/download/${VERSION}/kubekey-${VERSION}-${OSTYPE}-${ARCH}.tar.gz"
fi
fi
echo ""
echo "Downloading kubekey ${VERSION} from ${DOWNLOAD_URL} ..."
echo ""
curl -fsLO "$DOWNLOAD_URL"
if [ $? -ne 0 ]; then
echo ""
echo "Failed to download Kubekey ${VERSION} !"
echo ""
echo "Please verify the version you are trying to download."
echo ""
exit
fi
if [ "${ISLINUX}" = "true" ]; then
filename="kubekey-${VERSION}-${OSTYPE}-${ARCH}.tar.gz"
ret='0'
command -v tar >/dev/null 2>&1 || { ret='1'; }
if [ "$ret" -eq 0 ]; then
tar -xzf "${filename}" --no-same-owner
else
echo "Kubekey ${VERSION} Download Complete!"
echo ""
echo "Try to unpack the ${filename} failed."
echo "tar: command not found, please unpack the ${filename} manually."
exit
fi
fi
if check_version "${WEB_INSTALLER_VERSION}"; then
WEB_DOWNLOAD_URL=https://kubekey.pek3b.qingstor.com/github.com/kubesphere/web-installer/releases/download/${WEB_INSTALLER_VERSION}/web-installer.tgz
echo ""
echo "Downloading kubekey web_installer ${VERSION} from ${DOWNLOAD_URL} ..."
echo ""
curl -fsLO "$WEB_DOWNLOAD_URL"
ret='0'
command -v tar >/dev/null 2>&1 || { ret='1'; }
if [ "$ret" -eq 0 ]; then
tar -xzf "web-installer.tgz" --no-same-owner
else
echo "Web Installer Download Complete!"
echo ""
echo "Try to unpack the web-installer.tgz failed."
echo "tar: command not found, please unpack the web-installer.tgz manually."
exit
fi
fi
# generate package.sh
cat > package.sh << 'EOF'
#!/bin/sh
set -e
# Get the configuration file path from the first argument, default to config.yaml if not provided
if [ -n "$1" ]; then
CONFIG_FILE="$1"
else
CONFIG_FILE="config.yaml"
fi
if [ ! -f "$CONFIG_FILE" ]; then
echo "Configuration file $CONFIG_FILE does not exist. Please check the file path."
exit 1
fi
echo "Exporting artifact with kk..."
./kk artifact export -c "$CONFIG_FILE" --workdir prepare -a artifact.tgz
if [ $? -ne 0 ]; then
echo "Failed to export artifact with kk. Please check the command output above."
exit 1
fi
echo "Preparing offline package directory..."
mkdir -p offline
echo "Extracting artifact.tgz to offline/ ..."
tar -xzf artifact.tgz -C offline/ --no-same-owner
echo "Extracting web-installer.tgz to offline/ ..."
tar -xzf web-installer.tgz -C offline/ --no-same-owner
echo "Copying config.yaml and kk to offline/ ..."
cp "$CONFIG_FILE" offline/
cp kk offline/
echo "Creating offline.tgz package ..."
tar -czf offline.tgz offline
echo "Offline package offline.tgz has been created successfully."
EOF
chmod +x package.sh
echo ""
echo "Kubekey ${VERSION} Download Complete!"
echo ""

View File

@ -148,27 +148,18 @@ func (c *localConnector) getHostInfo(ctx context.Context) (map[string]any, error
if err != nil {
return nil, errors.Wrapf(err, "failed to get kernel: %v, stderr: %q", err, string(stderr))
}
if len(stderr) > 0 {
return nil, errors.Errorf("failed to get kernel, stderr: %q", string(stderr))
}
osVars[_const.VariableOSKernelVersion] = string(bytes.TrimSpace(kernel))
hn, hnStderr, err := c.ExecuteCommand(ctx, "hostname")
if err != nil {
return nil, errors.Wrapf(err, "failed to get hostname: %v, stderr: %q", err, string(hnStderr))
}
if len(hnStderr) > 0 {
return nil, errors.Errorf("failed to get hostname, stderr: %q", string(hnStderr))
}
osVars[_const.VariableOSHostName] = string(bytes.TrimSpace(hn))
arch, archStderr, err := c.ExecuteCommand(ctx, "arch")
if err != nil {
return nil, errors.Wrapf(err, "failed to get arch: %v, stderr: %q", err, string(archStderr))
}
if len(archStderr) > 0 {
return nil, errors.Errorf("failed to get arch, stderr: %q", string(archStderr))
}
osVars[_const.VariableOSArchitecture] = string(bytes.TrimSpace(arch))
// process information

View File

@ -329,27 +329,18 @@ func (c *sshConnector) getHostInfo(ctx context.Context) (map[string]any, error)
if err != nil {
return nil, errors.Wrapf(err, "failed to get kernel: %v, stderr: %q", err, string(kernelStderr))
}
if len(kernelStderr) > 0 {
return nil, errors.Errorf("failed to get kernel, stderr: %q", string(kernelStderr))
}
osVars[_const.VariableOSKernelVersion] = string(bytes.TrimSpace(kernel))
hn, hnStderr, err := c.ExecuteCommand(ctx, "hostname")
if err != nil {
return nil, errors.Wrapf(err, "failed to get hostname: %v, stderr: %q", err, string(hnStderr))
}
if len(hnStderr) > 0 {
return nil, errors.Errorf("failed to get hostname, stderr: %q", string(hnStderr))
}
osVars[_const.VariableOSHostName] = string(bytes.TrimSpace(hn))
arch, archStderr, err := c.ExecuteCommand(ctx, "arch")
if err != nil {
return nil, errors.Wrapf(err, "failed to get arch: %v, stderr: %q", err, string(archStderr))
}
if len(archStderr) > 0 {
return nil, errors.Errorf("failed to get arch, stderr: %q", string(archStderr))
}
osVars[_const.VariableOSArchitecture] = string(bytes.TrimSpace(arch))
// process information

View File

@ -474,7 +474,7 @@ func newLocalRepository(reference, localDir string) (*remote.Repository, error)
var responseNotFound = &http.Response{Proto: "Local", StatusCode: http.StatusNotFound}
var responseNotAllowed = &http.Response{Proto: "Local", StatusCode: http.StatusMethodNotAllowed}
var responseServerError = &http.Response{Proto: "Local", StatusCode: http.StatusInternalServerError}
var responseCreated = &http.Response{Proto: "Local", StatusCode: http.StatusCreated}
var responseCreated = &http.Response{Proto: "Local", StatusCode: http.StatusAccepted}
var responseOK = &http.Response{Proto: "Local", StatusCode: http.StatusOK}
// const domain = "internal"
@ -486,18 +486,26 @@ type imageTransport struct {
// RoundTrip deal http.Request in local dir images.
func (i imageTransport) RoundTrip(request *http.Request) (*http.Response, error) {
var resp *http.Response
switch request.Method {
case http.MethodHead: // check if file exist
return i.head(request), nil
case http.MethodHead:
resp = i.head(request)
case http.MethodPost:
return i.post(request), nil
resp = i.post(request)
case http.MethodPut:
return i.put(request), nil
resp = i.put(request)
case http.MethodGet:
return i.get(request), nil
resp = i.get(request)
default:
return responseNotAllowed, nil
resp = responseNotAllowed
}
if resp != nil {
resp.Request = request
}
return resp, nil
}
// head method for http.MethodHead. check if file is exist in blobs dir or manifests dir

View File

@ -63,16 +63,9 @@ func Get() Info {
// String returns info as a human-friendly version string.
func (info Info) String() string {
return info.GitVersion
}
// ParseFilesSha256 Load files' sha256 from components.json
func ParseFilesSha256(componentsJSON []byte) (map[string]map[string]map[string]string, error) {
m := make(map[string]map[string]map[string]string)
err := json.Unmarshal(componentsJSON, &m)
b, err := json.Marshal(info)
if err != nil {
return nil, err
return fmt.Sprintf("error: %v", err)
}
return m, nil
return string(b)
}