Skip to content

Commit

Permalink
Add separate Golan Bump job for 7.17 (#35942)
Browse files Browse the repository at this point in the history
Due to some differences between main and 7.17 we need this second job
to account for it and have better automation.
  • Loading branch information
rdner authored Jun 28, 2023
1 parent 3639b2e commit 26827e7
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 2 deletions.
144 changes: 144 additions & 0 deletions .ci/bump-golang-7.17.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---
name: Bump golang-version to latest version in 7.17
pipelineid: "bump-golang-version-7.17"

scms:
githubConfig:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
owner: elastic
repository: beats
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
branch: 7.17

actions:
beats:
kind: github/pullrequest
scmid: githubConfig
sourceid: latestGoVersion
title: '[Automation][7.17] Bump Golang version to {{ source "latestGoVersion" }}'
spec:
automerge: false
labels:
- dependencies
- backport-skip
description: |
Generated automatically with {{ requiredEnv "JOB_URL" }}
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: v
spec:
owner: elastic
repository: golang-crossbuild
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
versionfilter:
kind: regex
pattern: v1\.{{ 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"
sourceid: latestGoVersion
scmid: githubConfig
kind: file
spec:
content: '{{ source "latestGoVersion" }}'
file: .go-version
matchpattern: '\d+.\d+.\d+'
update-golang.ci:
name: "Update .golangci.yml"
sourceid: latestGoVersion
scmid: githubConfig
kind: file
spec:
content: '{{ source "latestGoVersion" }}'
file: .golangci.yml
matchpattern: '\d+.\d+.\d+'
update-version.asciidoc:
name: "Update version.asciidoc"
sourceid: latestGoVersion
scmid: githubConfig
kind: file
spec:
content: ':go-version: {{ source "latestGoVersion" }}'
file: libbeat/docs/version.asciidoc
matchpattern: ':go-version: \d+.\d+.\d+'
update-dockerfiles:
name: "Update from dockerfiles"
sourceid: latestGoVersion
scmid: githubConfig
kind: file
spec:
content: 'FROM golang:{{ source "latestGoVersion" }}'
# This list differs from the main branch, this is the main reason we have a separate job
files:
- ./metricbeat/Dockerfile
- ./metricbeat/module/vsphere/_meta/Dockerfile
- ./metricbeat/module/nats/_meta/Dockerfile
- ./metricbeat/module/http/_meta/Dockerfile
- ./filebeat/Dockerfile
- ./auditbeat/Dockerfile
- ./heartbeat/Dockerfile
- ./packetbeat/Dockerfile
- ./libbeat/Dockerfile
- ./x-pack/metricbeat/module/stan/_meta/Dockerfile
- ./x-pack/functionbeat/Dockerfile
- ./x-pack/libbeat/Dockerfile
matchpattern: 'FROM golang:\d+.\d+.\d+'
update-gomod:
name: "Update go.mod"
sourceid: gomod
scmid: githubConfig
kind: file
spec:
content: 'go {{ source "gomod" }}'
file: go.mod
matchpattern: 'go \d+.\d+'
10 changes: 8 additions & 2 deletions .github/workflows/bump-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: bump-golang

on:
schedule:
- cron: '0 20 * * 6'
- cron: "0 20 * * 6"

permissions:
contents: read
Expand All @@ -15,7 +15,6 @@ jobs:
bump:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3

- uses: elastic/apm-pipeline-library/.github/actions/updatecli@current
Expand All @@ -24,3 +23,10 @@ jobs:
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
pipeline: ./.ci/bump-golang.yml

- 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-7.17.yml

0 comments on commit 26827e7

Please sign in to comment.