Skip to content

Commit

Permalink
Merge pull request #1 from anduintransaction/anduin
Browse files Browse the repository at this point in the history
feat: patch registry client to publish compatible oras layers
  • Loading branch information
vanhtuan0409 authored Sep 30, 2024
2 parents da2e501 + 49e9e05 commit f5a485e
Show file tree
Hide file tree
Showing 18 changed files with 342 additions and 101 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Snapshot

on:
push:
branches:
- master

permissions:
contents: write

concurrency: snapshot

jobs:
snapshot:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup go
uses: actions/setup-go@v5

- name: Install CUE
run: go install ./cmd/cue

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: v2.2.0

- name: Run GoReleaser with CUE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cue cmd release
working-directory: ./internal/ci/goreleaser
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dev-build:
go build -o ./dist/cue-dev ./cmd/cue
3 changes: 3 additions & 0 deletions examples/anduin/multi-modules/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cue.cache/
data/
!cue.mod/module.cue
17 changes: 17 additions & 0 deletions examples/anduin/multi-modules/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
nuke:
sudo rm -rf ./cue.cache/mod && \
rm -rf ./data/* && \
mkdir -p ./cue.cache ./data

publish-module1:
cd ./module1 && \
../cue.sh mod publish v1.0.1

eval-module2:
cd ./module2 && \
../cue.sh mod tidy && \
../cue.sh export ./main.cue

oras-pull:
cd data && \
oras pull localhost:5000/anduin.com/module1:v1.0.1
1 change: 1 addition & 0 deletions examples/anduin/multi-modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Example using multi modules with Cue
9 changes: 9 additions & 0 deletions examples/anduin/multi-modules/cue.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/env bash

here=`cd $(dirname $BASH_SOURCE); pwd`

export ANDUIN_CUE_DEBUG="true"
export CUE_CACHE_DIR=$here/cue.cache/
export CUE_REGISTRY=file://$here/registry.cue

$here/../../../dist/cue-dev $@
5 changes: 5 additions & 0 deletions examples/anduin/multi-modules/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
zot:
image: ghcr.io/project-zot/zot-linux-amd64:v2.1.1
ports:
- 5000:5000
7 changes: 7 additions & 0 deletions examples/anduin/multi-modules/module1/cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module: "anduin.com/module1@v1"

source: kind: "self"

language: {
version: "v0.11.0"
}
1 change: 1 addition & 0 deletions examples/anduin/multi-modules/module1/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
asdasdasdasd
24 changes: 24 additions & 0 deletions examples/anduin/multi-modules/module1/file.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package module1

import "math"

data: {
// Simple labels don't need to be quoted.
one: 1
two: 2
piPlusOne: math.Pi + 1

// Field names must be quoted if they contain
// special characters, such as hyphen and space.
"quoted field names": {
"two-and-a-half": 2.5
"three point three": 3.3
"four^four": math.Pow(4, 4)
}

aList: [
1,
2,
3,
]
}
5 changes: 5 additions & 0 deletions examples/anduin/multi-modules/module1/file2.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package module1

data2: {
foo: "bar"
}
5 changes: 5 additions & 0 deletions examples/anduin/multi-modules/module1/submodules/file3.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package submodules

data3: {
fizz: "fizz"
}
12 changes: 12 additions & 0 deletions examples/anduin/multi-modules/module2/cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module: "anduin.com/module2@v1"
language: {
version: "v0.11.0"
}
source: {
kind: "self"
}
deps: {
"anduin.com/module1@v1": {
v: "v1.0.1"
}
}
10 changes: 10 additions & 0 deletions examples/anduin/multi-modules/module2/main.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package module2

import (
"anduin.com/module1"
"anduin.com/module1/submodules"
)

foo: module1.data
bar: module1.data2
fizz: submodules.data3
3 changes: 3 additions & 0 deletions examples/anduin/multi-modules/registry.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defaultRegistry: {
registry: "localhost:5000+insecure"
}
79 changes: 2 additions & 77 deletions internal/ci/goreleaser/goreleaser.cue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package goreleaser
config: {
#latest: bool @tag(latest, type=bool)

version: 2
version: 2
project_name: "cue"
// Note that gomod.proxy is ignored by `goreleaser release --snapshot`,
// which we use in CI to test the goreleaser config and build,
Expand All @@ -30,7 +30,6 @@ config: {
goos: *[
"darwin",
"linux",
"windows",
] | _
goarch: *[
"amd64",
Expand Down Expand Up @@ -68,82 +67,8 @@ config: {
// For those reasons, let goreleaser create the release, but leaving it as a draft.
draft: true
}
checksum: name_template: "checksums.txt"
checksum: name_template: "checksums.txt"
snapshot: version_template: "{{ .Tag }}-next"
// As explained above, we write our own release notes.
changelog: disable: true

brews: [{
if !#latest {
skip_upload: true
}
repository: {
owner: "cue-lang"
name: "homebrew-tap"
}
commit_author: {
name: "cueckoo"
email: "[email protected]"
}
homepage: "https://cuelang.org"
description: "CUE is an open source data constraint language which aims to simplify tasks involving defining and using data."
test: """
system \"#{bin}/cue version\"
"""
}]

dockers: [{
image_templates: [
"docker.io/cuelang/cue:{{ .Version }}-amd64",
]
dockerfile: "cmd/cue/Dockerfile"
use: "buildx"
build_flag_templates: [
"--platform=linux/amd64",
"--label=org.opencontainers.image.title={{ .ProjectName }}",
"--label=org.opencontainers.image.description={{ .ProjectName }}",
"--label=org.opencontainers.image.url=https://github.com/cue-lang/cue",
"--label=org.opencontainers.image.source=https://github.com/cue-lang/cue",
"--label=org.opencontainers.image.version={{ .Version }}",
"--label=org.opencontainers.image.created={{ time \"2006-01-02T15:04:05Z07:00\" }}",
"--label=org.opencontainers.image.revision={{ .FullCommit }}",
"--label=org.opencontainers.image.licenses=Apache 2.0",
]
}, {
image_templates: [
"docker.io/cuelang/cue:{{ .Version }}-arm64",
]
goarch: "arm64"
dockerfile: "cmd/cue/Dockerfile"
use: "buildx"
build_flag_templates: [
"--platform=linux/arm64",
"--label=org.opencontainers.image.title={{ .ProjectName }}",
"--label=org.opencontainers.image.description={{ .ProjectName }}",
"--label=org.opencontainers.image.url=https://github.com/cue-lang/cue",
"--label=org.opencontainers.image.source=https://github.com/cue-lang/cue",
"--label=org.opencontainers.image.version={{ .Version }}",
"--label=org.opencontainers.image.created={{ time \"2006-01-02T15:04:05Z07:00\" }}",
"--label=org.opencontainers.image.revision={{ .FullCommit }}",
"--label=org.opencontainers.image.licenses=Apache 2.0",
]
}]

docker_manifests: [
{
name_template: "docker.io/cuelang/cue:{{ .Version }}"
image_templates: [
"docker.io/cuelang/cue:{{ .Version }}-amd64",
"docker.io/cuelang/cue:{{ .Version }}-arm64",
]
},
if #latest {
name_template: "docker.io/cuelang/cue:latest"
image_templates: [
"docker.io/cuelang/cue:{{ .Version }}-amd64",
"docker.io/cuelang/cue:{{ .Version }}-arm64",
]
},
]
}
Loading

0 comments on commit f5a485e

Please sign in to comment.