-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yaokl
committed
Feb 19, 2024
1 parent
75284e4
commit 6cc089a
Showing
1 changed file
with
36 additions
and
80 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Build kubeadm | ||
id: build_kubeadm | ||
- name: Build app | ||
id: build_app | ||
run: | | ||
set -eux | ||
APP=kubernetes | ||
|
@@ -30,7 +30,6 @@ jobs: | |
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" | ||
mkdir -p $GOPATH/src/k8s.io && cd $GOPATH/src/k8s.io | ||
for t in $new_tags; do | ||
echo "[check] $t" | ||
|
@@ -54,17 +53,27 @@ jobs: | |
./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/386 >/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/386/kubeadm _output/kubeadm-linux-386 || return 1 | ||
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 _output/kubeadm-windows-amd64 || return 1 | ||
ls -al _output/kubeadm-* | ||
_output/kubeadm-linux-386 version | ||
_output/kubeadm-linux-amd64 version | ||
md5sum _output/kubeadm-linux-386 > _output/kubeadm-linux-386.md5 && sha256sum _output/kubeadm-linux-386 > _output/kubeadm-linux-386.sha256 | ||
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 > _output/kubeadm-windows-amd64.md5 && sha256sum _output/kubeadm-windows-amd64 > _output/kubeadm-windows-amd64.sha256 | ||
echo "::debug::[certs] test" | ||
sudo _output/kubeadm-linux-amd64 init phase certs all | ||
|
@@ -77,99 +86,46 @@ jobs: | |
echo "::debug::[Push file]" | ||
echo "${ADD_TAG}" >> kube_version.txt | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "lework" | ||
git remote rm origin | ||
git remote add origin https://${GITHUB_TOKEN}@github.com/lework/kubeadm-certs.git > /dev/null 2>&1 | ||
git add -A | ||
git commit -m "add kubeadm $kube_tag" | ||
git push origin master | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "lework" | ||
git config --global --add safe.directory /github/workspace | ||
git add version.txt | ||
git add kube_version.txt | ||
git commit -m "add kubeadm $ADD_TAG (Github Actions Automatically Built in `date +"%Y-%m-%d %H:%M"`)" | ||
echo "ADD_TAG=${ADD_TAG}" >> $GITHUB_OUTPUT | ||
cat _output/kubeadm-linux-{amd64,386}.{md5,sha256} > CHECKSUMS.txt | ||
echo "::endgroup::" | ||
popd | ||
break | ||
break | ||
else | ||
echo "[skip] $t" | ||
fi | ||
one | ||
|
||
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 | ||
|
||
# golang:1.19.2-alpine3.16 | ||
docker pull golang:1.19.2-alpine3.16 | ||
# Linux builds | ||
docker run --rm -t -v $PWD:/build golang:1.19.2-alpine3.16 sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -mod=vendor '-buildmode=pie' -ldflags '-extldflags -static' -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-linux-amd64 ./cmd/skopeo && md5sum ./bin/skopeo-linux-amd64 > ./bin/skopeo-linux-amd64.md5 && sha256sum ./bin/skopeo-linux-amd64 > ./bin/skopeo-linux-amd64.sha256" | ||
|
||
docker run --rm -t -v $PWD:/build golang:1.19.2-alpine3.16 sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=linux GOARCH=arm64 go build -mod=vendor '-buildmode=pie' -ldflags '-extldflags -static' -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-linux-arm64 ./cmd/skopeo && md5sum ./bin/skopeo-linux-arm64 > ./bin/skopeo-linux-arm64.md5 && sha256sum ./bin/skopeo-linux-arm64 > ./bin/skopeo-linux-arm64.sha256" | ||
# Darwin builds | ||
docker run --rm -t -v $PWD:/build golang:1.19.2-alpine3.16 sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -mod=vendor -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-darwin-amd64 ./cmd/skopeo && md5sum ./bin/skopeo-darwin-amd64 > ./bin/skopeo-darwin-amd64.md5 && sha256sum ./bin/skopeo-darwin-amd64 > ./bin/skopeo-darwin-amd64.sha256" | ||
|
||
docker run --rm -t -v $PWD:/build golang:1.19.2-alpine3.16 sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=darwin GOARCH=arm64 go build -mod=vendor -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-darwin-arm64 ./cmd/skopeo && md5sum ./bin/skopeo-darwin-arm64 > ./bin/skopeo-darwin-arm64.md5 && sha256sum ./bin/skopeo-darwin-arm64 > ./bin/skopeo-darwin-arm64.sha256" | ||
ls -al bin/ | ||
cd ../ | ||
ls -al ./ | ||
ADD_TAG=$t | ||
|
||
echo "::debug::[Push file]" | ||
echo "${t}" >> 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 version.txt | ||
git commit -m "$APP $ADD_TAG (Github Actions Automatically Built in `date +"%Y-%m-%d %H:%M"`)" | ||
echo "ADD_TAG=${ADD_TAG}" >> $GITHUB_OUTPUT | ||
cat ./skopeo/bin/skopeo-{darwin,linux}-{amd64,arm64}.{md5,sha256} > CHECKSUMS.txt | ||
echo "Set the validity period of the kubeadm certificate to 10 years. \n source: ${APP_REPO}/releases/tag/${ADD_TAG}" > CHECKSUMS.txt | ||
cat _output/kubeadm-{linux,darwin,windows}-{amd64,arm64}.{md5,sha256} >> CHECKSUMS.txt | ||
echo "::endgroup::" | ||
popd | ||
break | ||
else | ||
echo "::debug::[skip] $t" | ||
fi | ||
done | ||
done | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
if: ${{ steps.build_skopeo.outputs.ADD_TAG != '' }} | ||
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_skopeo.outputs.ADD_TAG != '' }} | ||
if: ${{ steps.build_app.outputs.ADD_TAG != '' }} | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag_name: "${{ steps.build_skopeo.outputs.ADD_TAG }}" | ||
tag_name: "${{ steps.build_app.outputs.ADD_TAG }}" | ||
files: | | ||
./skopeo/bin/skopeo-linux-amd64 | ||
./skopeo/bin/skopeo-linux-amd64.md5 | ||
./skopeo/bin/skopeo-linux-amd64.sha256 | ||
./skopeo/bin/skopeo-linux-arm64 | ||
./skopeo/bin/skopeo-linux-arm64.md5 | ||
./skopeo/bin/skopeo-linux-arm64.sha256 | ||
./skopeo/bin/skopeo-darwin-amd64 | ||
./skopeo/bin/skopeo-darwin-amd64.md5 | ||
./skopeo/bin/skopeo-darwin-amd64.sha256 | ||
./skopeo/bin/skopeo-darwin-arm64 | ||
./skopeo/bin/skopeo-darwin-arm64.md5 | ||
./skopeo/bin/skopeo-darwin-arm64.sha256 | ||
./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 | ||
./kubernetes/_output/kubeadm-windows-amd64.md5 | ||
./kubernetes/_output/kubeadm-windows-amd64.sha256 | ||
body_path: ./CHECKSUMS.txt |