Skip to content

Commit

Permalink
version of pkl packages is now inferred from env variables
Browse files Browse the repository at this point in the history
make pkl-resolve and make pkl-release now read the latest git tag for each package to determine the version without being stored in the PklProject files
update Kubernetes Dependencies

Signed-off-by: Tim <[email protected]>
  • Loading branch information
Avarei committed Jul 2, 2024
1 parent 23f5405 commit ea48fc6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 23 deletions.
26 changes: 22 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
REPO =? github.com/crossplane-contrib/function-pkl
CONTAINER_IMAGE =? ghcr.io/crossplane-contrib/function-pkl
REPO ?= github.com/crossplane-contrib/function-pkl
CONTAINER_IMAGE ?= ghcr.io/crossplane-contrib/function-pkl

# Target used for Pkl Package Releases
TARGET =? $(shell git branch --show-current)

LATEST_CORE := $(shell git tag -l "crossplane.contrib@*.*.*" --sort=-v:refname | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
LATEST_EXAMPLE := $(shell git tag -l "crossplane.contrib.example@*.*.*" --sort=-v:refname | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
LATEST_XRD := $(shell git tag -l "crossplane.contrib.xrd@*.*.*" --sort=-v:refname | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')

# This Resolves the Dependencies and sets the versions of our packages to the Latest ones for the package in Git
.PHONY: pkl-resolve
pkl-resolve:
pkl project resolve ./pkl/*/
pkl project resolve \
-e REPOSITORY="$(REPO)" \
-e CROSSPLANE_CONTRIB_VERSION="$(LATEST_CORE)" \
-e CROSSPLANE_CONTRIB_EXAMPLE_VERSION="$(LATEST_EXAMPLE)" \
-e CROSSPLANE_CONTRIB_XRD_VERSION="$(LATEST_XRD)" \
./pkl/*/

# Ensures the TAG Variable is set.
.PHONY: check-tag
check-tag:
@[ "${TAG}" ] || (echo "TAG is not specified" && exit 1)

# Packages all Projects with the latest tags for each before Pushing the one referenced in TAG
.PHONY: pkl-release
pkl-release: check-tag pkl-resolve
$(eval RELEASE_FILES := $(shell pkl project package ./pkl/*/ | grep ${TAG}))
$(eval RELEASE_FILES := $(shell \
pkl project package \
-e REPOSITORY="$(REPO)" \
-e CROSSPLANE_CONTRIB_VERSION="$(LATEST_CORE)" \
-e CROSSPLANE_CONTRIB_EXAMPLE_VERSION="$(LATEST_EXAMPLE)" \
-e CROSSPLANE_CONTRIB_XRD_VERSION="$(LATEST_XRD)" \
./pkl/*/ | grep ${TAG}))
@if [ -z "$(RELEASE_FILES)" ]; then \
echo "No release files found for tag ${TAG}."; \
exit 1; \
Expand Down
13 changes: 8 additions & 5 deletions pkl/crossplane.contrib.example/PklProject
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
/// Templates for configuring [Kubernetes](https://kubernetes.io).
amends "pkl:Project"

local repo = read?("env:REPOSITORY") ?? "github.com/crossplane-contrib/function-pkl"
local packageVersion: String = read?("env:CROSSPLANE_CONTRIB_EXAMPLE_VERSION") ?? "0.0.0"

package {
name = "crossplane.contrib.example"
authors {
"Tim Geimer <[email protected]>"
}
version = "1.0.0"
baseUri = "package://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/\(name)"
packageZipUrl = "https://github.com/crossplane-contrib/function-pkl/releases/download/\(name)@\(version)/\(name)@\(version).zip"
sourceCode = "https://github.com/crossplane-contrib/function-pkl"
version = packageVersion
baseUri = "package://pkg.pkl-lang.org/\(repo)/\(name)"
packageZipUrl = "https://\(repo)/releases/download/\(name)@\(version)/\(name)@\(version).zip"
sourceCode = "https://\(repo)"
license = "Apache-2.0"
description = """
Example for using the [Composition Functions](https://docs.crossplane.io/latest/concepts/composition-functions/).
Expand All @@ -36,7 +39,7 @@ dependencies {
["crossplane.contrib.xrd"] = import("../crossplane.contrib.xrd/PklProject")

["k8s"] {
uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1"
uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0"
}
["k8s.contrib.crd"] {
uri = "package://pkg.pkl-lang.org/pkl-pantry/[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions pkl/crossplane.contrib.example/PklProject.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
},
"package://pkg.pkl-lang.org/pkl-k8s/k8s@1": {
"type": "remote",
"uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1",
"uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0",
"checksums": {
"sha256": "75c6d66d94c335417a3c502e107aaeadf7a60b4e1d34b2c979afe11193205a1a"
"sha256": "9ca6002419e405a19b517d506490b46be9279556b5ef2664be0e836df80535e5"
}
},
"package://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/crossplane.contrib.xrd@1": {
Expand Down
7 changes: 4 additions & 3 deletions pkl/crossplane.contrib.xrd/PklProject
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
/// Templates for configuring [Kubernetes](https://kubernetes.io).
amends "pkl:Project"

local repo = "github.com/crossplane-contrib/function-pkl"
local repo = read?("env:REPOSITORY") ?? "github.com/crossplane-contrib/function-pkl"
local packageVersion: String = read?("env:CROSSPLANE_CONTRIB_XRD_VERSION") ?? "0.0.0"

package {
name = "crossplane.contrib.xrd"
authors {
"Tim Geimer <[email protected]>"
}
version = "1.0.0"
version = packageVersion
baseUri = "package://pkg.pkl-lang.org/\(repo)/\(name)"
packageZipUrl = "https://\(repo)/releases/download/\(name)@\(version)/\(name)@\(version).zip"
sourceCode = "https://\(repo)"
Expand All @@ -43,5 +44,5 @@ dependencies {
["syntax"] { uri = "package://pkg.pkl-lang.org/pkl-pantry/[email protected]" }
["openapiv3"] { uri = "package://pkg.pkl-lang.org/pkl-pantry/[email protected]" }

["k8s"] { uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1" }
["k8s"] { uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0" }
}
4 changes: 2 additions & 2 deletions pkl/crossplane.contrib.xrd/PklProject.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
},
"package://pkg.pkl-lang.org/pkl-k8s/k8s@1": {
"type": "remote",
"uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1",
"uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0",
"checksums": {
"sha256": "75c6d66d94c335417a3c502e107aaeadf7a60b4e1d34b2c979afe11193205a1a"
"sha256": "9ca6002419e405a19b517d506490b46be9279556b5ef2664be0e836df80535e5"
}
},
"package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3@2": {
Expand Down
13 changes: 8 additions & 5 deletions pkl/crossplane.contrib/PklProject
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@
/// Templates for configuring [Kubernetes](https://kubernetes.io).
amends "pkl:Project"

local repo = read?("env:REPOSITORY") ?? "github.com/crossplane-contrib/function-pkl"
local packageVersion: String = read?("env:CROSSPLANE_CONTRIB_VERSION") ?? "0.0.0"

package {
name = "crossplane.contrib"
authors {
"Tim Geimer <[email protected]>"
}
version = "1.0.0"
baseUri = "package://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/\(name)"
packageZipUrl = "https://github.com/crossplane-contrib/function-pkl/releases/download/\(name)@\(version)/\(name)@\(version).zip"
sourceCode = "https://github.com/crossplane-contrib/function-pkl"
version = packageVersion
baseUri = "package://pkg.pkl-lang.org/\(repo)/\(name)"
packageZipUrl = "https://\(repo)/releases/download/\(name)@\(version)/\(name)@\(version).zip"
sourceCode = "https://\(repo)"
license = "Apache-2.0"
description = """
Templates for reading and configuring [Composition Functions](https://docs.crossplane.io/latest/concepts/composition-functions/).
"""
}
dependencies {
["k8s"] {
uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1"
uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0"
}
}
4 changes: 2 additions & 2 deletions pkl/crossplane.contrib/PklProject.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"resolvedDependencies": {
"package://pkg.pkl-lang.org/pkl-k8s/k8s@1": {
"type": "remote",
"uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1",
"uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0",
"checksums": {
"sha256": "75c6d66d94c335417a3c502e107aaeadf7a60b4e1d34b2c979afe11193205a1a"
"sha256": "9ca6002419e405a19b517d506490b46be9279556b5ef2664be0e836df80535e5"
}
}
}
Expand Down

0 comments on commit ea48fc6

Please sign in to comment.