Skip to content

Commit 2896875

Browse files
committed
Build efficient binary tools
1 parent 2023a34 commit 2896875

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4124
-61
lines changed

.github/scripts/k9s.build

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
GIT_USER=${GIT_USER:-derailed}
6+
GIT_REPO=${GITHUB_REPO:-k9s}
7+
8+
OUTPUT_BIN="$GIT_REPO"
9+
PACKAGE="github.com/$GIT_USER/$GIT_REPO"
10+
11+
[ -d "$GIT_REPO" ] || for i in $(seq 3); do git clone "https://$PACKAGE" --depth "$i" && break; done
12+
13+
cd "$GIT_REPO" && {
14+
GitCommit=$(git rev-parse --short HEAD)
15+
GitDate=$(git show --pretty=format:"%ci" | head -1 | awk '{print $1}')
16+
GitVer=$(grep ^VERSION Makefile | awk '{print $NF}')
17+
} || exit
18+
19+
build() {
20+
go mod tidy >/dev/null 2>&1
21+
(
22+
#sed -i -E "/k8s.io/d;/helm.sh/d;/golang.org/d" go.mod
23+
# shellcheck disable=SC2016
24+
sed -i -E '/`.+`,/d;s~var Logo(.+)~var Logo\1`Kubernetes CLI`,~' internal/ui/splash.go
25+
sed -i -E 's~!.+LatestRevCheck~false~' internal/model/cluster_info.go
26+
sed -i -E 's~k9sFlags.[LC].+less~boolPtr(true)~' internal/config/k9s.go
27+
sed -i -E 's~fullGVR =.+~fullGVR = true~g' internal/ui/table.go
28+
git diff cmd internal
29+
)
30+
go mod tidy -v
31+
git diff go.mod | grep "^[+-]" || true
32+
GODEBUG=gotypesalias=0 CGO_ENABLED=0 GOOS="${0##*.}" GOARCH=$ARCH go build -trimpath -ldflags "-extldflags -static -w -s -X ${PACKAGE}/cmd.version=${GitVer} -X ${PACKAGE}/cmd.commit=${GitCommit} -X ${PACKAGE}/cmd.date=${GitDate}" -a -tags netgo -o "${OUTPUT_BIN}"
33+
chmod a+x "$OUTPUT_BIN"
34+
tar -zcf /cached/"$OUTPUT_BIN.tgz" "$OUTPUT_BIN"
35+
}
36+
37+
build

.github/scripts/kube-eventer.build

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
GIT_USER=${GIT_USER:-AliyunContainerService}
6+
GIT_REPO=${GITHUB_REPO:-kube-eventer}
7+
8+
OUTPUT_BIN="$GIT_REPO"
9+
PACKAGE="github.com/$GIT_USER/$GIT_REPO"
10+
11+
[ -d "$GIT_REPO" ] || for i in $(seq 3); do git clone "https://$PACKAGE" --depth "$i" && break; done
12+
13+
cd "$GIT_REPO" && {
14+
GitCommit=$(git rev-parse --short HEAD)
15+
GitDate=$(git show --pretty=format:"%ci" | head -1 | awk '{print $1}')
16+
GitVer=$(git branch --show-current)
17+
} || exit
18+
19+
build() {
20+
git diff
21+
go mod tidy
22+
CGO_ENABLED=0 GOOS="${0##*.}" GOARCH=$ARCH go build -trimpath -ldflags "-extldflags -static -w -s -X ${PACKAGE}/version.Version=${GitVer} -X ${PACKAGE}/version.GitCommit=${GitCommit}" -o "${OUTPUT_BIN}"
23+
chmod a+x "$OUTPUT_BIN"
24+
}
25+
26+
build && cp "$OUTPUT_BIN" /cached/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
GIT_USER=${GIT_USER:-zilliztech}
6+
GIT_REPO=${GITHUB_REPO:-milvus-backup}
7+
8+
OUTPUT_BIN="$GIT_REPO"
9+
PACKAGE="github.com/$GIT_USER/$GIT_REPO"
10+
11+
[ -d "$GIT_REPO" ] || for i in $(seq 3); do git clone "https://$PACKAGE" --depth "$i" && break; done
12+
13+
cd "$GIT_REPO" && {
14+
GitCommit=$(git rev-parse --short HEAD)
15+
GitDate=$(git show --pretty=format:"%ci" | head -1 | awk '{print $1}')
16+
GitVer=$(git branch --show-current)
17+
} || exit
18+
19+
build() {
20+
#sed -i "/&backuppb.RestoreCollectionTask/iif toRestoreSize == 0 {return resp}" core/backup_context.go
21+
#sed -i "/task.GetCollBackup().GetPartitionBackups/aif partitionBackup.GetSize() == 0 {continue}" core/backup_context.go
22+
git diff
23+
go mod tidy
24+
CGO_ENABLED=0 GOOS="${0##*.}" GOARCH=$ARCH go build -trimpath -ldflags "-extldflags -static -w -s" -o "${OUTPUT_BIN}"
25+
chmod a+x "$OUTPUT_BIN"
26+
}
27+
28+
build && cp "$OUTPUT_BIN" /cached/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
GIT_USER=${GIT_USER:-milvus-io}
6+
GIT_REPO=${GITHUB_REPO:-birdwatcher}
7+
8+
OUTPUT_BIN="$GIT_REPO"
9+
PACKAGE="github.com/$GIT_USER/$GIT_REPO"
10+
11+
[ -d "$GIT_REPO" ] || for i in $(seq 3); do git clone "https://$PACKAGE" --depth "$i" && break; done
12+
13+
cd "$GIT_REPO" && {
14+
GitCommit=$(git rev-parse --short HEAD)
15+
GitDate=$(git show --pretty=format:"%ci" | head -1 | awk '{print $1}')
16+
GitVer=$(git branch --show-current)
17+
} || exit
18+
19+
build() {
20+
git diff
21+
CGO_ENABLED=1 GOOS="${0##*.}" GOARCH=$ARCH go build -trimpath -ldflags "-extldflags -static -w -s" -o "${OUTPUT_BIN}"
22+
chmod a+x "$OUTPUT_BIN"
23+
}
24+
25+
build && cp "$OUTPUT_BIN" /cached/

.github/scripts/registry2images.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
if ! [ -d "$1" ]; then
4+
echo "Please input: registryDir"
5+
exit
6+
fi
7+
8+
DATAregistry="${1:-registry}"
9+
NEWregistry="${2:-docker.io}"
10+
OLDregistry="localhost:${3:-5000}"
11+
12+
sealos registry serve filesystem "$DATAregistry" -p "${OLDregistry#*:}" &
13+
PID=$!
14+
until curl -sSL "$OLDregistry/v2/" 2>/dev/null; do sleep 1; done
15+
curl -sSL "$OLDregistry/v2/_catalog" | awk -F[ '{print $NF}' | awk -F] '{print $1}' | sed 's~"~~g;s~,~\n~g' |
16+
while read image; do
17+
curl -sSL "$OLDregistry//v2/$image/tags/list" | awk -F[ '{print $NF}' | awk -F] '{print $1}' | sed 's~"~~g;s~,~\n~g' |
18+
while read tag; do echo "$image:$tag"; done
19+
done |
20+
while read it; do
21+
sealos pull --policy=always "$OLDregistry/$it" >/dev/null &&
22+
sealos tag "$OLDregistry/$it" "$NEWregistry/$it" &&
23+
sealos rmi --force "$OLDregistry/$it" >/dev/null
24+
done
25+
kill -9 $PID

.github/scripts/sealos.build

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
case $(uname -m) in
6+
amd64 | x86_64)
7+
ARCH=amd64
8+
;;
9+
arm64 | aarch64)
10+
ARCH=arm64
11+
;;
12+
*)
13+
echo "Unsupported architecture $ARCH"
14+
exit
15+
;;
16+
esac
17+
18+
declare -A VERs=(
19+
["v030"]=""
20+
["v029"]=""
21+
["v028"]=""
22+
["v027"]=""
23+
["v026"]=""
24+
["v025"]=""
25+
["v024"]=""
26+
)
27+
for name in ${!VERs[*]}; do
28+
export "$name"="$(until git ls-remote --refs --sort="-version:refname" --tags "https://github.com/kubernetes/api.git" | cut -d/ -f3- | grep -E "^v[0-9.]+$"; do sleep 1; done | grep "${name/0/0.}" | head -n 1)"
29+
done
30+
k8s_api_v02=$(
31+
env | grep ^v02 | sort -r | while read -r v02; do
32+
v=${v02#*=}
33+
printf 's~(k8s.io/.+)%s[.0-9]+~\\1%s~g;' "${v%.*}" "$v"
34+
done
35+
)
36+
37+
rm -rf sealos
38+
git clone --depth 9 https://github.com/muicoder/sealos.git
39+
cd sealos
40+
readonly CODE_DIR=$(pwd)
41+
readonly CODE_HEAD=$(git rev-parse HEAD)
42+
readonly COMMIT=${COMMIT:-$(git rev-parse --short HEAD^)}
43+
readonly TAG=${TAG:-4.3}
44+
45+
code_reset() {
46+
if pushd "$CODE_DIR" >/dev/null 2>&1; then
47+
git clean -fdx
48+
git reset --hard "$CODE_HEAD"
49+
git reset --soft "$COMMIT"
50+
git tag --delete "$TAG" >/dev/null 2>&1 || true
51+
git tag "$TAG"
52+
git rev-parse --short HEAD
53+
sed -E "s~^VERSION.+~VERSION=$TAG~;s~^BUILD_DATE.+~BUILD_DATE=2006-01-02T15:04:05-0700~" <scripts/make-rules/common.mk >f.sed && mv f.sed scripts/make-rules/common.mk
54+
find . -type f -name "*.mod" | while read -r mod; do sed -E "$k8s_api_v02" <"$mod" >"$mod.sed" && mv "$mod.sed" "$mod"; done
55+
popd >/dev/null 2>&1
56+
else
57+
exit
58+
fi
59+
go get github.com/google/gnostic
60+
go get github.com/google/gnostic-models
61+
go get k8s.io/kube-openapi
62+
go work sync
63+
}
64+
{
65+
buildah version
66+
sudo docker run --rm -v "/usr/bin:/pwd" -w /tools --entrypoint /bin/sh "ghcr.io/labring-actions/cache:tools-$ARCH" -c "ls -lh && cp -a . /pwd" 2>/dev/null
67+
buildah version
68+
sudo apt-get remove -y docker docker-engine docker.io containerd runc moby-engine moby-cli moby-buildx moby-compose >/dev/null
69+
sudo apt-get purge docker-ce docker-ce-cli containerd.io >/dev/null # docker-compose-plugin
70+
sudo apt update >/dev/null
71+
sudo apt install -y gcc-aarch64-linux-gnu qemu-user-static binfmt-support libgpgme-dev libbtrfs-dev libdevmapper-dev >/dev/null
72+
rm -rf /tmp/go
73+
wget -qO- https://go.dev/dl/go1.23.12.linux-$ARCH.tar.gz | sudo tar -C /tmp -xz
74+
export PATH="/tmp/go/bin:${PATH}"
75+
go version
76+
}
77+
78+
code_reset
79+
grep 10.103.97.2 -rl | grep .go$ | xargs sed -i "s~10.103.97.2~172.31.255.254~g"
80+
BINS="lvscare sealctl sealos" make build.multiarch || true
81+
find bin -type f -exec ls -l {} +
82+
for hcra in amd64 arm64; do
83+
pushd bin/linux_$hcra
84+
tar -zcvf "/tmp/bin.$hcra.tgz" ./*
85+
popd
86+
done
87+
88+
code_reset
89+
{
90+
go work edit -replace "k8s.io/cri-api=k8s.io/cri-api@$v025"
91+
pushd "staging/src/github.com/labring/image-cri-shim"
92+
sed -E "s~(k8s.io/.+)v0.2[.0-9]+~\1$v030~g;" <go.mod >f.sed && mv f.sed go.mod
93+
go mod edit -replace "k8s.io/cri-api=k8s.io/cri-api@$v025" go.mod
94+
go mod edit -replace "github.com/containers/image/v5=github.com/containers/image/v5@v5.30.2" go.mod
95+
go mod edit -replace "google.golang.org/grpc=google.golang.org/grpc@v1.64.1" go.mod
96+
go get -u all
97+
git diff go.mod | grep "^[+-]"
98+
popd
99+
grep 10.103.97.2 -rl | grep .go$ | xargs sed -i "s~10.103.97.2~172.31.255.254~g"
100+
BINS="image-cri-shim" make build.multiarch || true
101+
find bin -type f -exec ls -l {} +
102+
tar -zcvf /tmp/bin.ics.tgz bin
103+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
env:
2+
BASE64manifest: IyEvYmluL3NoCgpDTUQ9JChpZiBidWlsZGFoID4vZGV2L251bGw7IHRoZW4gZWNobyBidWlsZGFoOyBlbGlmIHNlYWxvcyA+L2Rldi9udWxsOyB0aGVuIGVjaG8gc2VhbG9zOyBmaSkKTUY9Im1mOiQoZGF0ZSArJUYpIgoKUkVQTz0iJHsxOi1kb2NrZXIuaW8vYml0bmFtaS9tZXRyaWNzLXNlcnZlcjpkb2NrZXIuaW8vbXVpY29kZXIvbWV0cmljcy1zZXJ2ZXJ9IgpUQUdTPSIkezI6LTAuNi4zfSIKVEFHPSIkezM6LSRUQUdTfSIKCmlmIFsgIiR7UkVQTyU6Kn0iICE9ICIkUkVQTyIgXTsgdGhlbgogIGlmIFsgIiR7VEFHUyUsKn0iICE9ICIkVEFHUyIgXTsgdGhlbgogICAgZWNobyAiJFRBR1MiIHwgc2VkICJzfix+XG5+ZyIgfCB3aGlsZSByZWFkIC1yIHRhZzsgZG8KICAgICAgZWNobyAiJHtSRVBPJToqfTokdGFnIgogICAgZG9uZSB8ICRDTUQgcHVsbAogIGVsc2UKICAgICRDTUQgcHVsbCAtLXBvbGljeT1hbHdheXMgLS1wbGF0Zm9ybT1saW51eC9hbWQ2NCAiJHtSRVBPJToqfTokVEFHUyIKICAgICRDTUQgdGFnICIke1JFUE8lOip9OiRUQUdTIiAiJHtSRVBPIyo6fTokVEFHUy1hbWQ2NCIKICAgICRDTUQgcHVsbCAtLXBvbGljeT1hbHdheXMgLS1wbGF0Zm9ybT1saW51eC9hcm02NCAiJHtSRVBPJToqfTokVEFHUyIKICAgICRDTUQgdGFnICIke1JFUE8lOip9OiRUQUdTIiAiJHtSRVBPIyo6fTokVEFHUy1hcm02NCIKICAgIFRBR1M9IiRUQUdTLWFtZDY0LCRUQUdTLWFybTY0IgogIGZpCmZpCgplY2hvICIkVEFHUyIgfCBzZWQgInN+LH5cbn5nIiB8IHdoaWxlIHJlYWQgLXIgdGFnOyBkbwogIGVjaG8gIiR7UkVQTyMqOn06JHRhZyIKZG9uZSB8IHhhcmdzICRDTUQgbWFuaWZlc3QgY3JlYXRlIC0tYWxsICIkTUYiCiRDTUQgbWFuaWZlc3QgcHVzaCAtLWFsbCAiJE1GIiAiZG9ja2VyOi8vJHtSRVBPIyo6fTokVEFHIgokQ01EIG1hbmlmZXN0IHJtICIkTUYiIHx8IHRydWUK
3+
jobs:
4+
RedisInsight:
5+
env:
6+
GITHUB_REPO: RedisInsight
7+
outputs:
8+
version: ${{ steps.git.outputs.version }}
9+
runs-on: ubuntu-latest
10+
steps:
11+
- id: git
12+
name: Build artifacts
13+
run: |-
14+
rm -rf RedisInsight .git
15+
git clone https://github.com/RedisInsight/RedisInsight.git
16+
mv RedisInsight/.git .
17+
TAG=$(git ls-remote --refs --sort="-version:refname" --tags https://github.com/RedisInsight/RedisInsight.git | cut -d/ -f3- | head -n 1)
18+
if docker pull ${{ secrets.DOCKERHUB_USERNAME }}/redisinsight:$TAG; then
19+
git reset --hard
20+
echo "version=latest" >>$GITHUB_OUTPUT
21+
else
22+
git reset --hard $TAG
23+
echo "version=$TAG" >>$GITHUB_OUTPUT
24+
fi
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v2
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
- name: Login to DockerHub
30+
uses: docker/login-action@v2
31+
with:
32+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
33+
username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
- name: Build and push
35+
uses: docker/build-push-action@v5
36+
continue-on-error: true
37+
with:
38+
context: .
39+
file: Dockerfile
40+
platforms: ${{ matrix.os }}/${{ matrix.arch }}
41+
provenance: false
42+
pull: true
43+
push: true
44+
sbom: false
45+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/redisinsight:action-${{ matrix.arch }}
46+
strategy:
47+
matrix:
48+
arch:
49+
- amd64
50+
os:
51+
- linux
52+
aio-manifest:
53+
needs:
54+
- RedisInsight
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Login to DockerHub
58+
uses: docker/login-action@v2
59+
with:
60+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
61+
username: ${{ secrets.DOCKERHUB_USERNAME }}
62+
- name: manifest
63+
run: echo ${{ env.BASE64manifest }} | base64 -d | sh -s docker.io/${{ secrets.DOCKERHUB_USERNAME }}/redisinsight action-amd64 ${{ needs.RedisInsight.outputs.version }}
64+
name: buildImage::RedisInsight
65+
on:
66+
workflow_dispatch:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
jobs:
2+
tools:
3+
runs-on: ubuntu-latest
4+
steps:
5+
- name: Checkout
6+
uses: actions/checkout@v3
7+
- name: Set up QEMU
8+
uses: docker/setup-qemu-action@v2
9+
- name: Set up Docker Buildx
10+
uses: docker/setup-buildx-action@v2
11+
- name: Login to DockerHub
12+
uses: docker/login-action@v2
13+
with:
14+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
15+
username: ${{ secrets.DOCKERHUB_USERNAME }}
16+
- name: Build and push
17+
uses: docker/build-push-action@v5
18+
with:
19+
context: .
20+
file: Dockerfile
21+
platforms: linux/amd64,linux/arm64
22+
provenance: false
23+
pull: true
24+
push: true
25+
sbom: false
26+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/alpine:tools
27+
name: buildImage::alpine
28+
on:
29+
workflow_dispatch:
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
jobs:
2+
repo-server:
3+
runs-on: ubuntu-latest
4+
steps:
5+
- name: Checkout
6+
uses: actions/checkout@v3
7+
- name: Set up QEMU
8+
uses: docker/setup-qemu-action@v2
9+
- name: Set up Docker Buildx
10+
uses: docker/setup-buildx-action@v2
11+
- name: Login to DockerHub
12+
uses: docker/login-action@v2
13+
with:
14+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
15+
username: ${{ secrets.DOCKERHUB_USERNAME }}
16+
- name: Build and push
17+
uses: docker/build-push-action@v5
18+
with:
19+
build-args: |-
20+
CACHE_IMAGE=${{ inputs.CACHE_IMAGE }}
21+
CACHE_VERSION=${{ inputs.CACHE_VERSION }}
22+
context: .
23+
file: argocd.Dockerfile
24+
platforms: linux/amd64,linux/arm64
25+
provenance: false
26+
pull: true
27+
push: true
28+
sbom: false
29+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/argocd-operator:plugins
30+
name: buildImage::argocd-plugins
31+
on:
32+
workflow_dispatch:
33+
inputs:
34+
CACHE_IMAGE:
35+
default: ghcr.io/helmfile/helmfile
36+
description: image name
37+
required: true
38+
type: string
39+
CACHE_VERSION:
40+
default: canary
41+
description: image tag
42+
required: true
43+
type: string

0 commit comments

Comments
 (0)