Skip to content

Commit 78396f2

Browse files
committed
Bot to bump go version and dependencies
Signed-off-by: oumk <oumk@jfrog.com>
1 parent a696810 commit 78396f2

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/bump-up-pr.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Bump Go and Dependencies
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- pr-bump-up
8+
9+
jobs:
10+
bump:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
# Find the latest stable Go version
17+
- name: Get latest Go version
18+
id: go-version
19+
run: |
20+
LATEST=$(curl -s https://go.dev/VERSION?m=text | head -n1 | sed 's/go//')
21+
echo "version=$LATEST" >> $GITHUB_OUTPUT
22+
23+
- name: Show detected Go version
24+
run: echo "Latest Go version is ${{ steps.go-version.outputs.version }}"
25+
26+
# Update go.mod 'go' directive if needed
27+
- name: Update go.mod Go version
28+
run: |
29+
CURRENT=$(grep '^go ' go.mod | awk '{print $2}')
30+
NEW=${{ steps.go-version.outputs.version }}
31+
if [ "$CURRENT" != "$NEW" ]; then
32+
echo "Updating Go version from $CURRENT to $NEW"
33+
sed -i "s/^go .*/go $NEW/" go.mod
34+
else
35+
echo "Go version already up-to-date ($CURRENT)"
36+
fi
37+
38+
# Update dependencies
39+
- name: Update dependencies
40+
run: |
41+
go get -u ./...
42+
go mod tidy
43+
44+
# Try building the project
45+
- name: Build project
46+
id: build
47+
continue-on-error: true
48+
run: |
49+
echo "Running go build..."
50+
if go build ./...; then
51+
echo "build_status=success" >> $GITHUB_OUTPUT
52+
echo "✅ Build succeeded"
53+
else
54+
echo "build_status=failure" >> $GITHUB_OUTPUT
55+
echo "❌ Build failed"
56+
fi
57+
58+
# Commit and open PR
59+
- name: Create PR
60+
uses: peter-evans/create-pull-request@v6
61+
with:
62+
token: ${{ secrets.GITHUB_TOKEN }}
63+
commit-message: "Bumping up Go version and dependencies"
64+
title: "Bump: bump Go version and dependencies"
65+
branch: "chore/go-bump"
66+
body: |
67+
This PR updates the Go toolchain version and all dependencies.
68+
69+
**Build status:** ${{ steps.build.outputs.build_status == 'success' && '✅ Successful' || '❌ Failed' }}
70+
71+
---
72+
_Automated bump workflow run by GitHub Actions._

0 commit comments

Comments
 (0)