Skip to content

Auto release minor version and notify new large version #3020

Auto release minor version and notify new large version

Auto release minor version and notify new large version #3020

name: Auto release minor version and notify new large version
on:
push:
branches:
- main
schedule:
- cron: "0 */2 * * *"
jobs:
notification:
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@master
with:
fetch-depth: 0
- name: check version
shell: bash
run: |
#!/bin/bash
set -x
git config --global user.name "buxiaomo"
git config --global user.email "[email protected]"
git fetch
KUBE_VERSION=$(curl -s 'https://api.github.com/repos/kubernetes/kubernetes/tags?page=1&per_page=100' | jq -r '.[] | select(.name | test("^v[0-9]+.[0-9]+.[0-9]+$")) | .name' | sort -rV | awk -F. 'a[$1$2]++ == 0 {print}' | awk '{print $1}')
for version in ${KUBE_VERSION[@]}; do
branch=${version::5}
if [[ $(git branch -a | grep "${branch}") ]]; then
git checkout ${branch}
git pull
if ! grep -E "^KUBE_VERSION:=${version:1}" Makefile ; then
echo "upgrade kubernetes to ${version}"
sed -i "s/^KUBE_VERSION:=.*/KUBE_VERSION:=${version:1}/g" Makefile
git add Makefile
git commit -m "upgrade kubernetes to ${version}"
git push origin ${branch}
git tag -a -m $(git rev-parse HEAD) ${version}
git push -v origin refs/tags/${version}
curl -X POST \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: Bearer ${{ secrets.TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/dispatches" \
-d '{"event_type": "auto-release-package", "client_payload": {"tag": "'"${version}"'"}}'
fi
else
NEW_VERSION[${#NEW_VERSION[*]}]=${version}
fi
done
if [ ${#NEW_VERSION[*]} != 0 ];then
echo "NEW_VERSION=${NEW_VERSION[*]}" >> $GITHUB_ENV
fi
- name: notify to slack
uses: buxiaomo/slack-notify@v1
if: env.NEW_VERSION
with:
channel: "#kubeasy"
username: "webhookbot"
icon_url: "https://avatars.githubusercontent.com/u/65916846?v=4"
title: "A new version of kubernetes has been released"
text: "${{ env.NEW_VERSION }}"
webhook_url: "${{ secrets.SLACK_WEBHOOK }}"