-
Notifications
You must be signed in to change notification settings - Fork 15
137 lines (116 loc) · 6.41 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Build
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build app
id: build_app
run: |
set -eux
APP=kubernetes
APP_VERSION=$(cat kube_version.txt)
# APP_VERSION=$(git ls-remote --tags | grep 'v[1-9]\.[0-9]*\.[0-9]*$' | awk -F'tags/' '{print $2}')
APP_REPO="https://github.com/kubernetes/kubernetes.git"
ADD_TAG=""
tags="$(git ls-remote --tags $APP_REPO | grep 'v[1-9]\.[0-9]*\.[0-9]*$' | awk -F'tags/' '{print $2}' | sort -t. -k1,1n -k2,2n -k3,3n)"
new_tags="$(printf "%s" "$tags"| sed -n '{/\.0$/{g;p}};h' | tail -5) $(printf "%s" "$tags" | tail -1) v1.21.10 v1.22.7 v1.23.4"
echo -e "[Tags] $new_tags"
for t in $new_tags; do
echo "[check] $t"
b=$(echo "${APP_VERSION}" | grep -w ${t} | wc -l)
if [[ $b == 0 ]]; then
echo "::group::[Build] $t"
git clone -q --depth=1 --branch $t --progress "${APP_REPO}"
pushd ${APP}
git checkout -b $t $t
git branch
sed -i 's#time.Hour \* 24 \* 365#time.Hour * 24 * 365 * 10#g' cmd/kubeadm/app/constants/constants.go
grep -n -R CertificateValidity ./*
grep -n -R duration365d ./*
build_version=$(cat build/build-image/cross/VERSION)
docker pull registry.k8s.io/build-image/kube-cross:${build_version}
./build/run.sh make kubeadm KUBE_BUILD_PLATFORMS=linux/amd64 >/dev/null
ls -l _output/dockerized/bin/linux/amd64/
./build/run.sh make kubeadm KUBE_BUILD_PLATFORMS=linux/arm64 >/dev/null
ls -l _output/dockerized/bin/linux/arm64/
./build/run.sh make kubeadm KUBE_BUILD_PLATFORMS=darwin/amd64 >/dev/null
ls -l _output/dockerized/bin/darwin/amd64/
./build/run.sh make kubeadm KUBE_BUILD_PLATFORMS=windows/amd64 >/dev/null
ls -l _output/dockerized/bin/windows/amd64/
cp _output/dockerized/bin/linux/arm64/kubeadm _output/kubeadm-linux-arm64 || return 1
cp _output/dockerized/bin/linux/amd64/kubeadm _output/kubeadm-linux-amd64 || return 1
cp _output/dockerized/bin/darwin/amd64/kubeadm _output/kubeadm-darwin-amd64 || return 1
cp _output/dockerized/bin/windows/amd64/kubeadm.exe _output/kubeadm-windows-amd64.exe || return 1
md5sum _output/kubeadm-linux-arm64 > _output/kubeadm-linux-arm64.md5 && sha256sum _output/kubeadm-linux-arm64 > _output/kubeadm-linux-arm64.sha256
md5sum _output/kubeadm-linux-amd64 > _output/kubeadm-linux-amd64.md5 && sha256sum _output/kubeadm-linux-amd64 > _output/kubeadm-linux-amd64.sha256
md5sum _output/kubeadm-darwin-amd64 > _output/kubeadm-darwin-amd64.md5 && sha256sum _output/kubeadm-darwin-amd64 > _output/kubeadm-darwin-amd64.sha256
md5sum _output/kubeadm-windows-amd64.exe > _output/kubeadm-windows-amd64.exe.md5 && sha256sum _output/kubeadm-windows-amd64.exe > _output/kubeadm-windows-amd64.exe.sha256
ls -al _output/kubeadm-*
_output/kubeadm-linux-amd64 version
echo "::debug::[certs] test"
sudo _output/kubeadm-linux-amd64 init phase certs all
sudo _output/kubeadm-linux-amd64 init phase kubeconfig all
sudo _output/kubeadm-linux-amd64 certs check-expiration || sudo _output/kubeadm-linux-amd64 alpha certs check-expiration
ADD_TAG=$t
echo "[ADD_TAG] ${ADD_TAG}"
[[ "x${ADD_TAG:-}" == "x" ]] && return 1 || echo ok
echo "ADD_TAG=${ADD_TAG}" >> $GITHUB_OUTPUT
echo -e "Set the validity period of the kubeadm certificate to 10 years. \nrepo: https://github.com/kubernetes/kubernetes/releases/tag/${ADD_TAG}\n" > _output/CHECKSUMS.txt
cat _output/kubeadm-linux-{amd64,arm64}.{md5,sha256} >> _output/CHECKSUMS.txt
cat _output/kubeadm-darwin-amd64.{md5,sha256} >> _output/CHECKSUMS.txt
cat _output/kubeadm-windows-amd64.exe.{md5,sha256} >> _output/CHECKSUMS.txt
echo "::debug::[Push file]"
cd ${GITHUB_WORKSPACE}
echo "${ADD_TAG}" >> kube_version.txt
git config --global user.email "[email protected]"
git config --global user.name "lework"
git config --global --add safe.directory /github/workspace
git add kube_version.txt
git commit -m "add kubeadm $ADD_TAG (Github Actions Automatically Built in `date +"%Y-%m-%d %H:%M"`)"
echo "::endgroup::"
popd
break
else
echo "::debug::[skip] $t"
fi
done
- name: Push changes
uses: ad-m/github-push-action@master
if: ${{ steps.build_app.outputs.ADD_TAG != '' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ steps.build_app.outputs.ADD_TAG != '' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: "${{ steps.build_app.outputs.ADD_TAG }}"
files: |
./kubernetes/_output/kubeadm-linux-arm64
./kubernetes/_output/kubeadm-linux-arm64.md5
./kubernetes/_output/kubeadm-linux-arm64.sha256
./kubernetes/_output/kubeadm-linux-amd64
./kubernetes/_output/kubeadm-linux-amd64.md5
./kubernetes/_output/kubeadm-linux-amd64.sha256
./kubernetes/_output/kubeadm-darwin-amd64
./kubernetes/_output/kubeadm-darwin-amd64.md5
./kubernetes/_output/kubeadm-darwin-amd64.sha256
./kubernetes/_output/kubeadm-windows-amd64.exe
./kubernetes/_output/kubeadm-windows-amd64.exe.md5
./kubernetes/_output/kubeadm-windows-amd64.exe.sha256
body_path: ./kubernetes/_output/CHECKSUMS.txt