-
Notifications
You must be signed in to change notification settings - Fork 447
Update dependencies using github actions #5636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nawazkh
wants to merge
5
commits into
kubernetes-sigs:main
Choose a base branch
from
nawazkh:toolsDotYaml
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e7ab2d3
Update dependencies using github actions
nawazkh 673746a
drop kpromo, go-apidiff and setup-envtest
nawazkh 12988d0
drop kpromo, go-apidiff and setup-envtest
nawazkh e10e02e
print env variables
nawazkh 9f8bf2c
fix repo fetching bug
nawazkh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: Update Tool Versions | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-tools: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install yq, jq and gh | ||
run: | | ||
sudo apt-get update && sudo apt-get install -y jq | ||
curl -sL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/local/bin/yq | ||
chmod +x /usr/local/bin/yq | ||
curl -sL https://github.com/cli/cli/releases/download/v2.49.0/gh_2.49.0_linux_amd64.tar.gz | tar xz | ||
sudo cp gh_*/bin/gh /usr/local/bin/ | ||
|
||
- name: Create PRs for Updated Tools | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
set -euo pipefail | ||
file="hack/tools/tools.yaml" | ||
tools=$(yq eval '.tools | keys | .[]' $file) | ||
|
||
get_latest_release() { | ||
local repo=$1 | ||
curl -s "https://api.github.com/repos/$repo/releases/latest" | jq -r .tag_name | ||
} | ||
|
||
get_kustomize_latest_release() { | ||
local repo=$1 | ||
curl -s https://api.github.com/repos/$repo/releases/latest | jq -r '.tag_name' | sed 's|.*/||' | ||
} | ||
|
||
get_conversion_gen_latest_release() { | ||
local repo=$1 | ||
curl -s "https://api.github.com/repos/kubernetes/code-generator/tags?per_page=100" | jq -r '.[].name' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' |sort -V | tail -n1 | ||
} | ||
|
||
declare -A repos=( | ||
[controller-gen]="kubernetes-sigs/controller-tools" | ||
[conversion-gen]="kubernetes/code-generator" | ||
[kustomize]="kubernetes-sigs/kustomize" | ||
[azwi]="Azure/azure-workload-identity" | ||
[mockgen]="golang/mock" | ||
[release-notes]="kubernetes/release" | ||
[kubectl]="kubernetes/kubernetes" | ||
[helm]="helm/helm" | ||
[yq]="mikefarah/yq" | ||
[kind]="kubernetes-sigs/kind" | ||
[codespell]="codespell-project/codespell" | ||
) | ||
|
||
for tool in "${!repos[@]}"; do | ||
repo="${repos[$tool]}" | ||
current=$(yq ".tools.$tool" $file) | ||
|
||
if [[ "$tool" == "kubectl" ]]; then | ||
latest="$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)" | ||
elif [[ "$tool" == "kustomize" ]]; then | ||
latest=$(get_kustomize_latest_release $repo) | ||
elif [[ "$tool" == "conversion-gen" ]]; then | ||
latest=$(get_conversion_gen_latest_release $repo) | ||
else | ||
latest=$(get_latest_release $repo) | ||
fi | ||
|
||
if [[ "$current" != "$latest" ]]; then | ||
echo "$tool" | ||
echo "$current" | ||
echo "$latest" | ||
branch="update-tool-$tool-$latest" | ||
echo "Updating $tool from $current to $latest" | ||
git checkout -b "$branch" | ||
yq -i ".tools.$tool = \"$latest\"" "$file" | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add "$file" | ||
git commit -m "dependency: bump $tool to $latest" | ||
git push origin "$branch" --force | ||
|
||
gh pr create \ | ||
--title "[dependency] bump $tool to $latest" \ | ||
--body "This PR updates \`$tool\` from \`$current\` to \`$latest\`." \ | ||
--base main \ | ||
--label "dependencies,area/dependency,release-note/none,ok-to-test" \ | ||
--head "$branch" | ||
else | ||
echo "$tool is already up to date ($current)" | ||
fi | ||
|
||
git checkout main | ||
git reset --hard origin/main | ||
git clean -fd | ||
done |
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
tools: | ||
controller-gen: v0.16.1 | ||
conversion-gen: v0.31.0 | ||
kustomize: v5.4.1 | ||
azwi: v1.2.2 | ||
mockgen: v0.4.0 | ||
release-notes: v0.18.0 | ||
kubectl: v1.29.10 | ||
helm: v3.14.4 | ||
yq: v4.35.2 | ||
kind: v0.27.0 | ||
codespell: 2.2.6 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is just reorganizing the Makefile.