Skip to content

Commit 1864449

Browse files
committed
refactor: remove OCM CLI installation from workflows and add installation task to Taskfile
1 parent 5ae1e48 commit 1864449

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

.github/workflows/main.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ jobs:
2727
attestations: write
2828

2929
steps:
30-
- name: Install OCM CLI
31-
run: |
32-
sudo curl -sL https://raw.githubusercontent.com/open-component-model/ocm/main/install.sh | sudo bash
33-
3430
- name: Install Go-Task
3531
uses: arduino/setup-task@v2
3632
with:

.github/workflows/on-release.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ jobs:
7171
sbom: true
7272
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.nextVersion }}
7373

74-
- name: Install OCM CLI
75-
run: |
76-
sudo curl -sL https://raw.githubusercontent.com/open-component-model/ocm/main/install.sh | sudo bash
77-
7874
- name: Install Go-Task
7975
uses: arduino/setup-task@v2
8076
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ dist
1212
dist-ssr
1313
*.local
1414

15+
.bin
16+
1517
# Editor directories and files
1618
.vscode/*
1719
!.vscode/extensions.json

Taskfile.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ vars:
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+
1822
tasks:
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

Comments
 (0)