check-kubebuilder-release #358
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: check-kubebuilder-release | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: check | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
latest_version="$(curl --silent "https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases" | jq -r '. | sort_by(.published_at) | reverse | .[] | select(.tag_name | test("^v[0-9]+.[0-9]+.0$") ) | .tag_name' | head -1)" | |
latest_minor_version="${latest_version%.*}" | |
current_version="$(grep '\[kubebuilder\]' README.md | sed 's/.*\(v[0-9]\+.[0-9]\+.[0-9]\+\).*/\1/')" | |
current_minor_version="${current_version%.*}" | |
echo "current: $current_version ($current_minor_version), latest: $latest_version ($latest_minor_version)" | |
if [ "$current_minor_version" = "$latest_minor_version" ]; then | |
echo "latest minor version" | |
else | |
echo "new version exists" | |
title="Upgrade kubebuilder to $latest_version" | |
issue_cnt="$(gh issue list --search "$title" --json 'id' | jq length)" | |
if [ "$issue_cnt" -gt 0 ];then | |
echo "issue already exists" | |
else | |
gh issue create --title "$title" --body "kubebuilder [$latest_version](https://github.com/kubernetes-sigs/kubebuilder/releases/$latest_version) has been released." --assignee nakamasato | |
fi | |
fi |