Build #214
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |