Skip to content

Commit 4be23d5

Browse files
authored
feat: add updatecli autobump (#71)
1 parent 1fd8baf commit 4be23d5

File tree

11 files changed

+145
-1
lines changed

11 files changed

+145
-1
lines changed

.ci/scripts/release.bash

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ function runUpdatecliDiff(){
3636
--values "$POLICY_ROOT_DIR/testdata/values.yaml"
3737
}
3838

39+
function runUpdatescliShow(){
40+
local POLICY_ROOT_DIR=""
41+
POLICY_ROOT_DIR="$1"
42+
updatecli manifest show \
43+
--config "$POLICY_ROOT_DIR/updatecli.d" \
44+
--values "$POLICY_ROOT_DIR/values.yaml" \
45+
--values "$POLICY_ROOT_DIR/testdata/values.yaml"
46+
}
47+
3948
function validateRequiredFile(){
4049
local POLICY_ROOT_DIR="$1"
4150
local POLICY_VALUES="$POLICY_ROOT_DIR/values.yaml"
@@ -137,6 +146,7 @@ function main(){
137146
POLICY_ROOT_DIR="$2"
138147
validateRequiredFile "$POLICY_ROOT_DIR"
139148
runUpdatecliDiff "$POLICY_ROOT_DIR"
149+
runUpdatescliShow "$POLICY_ROOT_DIR"
140150
exit 0
141151
fi
142152

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ test: ## Release checks for each policy if they can be published on ghcr.io
1212
e2e-test: ## Release checks for each policy if they can be published on ghcr.io
1313
.ci/scripts/release.bash --e2e-test
1414

15-
.PHONY: e2e-test
15+
.PHONY: validate-policy
16+
## make validate-policy POLICY=policies/apm/apm-data-spec GITHUB_WORKSPACE=/tmp
1617
validate-policy: ## Release checks for each policy if they can be published on ghcr.io
1718
.ci/scripts/release.bash --validate-policy $(POLICY)
1819

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
updatecli v0.87.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.86.0

updatecli-compose.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ policies:
3333
policy: ghcr.io/elastic/oblt-updatecli-policies/ironbank/templates:latest
3434
values:
3535
- updatecli/policies/ironbank/templates/testdata/values.yaml
36+
37+
- name: Handle updatecli update (e2e tests)
38+
policy: ghcr.io/elastic/oblt-updatecli-policies/updatecli/version:latest
39+
values:
40+
- updatecli/policies/updatecli/version/testdata/values.yaml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Initial release
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
authors:
2+
- Victor Martinez <[email protected]>
3+
4+
url: "https://github.com/elastic/oblt-updatecli-policies/"
5+
changelog: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/updatecli/version/CHANGELOG.md"
6+
documentation: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/updatecli/version/README.md"
7+
source: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/updatecli/version/"
8+
version: 0.1.0
9+
vendor: Updatecli Project
10+
11+
licenses:
12+
- "Apache-2.0 license"
13+
14+
description: |
15+
updatecli Version update policy
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# README
2+
3+
This policy will update the version of the [updatecli](https://github.com/updatecli/updatecli/releases)
4+
defined in a file. Also supports .tool-versions file (asdf-vm).
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
scm:
2+
enabled: true
3+
user: obltmachine
4+
owner: elastic
5+
repository: oblt-updatecli-policies
6+
username: obltmachine
7+
branch: main
8+
commitusingapi: true
9+
10+
path: tests/updatecli/version/.tool-versions
11+
12+
pull_request:
13+
labels:
14+
- dependencies
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
# Helpers
3+
# {{ $GitHubUser := env ""}}
4+
# {{ $GitHubRepositoryList := env "GITHUB_REPOSITORY" | split "/"}}
5+
# {{ $GitHubPAT := env "GITHUB_TOKEN"}}
6+
# {{ $GitHubUsername := env "GITHUB_ACTOR"}}
7+
8+
name: '{{ .name }}'
9+
pipelineid: '{{ .pipelineid }}'
10+
11+
sources:
12+
version:
13+
name: Get latest updatecli version from updatecli/updatecli
14+
kind: githubrelease
15+
spec:
16+
owner: updatecli
17+
repository: updatecli
18+
token: "{{ default $GitHubPAT .scm.token }}"
19+
username: "{{ default $GitHubUsername .scm.username }}"
20+
versionFilter:
21+
kind: latest
22+
23+
targets:
24+
updatecli-version-file:
25+
name: 'deps(updatecli): Bump updatecli version to {{ source "version" }}'
26+
kind: file
27+
# {{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }}
28+
scmid: default
29+
# {{ end }}
30+
sourceid: version
31+
spec:
32+
file: '{{ .path }}'
33+
# {{ if hasSuffix ".tool-versions" .path }}
34+
matchpattern: '^updatecli\s+\d+\.\d+\.\d+'
35+
content: 'updatecli {{ source `version` }}'
36+
# {{ else }}
37+
# |+ adds newline to the end of the file
38+
content: |+
39+
{{ source `version` }}
40+
# {{ end }}
41+
42+
# {{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }}
43+
scms:
44+
default:
45+
kind: "github"
46+
spec:
47+
# Priority set to the environment variable
48+
user: '{{ default $GitHubUser .scm.user}}'
49+
owner: '{{ default $GitHubRepositoryList._0 .scm.owner }}'
50+
repository: '{{ default $GitHubRepositoryList._1 .scm.repository}}'
51+
token: '{{ default $GitHubPAT .scm.token }}'
52+
username: '{{ default $GitHubUsername .scm.username }}'
53+
branch: '{{ .scm.branch }}'
54+
#{{ if .scm.commitusingapi }}
55+
commitusingapi: {{ .scm.commitusingapi }}
56+
# {{ end }}
57+
58+
actions:
59+
default:
60+
title: 'deps: Bump updatecli version to {{ source "version" }}'
61+
kind: "github/pullrequest"
62+
spec:
63+
automerge: {{ .automerge }}
64+
labels:
65+
# {{ range .pull_request.labels }}
66+
- {{ . }}
67+
# {{ end }}
68+
scmid: "default"
69+
{{ end }}

0 commit comments

Comments
 (0)