Skip to content

Commit

Permalink
New build: /kube latest
Browse files Browse the repository at this point in the history
  • Loading branch information
muicoder committed Sep 13, 2023
1 parent 01087f8 commit 4020058
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 37 deletions.
28 changes: 1 addition & 27 deletions .github/scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,6 @@

set -e

readonly ERR_CODE=127

case $(arch) in
x86_64)
ARCH=amd64
;;
*)
echo "sealosPatch(ghcr.io/labring/sealos:dev) only support amd64(x86_64)"
exit $ERR_CODE
;;
esac

readonly IMAGE_CACHE_NAME="ghcr.io/labring-actions/cache"
readonly SEALOS=${sealoslatest:-$(
until curl -sL "https://api.github.com/repos/labring/sealos/releases/latest" | grep tarball_url; do sleep 3; done | awk -F\" '{print $(NF-1)}' | awk -F/ '{print $NF}' | cut -dv -f2
)}

if [[ -z "$sealosPatch" ]]; then
sudo docker run --rm -v "/usr/bin:/pwd" --entrypoint /bin/sh "$IMAGE_CACHE_NAME:sealos-v$SEALOS-$ARCH" -c "cp -a /sealos/sealos /pwd"
else
sudo docker run --rm -v "/usr/bin:/pwd" --entrypoint /bin/sh ghcr.io/labring/sealos:dev -c "cp -a /usr/bin/sealos /pwd"
fi
echo
sudo sealos version
echo

until sudo docker run --rm -v "/usr/bin:/pwd" -w /tools --entrypoint /bin/sh "$IMAGE_CACHE_NAME:tools-$ARCH" -c "ls -lh && cp -a . /pwd"; do
until sudo docker run --rm -v "/usr/bin:/pwd" -w /tools --entrypoint /bin/sh "ghcr.io/labring-actions/cache:tools-amd64" -c "ls -lh && cp -a . /pwd"; do
sleep 3
done
13 changes: 10 additions & 3 deletions .github/scripts/kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ readonly ARCH=${arch?}
readonly CRI_TYPE=${criType?}
readonly KUBE_TYPE=${kubeType:-k8s}
readonly KUBE=${kubeVersion?}
if [[ "$sealoslatest" == latest ]]; then
export sealosPatch="ghcr.io/labring/sealos-patch:latest"
sealoslatest=$(until curl -sL "https://api.github.com/repos/labring/sealos/releases/latest" | grep tarball_url; do sleep 3; done | awk -F\" '{print $(NF-1)}' | awk -F/ '{print $NF}' | cut -dv -f2)
fi
readonly SEALOS=${sealoslatest?}

readonly KUBE_XY="${KUBE%.*}"
Expand Down Expand Up @@ -36,7 +40,7 @@ cp -a "$KUBE_TYPE"/* "$ROOT"
pushd "$ROOT"
mkdir -p bin cri opt images/shim

if [[ "${SEALOS_XYZ//./}" -le 433 ]] && [[ $KUBE_TYPE == k3s ]]; then
if [[ "${SEALOS_XYZ//./}" -le 433 ]] && [[ $KUBE_TYPE == k3s ]] && [[ -z "$sealosPatch" ]]; then
echo "INFO::skip $KUBE(build for k3s) when $SEALOS(sealos<=4.3.3)"
exit
fi
Expand All @@ -52,14 +56,17 @@ fi
# image-cri-shim sealctl
if [[ -n "$sealosPatch" ]]; then
rmdir "$PATCH"
sudo docker run --rm -v "/usr/bin:/pwd" --entrypoint /bin/sh ghcr.io/labring/sealos:latest -c "cp -a /usr/bin/sealos /pwd"
sudo cp -au "$(sudo buildah mount "$(sudo buildah from "$sealosPatch-$ARCH")")" "$PATCH"
tree "$PATCH"
sudo cp -au "$PATCH"/* .
else
sudo docker run --rm -v "/usr/bin:/pwd" --entrypoint /bin/sh "$IMAGE_CACHE_NAME:sealos-v$SEALOS-$ARCH" -c "cp -a /sealos/sealos /pwd"
MOUNT_SEALOS=$(sudo buildah mount "$(sudo buildah from "$IMAGE_CACHE_NAME:sealos-v$SEALOS-$ARCH")")
sudo cp -au "$MOUNT_SEALOS"/sealos/image-cri-shim cri/
sudo cp -au "$MOUNT_SEALOS"/sealos/sealctl opt/
fi
sudo sealos version

# crictl helm kubeadm,kubectl,kubelet conntrack registry and cri(kubelet)
MOUNT_KUBE=$(sudo buildah mount "$(sudo buildah from "$IMAGE_CACHE_NAME:kubernetes-v${KUBE%+*}-$ARCH")")
Expand Down Expand Up @@ -100,7 +107,7 @@ docker)
esac
if grep k3s <<<"$KUBE"; then
IMAGE_KUBE=k3s
rm -f bin/crictl cri/cri-containerd.tar.gz
rm -f bin/crictl bin/conntrack cri/cri-containerd.tar.gz cri/libseccomp.tar.gz opt/lsof
fi

# define ImageTag for kube
Expand Down Expand Up @@ -133,7 +140,7 @@ sudo chown -R "$(whoami)" "$ROOT"
if rmdir "$PATCH" 2>/dev/null; then
ipvsImage="ghcr.io/labring/lvscare:v$SEALOS"
else
ipvsImage="${sealosPatch%%/*}/labring/lvscare:$(find "registry" -type d | grep -E "tags/.+-$ARCH$" | awk -F/ '{print $NF}')"
ipvsImage="${sealosPatch%%/*}/labring/lvscare:v$SEALOS"
rm -fv images/shim/*vscare*
fi
echo "$ipvsImage" >images/shim/LvscareImageList
Expand Down
4 changes: 4 additions & 0 deletions .github/scripts/manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ readonly IMAGE_CACHE_NAME="ghcr.io/labring-actions/cache"

readonly IMAGE_TAG=${version?}
readonly KUBE="${IMAGE_TAG%%-*}"
if [[ "$sealoslatest" == latest ]]; then
export sealosPatch="ghcr.io/labring/sealos-patch:latest"
sealoslatest=$(until curl -sL "https://api.github.com/repos/labring/sealos/releases/latest" | grep tarball_url; do sleep 3; done | awk -F\" '{print $(NF-1)}' | awk -F/ '{print $NF}' | cut -dv -f2)
fi
readonly sealoslatest="${sealoslatest:-IMAGE_TAG#*-}"
readonly SEALOS=${sealoslatest?}

Expand Down
9 changes: 8 additions & 1 deletion .github/scripts/versions/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ readonly KUBE_TYPE=${kubeType:-k8s}

readonly IMAGE_HUB_REGISTRY=${registry:-}
readonly IMAGE_HUB_REPO=${repo?}
if [[ "$sealoslatest" == latest ]]; then
export sealosPatch="ghcr.io/labring/sealos-patch:latest"
sealoslatest=$(until curl -sL "https://api.github.com/repos/labring/sealos/releases/latest" | grep tarball_url; do sleep 3; done | awk -F\" '{print $(NF-1)}' | awk -F/ '{print $NF}' | cut -dv -f2)
fi
readonly SEALOS=${sealoslatest?}
readonly SEALOS_XYZ="${SEALOS%%-*}"

Expand All @@ -21,6 +25,9 @@ cri-o)
IMAGE_KUBE=kubernetes-crio
;;
esac
if grep k3s <<<"$KUBE"; then
IMAGE_KUBE=k3s
fi

# Recursively finds all directories with a go.mod file and creates
# a GitHub Actions JSON output option. This is used by the linter action.
Expand Down Expand Up @@ -69,7 +76,7 @@ for file in $(pwd)/.github/versions/${part:-*}/CHANGELOG*; do
head -n 1 ".versions/$K8S_MD.cached" >".versions/$K8S_MD.latest"
case $KUBE_TYPE in
k3s)
git ls-remote --refs --sort="-version:refname" --tags "https://github.com/k3s-io/k3s.git" | cut -d/ -f3- | grep -E "^v$(cut -d. -f-2 ".versions/$K8S_MD.latest").[0-9]+\+k3s[0-9]$" | head -n 1 >".versions/$K8S_MD.cached"
git ls-remote --refs --sort="-version:refname" --tags "https://github.com/k3s-io/k3s.git" | cut -d/ -f3- | grep -E "^$(cut -d. -f-2 ".versions/$K8S_MD.latest").[0-9]+\+k3s[0-9]$" | head -n 1 >".versions/$K8S_MD.cached"
cp ".versions/$K8S_MD.cached" ".versions/$K8S_MD.latest"
;;
esac
Expand Down
9 changes: 8 additions & 1 deletion .github/scripts/versions/versions_arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ readonly KUBE_TYPE=${kubeType:-k8s}

readonly IMAGE_HUB_REGISTRY=${registry:-}
readonly IMAGE_HUB_REPO=${repo?}
if [[ "$sealoslatest" == latest ]]; then
export sealosPatch="ghcr.io/labring/sealos-patch:latest"
sealoslatest=$(until curl -sL "https://api.github.com/repos/labring/sealos/releases/latest" | grep tarball_url; do sleep 3; done | awk -F\" '{print $(NF-1)}' | awk -F/ '{print $NF}' | cut -dv -f2)
fi
readonly SEALOS=${sealoslatest?}
readonly SEALOS_XYZ="${SEALOS%%-*}"

Expand All @@ -21,6 +25,9 @@ cri-o)
IMAGE_KUBE=kubernetes-crio
;;
esac
if grep k3s <<<"$KUBE"; then
IMAGE_KUBE=k3s
fi

# Recursively finds all directories with a go.mod file and creates
# a GitHub Actions JSON output option. This is used by the linter action.
Expand Down Expand Up @@ -69,7 +76,7 @@ for file in $(pwd)/.github/versions/${part:-*}/CHANGELOG*; do
head -n 1 ".versions/$K8S_MD.cached" >".versions/$K8S_MD.latest"
case $KUBE_TYPE in
k3s)
git ls-remote --refs --sort="-version:refname" --tags "https://github.com/k3s-io/k3s.git" | cut -d/ -f3- | grep -E "^v$(cut -d. -f-2 ".versions/$K8S_MD.latest").[0-9]+\+k3s[0-9]$" | head -n 1 >".versions/$K8S_MD.cached"
git ls-remote --refs --sort="-version:refname" --tags "https://github.com/k3s-io/k3s.git" | cut -d/ -f3- | grep -E "^$(cut -d. -f-2 ".versions/$K8S_MD.latest").[0-9]+\+k3s[0-9]$" | head -n 1 >".versions/$K8S_MD.cached"
cp ".versions/$K8S_MD.cached" ".versions/$K8S_MD.latest"
;;
esac
Expand Down
14 changes: 9 additions & 5 deletions .github/scripts/versions/versions_sealos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ else
sealosVersion=$defaultVersion
fi

until curl -sL https://api.github.com/repos/labring/sealos/tags | yq .[].name | grep -E "^v.+$"; do sleep 3; done >.tags
if ! grep "$sealosVersion" .tags >/dev/null; then
cat .tags
echo "sealos version $sealosVersion does not exist"
exit 127
if [[ "$sealosVersion" == latest ]]; then
echo "sealos latest for development"
else
until curl -sL https://api.github.com/repos/labring/sealos/tags | yq .[].name | grep -E "^v.+$"; do sleep 3; done >.tags
if ! grep "$sealosVersion" .tags >/dev/null; then
cat .tags
echo "sealos version $sealosVersion does not exist"
exit 127
fi
fi

echo "sealos: $sealosVersion"
Expand Down

0 comments on commit 4020058

Please sign in to comment.