1515 OCM_OUTPUT_DIR : ' {{.ROOT_DIR}}/.ctf'
1616 OCM_DESCRIPTOR : ' {{.ROOT_DIR}}/ocm/component-descriptor.yaml'
1717
18+ ROOT_DIR2 : ' {{.ROOT_DIR | trimSuffix "/common" | trimSuffix "/hack"}}'
19+ LOCALBIN : ' {{ env "LOCALBIN" | default ( .LOCALBIN | default (print .ROOT_DIR2 "/.bin") ) }}'
20+ OCM : ' {{ .OCM | default (print .LOCALBIN "/ocm") }}'
21+
1822tasks :
1923 default :
2024 desc : Show available tasks
@@ -23,10 +27,12 @@ tasks:
2327
2428 build:ocm :
2529 desc : ' Builds the ocm component. Usage: task build:ocm'
30+ deps :
31+ - install:ocm
2632 cmds :
2733 - rm -rf {{.OCM_OUTPUT_DIR}}
2834 - |
29- ocm add components --create \
35+ {{.OCM}} add components --create \
3036 --lookup {{.OCM_TARGET_REPO}} \
3137 --file {{.OCM_OUTPUT_DIR}} \
3238 {{.OCM_DESCRIPTOR}} -- \
@@ -39,9 +45,11 @@ tasks:
3945
4046 publish:ocm :
4147 desc : ' Publishes the ocm component to the registry.'
48+ deps :
49+ - install:ocm
4250 cmds :
4351 - |
44- ocm transfer ctf \
52+ {{.OCM}} transfer ctf \
4553 {{.OCM_OUTPUT_DIR}} {{.OCM_TARGET_REPO}}
4654
4755 build:image:local :
@@ -53,3 +61,36 @@ tasks:
5361 desc : ' Publishes the docker image for local testing. Usage: task test:publish-image TAG=v-local-test'
5462 cmds :
5563 - docker push {{.DOCKER_IMAGE}}
64+
65+ localbin :
66+ desc : ' Ensure that the folder specified in LOCALBIN exists.'
67+ run : once
68+ requires :
69+ vars :
70+ - LOCALBIN
71+ status :
72+ - test -d {{.LOCALBIN}}
73+ cmds :
74+ - ' echo "localbin: {{.LOCALBIN}}"'
75+ - mkdir -p {{.LOCALBIN}}
76+ internal : true
77+
78+ install:ocm :
79+ desc : ' Ensure that the ocm CLI is installed.'
80+ run : once
81+ requires :
82+ vars :
83+ - OCM
84+ deps :
85+ - localbin
86+ status :
87+ - ' test -x "{{.OCM}}"'
88+ - ' "{{.OCM}}" --version | grep -q "{{.OCM_VERSION | trimPrefix "v"}}"'
89+ vars :
90+ # renovate: datasource=github-releases depName=ocm packageName=open-component-model/ocm
91+ OCM_VERSION : ' {{ env "OCM_VERSION" | default ( .OCM_VERSION | default "v0.30.0" ) }}'
92+ tmpdir :
93+ sh : ' mktemp -d'
94+ cmds :
95+ - ' curl -sSfL https://ocm.software/install.sh | OCM_VERSION="{{.OCM_VERSION | trimPrefix "v"}}" bash -s "{{.tmpdir}}"'
96+ - ' mv "{{.tmpdir}}/ocm" "{{.OCM}}"'
0 commit comments