Skip to content

Commit

Permalink
enable auto-bump golang (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Nov 6, 2023
1 parent e3565b8 commit ba920ff
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/bump-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@ permissions:
pull-requests: write
contents: write

env:
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

jobs:
bump:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Git
uses: elastic/apm-pipeline-library/.github/actions/setup-git@current

- name: Install Updatecli in the runner
uses: updatecli/updatecli-action@453502948b442d7b9a923de7b40cc7ce8628505c
uses: updatecli/updatecli-action@22fc20fc94d2482874876b66b797e2a4a7178445

- name: Run Updatecli
env:
GITHUB_TOKEN: ${{ github.token }}
run: updatecli apply --config ./.ci/bump-golang.yml
run: updatecli apply --config ./.github/workflows/updatecli.d/bump-golang.yml
117 changes: 117 additions & 0 deletions .github/workflows/updatecli.d/bump-golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
name: Bump golang-version to latest version

scms:
githubConfig:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
owner: elastic
repository: elastic-agent-autodiscover
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
branch: main

actions:
elastic-agent-autodiscover:
title: '[updatecli] Bump Golang version to {{ source "latestGoVersion" }}'
kind: github/pullrequest
scmid: githubConfig
sourceid: latestGoVersion
spec:
automerge: false
labels:
- dependencies
- backport-skip
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" }}
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: 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"
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-gomod:
name: "Update go.mod"
sourceid: gomod
scmid: githubConfig
kind: file
spec:
content: 'go {{ source "gomod" }}'
file: go.mod
matchpattern: 'go \d+.\d+'

0 comments on commit ba920ff

Please sign in to comment.