1# Publish a version for a simple CUE module via "cue mod publish"
2# to an off-the-shelf OCI registry which requires authentication.
3# Then fetch that module as a dependency via cmd/cue.
4
5gcloud-auth-docker # sets: MODULE, CUE_REGISTRY, CUE_REGISTRY_HOST, CLOUDSDK_CONFIG
6env DOCKER_CONFIG=$WORK/docker-config
7env-fill docker-config/config.json
8
9env VERSION=v0.0.1
10env MODVER=${MODULE}@v0
11
12cd publish
13
14exec cue mod init --source self ${MODVER}
15exec cue mod publish ${VERSION}
16
17cd ../depend
18
19env-fill out_foo.cue
20exec cue mod init --source self depend.localhost
21exec cue mod tidy
22exec cue export
23cmp stdout export.golden
24
25-- docker-config/config.json --
26{"credHelpers": {"${CUE_REGISTRY_HOST}": "gcloud"}}
27-- publish/foo.cue --
28package publish
29
30foo: "foo value"
31
32-- depend/out_foo.cue --
33package depend
34
35import mt "${MODVER}:publish"
36
37out: mt.foo
38-- depend/export.golden --
39{
40 "out": "foo value"
41}