From 4bd431d0ce1aa7bf71fa9c45a24f036bdc9b4491 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 8 May 2024 11:14:39 +0200 Subject: [PATCH] updatecli: verify commits for golang and beats (#13107) (cherry picked from commit 8182fb1305b8704f4ade4d29bd7e3844cb3a6778) # Conflicts: # .ci/bump-golang.yml # .github/workflows/bump-golang.yml # .github/workflows/update-beats.yml --- .ci/bump-golang.yml | 111 +++++++++++++++++++++++ .ci/update-beats.yml | 5 +- .github/workflows/bump-elastic-stack.yml | 1 - .github/workflows/bump-golang.yml | 24 +++++ .github/workflows/update-beats.yml | 5 + 5 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 .ci/bump-golang.yml create mode 100644 .github/workflows/bump-golang.yml diff --git a/.ci/bump-golang.yml b/.ci/bump-golang.yml new file mode 100644 index 00000000000..980d6480640 --- /dev/null +++ b/.ci/bump-golang.yml @@ -0,0 +1,111 @@ +--- +name: Bump golang-version to latest version +pipelineid: 'updatecli-bump-golang' + +actions: + default: + title: '[updatecli] Bump Golang version to {{ source "latestGoVersion" }}' + kind: github/pullrequest + scmid: default + spec: + labels: + - automation + - backport-skip + - dependencies + description: |- + ### What + Bump go release version with the latest release. + + ### Further details + See [changelog](https://github.com/golang/go/issues?q=milestone%3AGo{{ source "latestGoVersion" }}+label%3ACherryPickApproved) for {{ source "latestGoVersion" }} + +scms: + default: + kind: github + spec: + user: '{{ requiredEnv "GITHUB_ACTOR" }}' + owner: elastic + repository: apm-server + token: '{{ requiredEnv "GITHUB_TOKEN" }}' + branch: main + commitusingapi: true + +sources: + minor: + name: Get minor version in .go-version + kind: shell + transformers: + - findsubmatch: + pattern: '^\d+.(\d+).\d+$' + captureindex: 1 + spec: + command: cat .go-version + + latestGoVersion: + name: Get Latest Go Release + kind: githubrelease + dependson: + - minor + transformers: + - trimprefix: go + spec: + owner: golang + repository: go + token: '{{ requiredEnv "GITHUB_TOKEN" }}' + username: '{{ requiredEnv "GIT_USER" }}' + versionfilter: + kind: regex + pattern: go1\.{{ source "minor" }}\.\d*$ + + gomod: + dependson: + - latestGoVersion + name: Get version in go.mod format + kind: shell + transformers: + - findsubmatch: + pattern: '^(\d+.\d+).\d*' + captureindex: 1 + spec: + command: echo {{ source "latestGoVersion" }} + +conditions: + dockerTag: + name: Is docker image golang:{{ source "latestGoVersion" }} published + kind: dockerimage + spec: + image: golang + tag: '{{ source "latestGoVersion" }}' + sourceid: latestGoVersion + + goDefaultVersion-check: + name: Check if defined golang version differs + kind: shell + sourceid: latestGoVersion + spec: + command: 'grep -v -q {{ source "latestGoVersion" }} .go-version #' + +targets: + update-go-version: + name: 'Update .go-version with Golang version {{ source "latestGoVersion" }}' + sourceid: latestGoVersion + scmid: default + kind: file + spec: + content: '{{ source "latestGoVersion" }}' + file: .go-version + matchpattern: '\d+.\d+.\d+' + update-gomod: + name: 'Update go.mod files with {{ source "gomod" }}' + sourceid: gomod + scmid: default + kind: file + spec: + content: 'go {{ source "gomod" }}' + files: + - go.mod + - cmd/intake-receiver/go.mod + - internal/glog/go.mod + - systemtest/go.mod + - tools/go.mod + matchpattern: 'go \d+.\d+' diff --git a/.ci/update-beats.yml b/.ci/update-beats.yml index 85c5882bfef..21b1953faad 100644 --- a/.ci/update-beats.yml +++ b/.ci/update-beats.yml @@ -6,13 +6,12 @@ scms: default: kind: github spec: - user: '{{ requiredEnv "GIT_USER" }}' - email: '{{ requiredEnv "GIT_EMAIL" }}' + user: '{{ requiredEnv "GITHUB_ACTOR" }}' owner: elastic repository: apm-server token: '{{ requiredEnv "GITHUB_TOKEN" }}' - username: '{{ requiredEnv "GIT_USER" }}' branch: '{{ requiredEnv "BRANCH_NAME" }}' + commitusingapi: true actions: default: diff --git a/.github/workflows/bump-elastic-stack.yml b/.github/workflows/bump-elastic-stack.yml index 9aba7279f46..fb7adba4bb7 100644 --- a/.github/workflows/bump-elastic-stack.yml +++ b/.github/workflows/bump-elastic-stack.yml @@ -39,4 +39,3 @@ jobs: command: '--experimental apply' env: BRANCH: ${{ matrix.branch }} - GITHUB_ACTOR: ${{ github.actor }} diff --git a/.github/workflows/bump-golang.yml b/.github/workflows/bump-golang.yml new file mode 100644 index 00000000000..3fbcd7558da --- /dev/null +++ b/.github/workflows/bump-golang.yml @@ -0,0 +1,24 @@ +--- +name: bump-golang + +on: + workflow_dispatch: + schedule: + - cron: '0 20 * * 6' + +permissions: + contents: read + +jobs: + bump: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v4 + - uses: elastic/apm-pipeline-library/.github/actions/updatecli@current + with: + vaultUrl: ${{ secrets.VAULT_ADDR }} + vaultRoleId: ${{ secrets.VAULT_ROLE_ID }} + vaultSecretId: ${{ secrets.VAULT_SECRET_ID }} + pipeline: ./.ci/bump-golang.yml + command: '--experimental apply' diff --git a/.github/workflows/update-beats.yml b/.github/workflows/update-beats.yml index 78396b32d57..75e046671ed 100644 --- a/.github/workflows/update-beats.yml +++ b/.github/workflows/update-beats.yml @@ -38,7 +38,12 @@ jobs: vaultRoleId: ${{ secrets.VAULT_ROLE_ID }} vaultSecretId: ${{ secrets.VAULT_SECRET_ID }} pipeline: ./.ci/update-beats.yml +<<<<<<< HEAD - if: always() +======= + command: '--experimental apply' + - if: failure() +>>>>>>> 8182fb130 (updatecli: verify commits for golang and beats (#13107)) uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current with: vaultUrl: ${{ secrets.VAULT_ADDR }}