From f041669ecd0b6564aab68809b1f379f45e6cb614 Mon Sep 17 00:00:00 2001 From: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:52:36 +0530 Subject: [PATCH] Add workflow to automatically update go Bump go to latest Signed-off-by: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> --- .github/workflows/golangci-lint.yml | 8 +++--- .github/workflows/release.yml | 2 +- .github/workflows/test-gh-k8s-1.16.yml | 14 +++------ .github/workflows/test-gh.yml | 14 +++------ .github/workflows/trivy-scan.yml | 1 - .github/workflows/update-go.yml | 40 ++++++++++++++++++++++++++ go.mod | 2 +- hack/build.sh | 9 +----- 8 files changed, 55 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/update-go.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 76ffba277..293a38802 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -12,13 +12,13 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - uses: actions/checkout@v4 with: fetch-depth: '0' + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d057c621..58c2022c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version-file: go.mod - name: Set up Cosign uses: sigstore/cosign-installer@v3 diff --git a/.github/workflows/test-gh-k8s-1.16.yml b/.github/workflows/test-gh-k8s-1.16.yml index df5e3bde3..3ef6c8eb3 100644 --- a/.github/workflows/test-gh-k8s-1.16.yml +++ b/.github/workflows/test-gh-k8s-1.16.yml @@ -10,22 +10,16 @@ jobs: name: Test GH 1.21 runs-on: ubuntu-20.04 steps: - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - name: Check out code into the Go module directory uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 with: - path: src/github.com/${{ github.repository }} - fetch-depth: 0 + go-version-file: go.mod - name: Run Tests run: | set -e -x - export GOPATH=$(pwd) - cd src/github.com/${{ github.repository }} - # Install ytt for build mkdir -p /tmp/bin export PATH=/tmp/bin:$PATH @@ -42,7 +36,7 @@ jobs: # Ensure that there is no existing kapp installed rm -f /tmp/bin/kapp - ./hack/build-binaries.sh + ./hack/build.sh export KAPP_E2E_NAMESPACE=kapp-test kubectl create ns $KAPP_E2E_NAMESPACE diff --git a/.github/workflows/test-gh.yml b/.github/workflows/test-gh.yml index 8887ac947..05ec5885d 100644 --- a/.github/workflows/test-gh.yml +++ b/.github/workflows/test-gh.yml @@ -10,22 +10,16 @@ jobs: name: Test GH runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - name: Check out code into the Go module directory uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 with: - path: src/github.com/${{ github.repository }} - fetch-depth: 0 + go-version-file: go.mod - name: Run Tests run: | set -e -x - export GOPATH=$(pwd) - cd src/github.com/${{ github.repository }} - # Install ytt for build mkdir -p /tmp/bin export PATH=/tmp/bin:$PATH @@ -42,7 +36,7 @@ jobs: # Ensure that there is no existing kapp installed rm -f /tmp/bin/kapp - ./hack/build-binaries.sh + ./hack/build.sh export KAPP_E2E_NAMESPACE=kapp-test kubectl create ns $KAPP_E2E_NAMESPACE diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index 0da208354..80bf3afdd 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -11,7 +11,6 @@ jobs: with: repo: carvel-dev/kapp tool: kapp - goVersion: '1.22' secrets: githubToken: ${{ secrets.GITHUB_TOKEN }} slackWebhookURL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/update-go.yml b/.github/workflows/update-go.yml new file mode 100644 index 000000000..ce133b1f6 --- /dev/null +++ b/.github/workflows/update-go.yml @@ -0,0 +1,40 @@ +name: go-updater + +on: + schedule: + - cron: '0 12 * * *' + workflow_dispatch: + +jobs: + update-go: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.2 + with: + fetch-depth: 0 + - name: Set up Go 1.x + uses: actions/setup-go@v5 + with: + go-version: 'stable' + check-latest: true + - name: Update Go + run: go get go + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.CARVEL_BOT_ACCESS_TOKEN }} + committer: Carvel Bot + author: Carvel Bot + commit-message: | + Bump go + + Signed-off-by: Carvel Bot + title: Bump go + delete-branch: true + body: | + Auto-generated by https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + + Signed-off-by: Carvel Bot + base: develop + branch: bump-go diff --git a/go.mod b/go.mod index ab3bd123e..f9fe0a801 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module carvel.dev/kapp -go 1.22.3 +go 1.22.5 require ( github.com/cppforlife/cobrautil v0.0.0-20221130162803-acdfead391ef diff --git a/hack/build.sh b/hack/build.sh index 4b4fb7b52..9bec3cce0 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -2,21 +2,14 @@ set -e -x -u -function get_latest_git_tag { - git describe --tags | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' -} - -VERSION="${1:-`get_latest_git_tag`}" - # makes builds reproducible export CGO_ENABLED=0 -LDFLAGS="-X carvel.dev/kapp/pkg/kapp/version.Version=$VERSION -buildid=" go mod vendor go mod tidy go fmt ./cmd/... ./pkg/... ./test/... -go build -ldflags="$LDFLAGS" -trimpath -o kapp ./cmd/kapp/... +go build -trimpath -o kapp ./cmd/kapp/... ./kapp version # compile tests, but do not run them: https://github.com/golang/go/issues/15513#issuecomment-839126426