Skip to content

Commit 4b88990

Browse files
authored
feat: adds KCL provider (#111)
1 parent 2929028 commit 4b88990

File tree

5 files changed

+103
-1
lines changed

5 files changed

+103
-1
lines changed

actions/setup/action.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
description: If true, skip authenticating to GitHub Container Registry
2424
required: false
2525
default: "false"
26+
skip_kcl:
27+
description: If true, skips installing KCL CLI if the provider is configured
28+
required: false
29+
default: "false"
2630
skip_timoni:
2731
description: If true, skips installing Timoni CLI if the provider is configured
2832
required: false
@@ -225,4 +229,43 @@ runs:
225229
uses: cue-lang/[email protected]
226230
if: steps.cue.outputs.install && steps.cue.conclusion == 'success'
227231
with:
228-
version: v${{ steps.cue.outputs.version }}
232+
version: v${{ steps.cue.outputs.version }}
233+
234+
# KCL Provider
235+
- name: Get KCL provider configuration
236+
id: kcl
237+
if: inputs.skip_kcl == 'false'
238+
shell: bash
239+
run: |
240+
echo "==== KCL Setup ====="
241+
BP=$(forge dump .)
242+
243+
KCL=$(echo "$BP" | jq -r .global.ci.providers.kcl.install)
244+
if [[ "$KCL" == "true" ]]; then
245+
INSTALL=1
246+
VERSION=$(echo "$BP" | jq -r .global.ci.providers.kcl.version)
247+
echo "install=$INSTALL" >> $GITHUB_OUTPUT
248+
echo "version=$VERSION" >> $GITHUB_OUTPUT
249+
else
250+
echo "Not installing KCL CLI"
251+
fi
252+
- name: Cache KCL
253+
id: cache-kcl
254+
if: steps.kcl.outputs.install && steps.kcl.conclusion == 'success'
255+
uses: actions/cache@v4
256+
with:
257+
path: /usr/local/bin/kcl
258+
key: ${{ runner.os }}-kcl-${{ steps.kcl.outputs.version }}
259+
- name: Install KCL
260+
if: steps.cache-kcl.outputs.cache-hit == false
261+
shell: bash
262+
run: |
263+
WORKDIR="$(mktemp -d)"
264+
VERSION="${{ steps.kcl.outputs.version }}"
265+
curl -Lo "${WORKDIR}/kcl.tar.gz" https://github.com/kcl-lang/cli/releases/download/$VERSION/kcl-$VERSION-linux-amd64.tar.gz
266+
cd "${WORKDIR}" && tar -xvzf kcl.tar.gz && mv kcl /usr/local/bin/kcl
267+
- name: Check KCL
268+
if: steps.kcl.outputs.install && steps.kcl.conclusion == 'success'
269+
shell: bash
270+
run: |
271+
kcl version

blueprint.cue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ global: {
5454
}
5555
registry: "ghcr.io"
5656
}
57+
58+
kcl: {
59+
install: true
60+
version: "v0.11.0"
61+
}
5762
}
5863
secrets: [
5964
{

lib/project/schema/_embed/schema.cue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ package schema
7979
// +optional
8080
github?: #ProviderGithub @go(Github)
8181

82+
// KCL contains the configuration for the KCL provider.
83+
// +optional
84+
kcl?: #ProviderKCL @go(KCL)
85+
8286
// Timoni contains the configuration for the Timoni provider.
8387
// +optional
8488
timoni?: #TimoniProvider @go(Timoni)
@@ -166,6 +170,20 @@ package schema
166170
// +optional
167171
registry?: null | string @go(Registry,*string)
168172
}
173+
174+
// ProviderKCL contains the configuration for the KCL provider.
175+
#ProviderKCL: {
176+
// Install contains whether to install KCL in the CI environment.
177+
// +optional
178+
install?: null | bool @go(Install,*bool)
179+
180+
// Registries contains the registries to use for publishing KCL modules
181+
registries: [...string] @go(Registries,[]string)
182+
183+
// The version of KCL to install in the CI environment
184+
// +optional
185+
version?: string @go(Version)
186+
}
169187
#TagStrategy: string
170188
#enumTagStrategy: #TagStrategyGitCommit
171189
#TagStrategyGitCommit: #TagStrategy & {

lib/project/schema/providers.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ type Providers struct {
2626
// +optional
2727
Github ProviderGithub `json:"github"`
2828

29+
// KCL contains the configuration for the KCL provider.
30+
// +optional
31+
KCL ProviderKCL `json:"kcl"`
32+
2933
// Timoni contains the configuration for the Timoni provider.
3034
// +optional
3135
Timoni TimoniProvider `json:"timoni"`
@@ -115,6 +119,20 @@ type ProviderGithub struct {
115119
Registry *string `json:"registry"`
116120
}
117121

122+
// ProviderKCL contains the configuration for the KCL provider.
123+
type ProviderKCL struct {
124+
// Install contains whether to install KCL in the CI environment.
125+
// +optional
126+
Install *bool `json:"install"`
127+
128+
// Registries contains the registries to use for publishing KCL modules
129+
Registries []string `json:"registries"`
130+
131+
// The version of KCL to install in the CI environment
132+
// +optional
133+
Version string `json:"version"`
134+
}
135+
118136
// TimoniProvider contains the configuration for the Timoni provider.
119137
type TimoniProvider struct {
120138
// Install contains whether to install Timoni in the CI environment.

lib/project/schema/providers_go_gen.cue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ package schema
3030
// +optional
3131
github?: #ProviderGithub @go(Github)
3232

33+
// KCL contains the configuration for the KCL provider.
34+
// +optional
35+
kcl?: #ProviderKCL @go(KCL)
36+
3337
// Timoni contains the configuration for the Timoni provider.
3438
// +optional
3539
timoni?: #TimoniProvider @go(Timoni)
@@ -119,6 +123,20 @@ package schema
119123
registry?: null | string @go(Registry,*string)
120124
}
121125

126+
// ProviderKCL contains the configuration for the KCL provider.
127+
#ProviderKCL: {
128+
// Install contains whether to install KCL in the CI environment.
129+
// +optional
130+
install?: null | bool @go(Install,*bool)
131+
132+
// Registries contains the registries to use for publishing KCL modules
133+
registries: [...string] @go(Registries,[]string)
134+
135+
// The version of KCL to install in the CI environment
136+
// +optional
137+
version?: string @go(Version)
138+
}
139+
122140
// TimoniProvider contains the configuration for the Timoni provider.
123141
#TimoniProvider: {
124142
// Install contains whether to install Timoni in the CI environment.

0 commit comments

Comments
 (0)