-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use kres to manage repo. Signed-off-by: Noel Georgi <[email protected]>
- Loading branch information
Showing
11 changed files
with
247 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. | ||
# | ||
# Generated on 2023-11-02T12:25:12Z by kres a0777d5-dirty. | ||
|
||
* | ||
!README.md | ||
!pkg.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
_out* | ||
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. | ||
# | ||
# Generated on 2023-11-02T12:25:12Z by kres a0777d5-dirty. | ||
|
||
_out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
kind: pkgfile.Build | ||
spec: | ||
targets: | ||
- tools | ||
reproducibleTargetName: tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,131 @@ | ||
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. | ||
# | ||
# Generated on 2023-11-02T12:30:07Z by kres latest. | ||
|
||
# common variables | ||
|
||
SHA := $(shell git describe --match=none --always --abbrev=8 --dirty) | ||
TAG := $(shell git describe --tag --always --dirty) | ||
ABBREV_TAG := $(shell git describe --tags >/dev/null 2>/dev/null && git describe --tag --always --match v[0-9]\* --abbrev=0 || echo 'undefined') | ||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
ARTIFACTS := _out | ||
REGISTRY ?= ghcr.io | ||
USERNAME ?= siderolabs | ||
SHA ?= $(shell git describe --match=none --always --abbrev=8 --dirty) | ||
TAG ?= $(shell git describe --tag --always --dirty) | ||
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) | ||
REGISTRY_AND_USERNAME := $(REGISTRY)/$(USERNAME) | ||
# inital commit time | ||
# git rev-list --max-parents=0 HEAD | ||
# git log e2983a47abbfaf9cb1cc740c87af26f29a837ee0 --pretty=%ct | ||
SOURCE_DATE_EPOCH ?= "1559830076" | ||
|
||
# Sync bldr image with Pkgfile | ||
USERNAME ?= talos-systems | ||
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME) | ||
KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest | ||
CONFORMANCE_IMAGE ?= ghcr.io/siderolabs/conform:latest | ||
|
||
# source date epoch of first commit | ||
|
||
INITIAL_COMMIT_SHA := $(shell git rev-list --max-parents=0 HEAD) | ||
SOURCE_DATE_EPOCH := $(shell git log $(INITIAL_COMMIT_SHA) --pretty=%ct) | ||
|
||
# sync bldr image with pkgfile | ||
|
||
BLDR_IMAGE := ghcr.io/siderolabs/bldr:v0.2.3 | ||
BLDR ?= docker run --rm --volume $(PWD):/tools --entrypoint=/bldr \ | ||
$(BLDR_IMAGE) graph --root=/tools | ||
BLDR := docker run --rm --user $(shell id -u):$(shell id -g) --volume $(PWD):/src --entrypoint=/bldr $(BLDR_IMAGE) --root=/src | ||
|
||
# docker build settings | ||
|
||
BUILD := docker buildx build | ||
PLATFORM ?= linux/amd64,linux/arm64 | ||
PROGRESS ?= auto | ||
PUSH ?= false | ||
DEST ?= _out | ||
COMMON_ARGS := --file=Pkgfile | ||
CI_ARGS ?= | ||
COMMON_ARGS = --file=Pkgfile | ||
COMMON_ARGS += --provenance=false | ||
COMMON_ARGS += --progress=$(PROGRESS) | ||
COMMON_ARGS += --platform=$(PLATFORM) | ||
COMMON_ARGS += --build-arg=SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) | ||
|
||
# targets defines all the available targets | ||
|
||
TARGETS = tools | ||
|
||
all: $(TARGETS) ## Builds all known pkgs. | ||
# help menu | ||
|
||
.PHONY: help | ||
help: ## This help menu. | ||
@grep -E '^[a-zA-Z0-9\.%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
export define HELP_MENU_HEADER | ||
# Getting Started | ||
|
||
target-%: ## Builds the specified target defined in the Pkgfile. The build result will only remain in the build cache. | ||
@$(BUILD) \ | ||
--target=$* \ | ||
$(COMMON_ARGS) \ | ||
$(TARGET_ARGS) . | ||
To build this project, you must have the following installed: | ||
|
||
local-%: ## Builds the specified target defined in the Pkgfile using the local output type. The build result will be output to the specified local destination. | ||
@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)" | ||
- git | ||
- make | ||
- docker (19.03 or higher) | ||
|
||
reproducibility-test: | ||
@$(MAKE) reproducibility-test-local-tools | ||
## Creating a Builder Instance | ||
|
||
The build process makes use of experimental Docker features (buildx). | ||
To enable experimental features, add 'experimental: "true"' to '/etc/docker/daemon.json' on | ||
Linux or enable experimental features in Docker GUI for Windows or Mac. | ||
|
||
To create a builder instance, run: | ||
|
||
docker buildx create --name local --use | ||
|
||
|
||
If you already have a compatible builder instance, you may use that instead. | ||
|
||
reproducibility-test-local-%: ## Builds the specified target defined in the Pkgfile using the local output type. The build result will be output to the specified local destination. | ||
@rm -rf _out1/ _out2/ | ||
@$(MAKE) local-$* DEST=_out1 | ||
@$(MAKE) local-$* DEST=_out2 TARGET_ARGS="--no-cache" | ||
@touch -ch -t $$(date -d @$(SOURCE_DATE_EPOCH) +%Y%m%d0000) _out1 _out2 | ||
@diffoscope _out1 _out2 | ||
@rm -rf _out1/ _out2/ | ||
## Artifacts | ||
|
||
docker-%: ## Builds the specified target defined in the Pkgfile using the docker output type. The build result will be loaded into Docker. | ||
All artifacts will be output to ./$(ARTIFACTS). Images will be tagged with the | ||
registry "$(REGISTRY)", username "$(USERNAME)", and a dynamic tag (e.g. $(IMAGE):$(TAG)). | ||
The registry and username can be overridden by exporting REGISTRY, and USERNAME | ||
respectively. | ||
|
||
endef | ||
|
||
all: $(TARGETS) ## Builds all targets defined. | ||
|
||
.PHONY: clean | ||
clean: ## Cleans up all artifacts. | ||
@rm -rf $(ARTIFACTS) | ||
|
||
target-%: ## Builds the specified target defined in the Pkgfile. The build result will only remain in the build cache. | ||
@$(BUILD) --target=$* $(COMMON_ARGS) $(TARGET_ARGS) $(CI_ARGS) . | ||
|
||
local-%: ## Builds the specified target defined in the Pkgfile using the local output type. The build result will be output to the specified local destination. | ||
@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)" | ||
|
||
docker-%: ## Builds the specified target defined in the Pkgfile using the docker output type. The build result will be loaded into Docker. | ||
@$(MAKE) target-$* TARGET_ARGS="$(TARGET_ARGS)" | ||
|
||
reproducibility-test: ## Builds the reproducibility test target | ||
@$(MAKE) reproducibility-test-local-tools | ||
|
||
reproducibility-test-local-%: ## Builds the specified target defined in the Pkgfile using the local output type with and without cahce. The build result will be output to the specified local destination | ||
@rm -rf $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b | ||
@$(MAKE) local-$* DEST=$(ARTIFACTS)/build-a | ||
@$(MAKE) local-$* DEST=$(ARTIFACTS)/build-b TARGET_ARGS="--no-cache" | ||
@touch -ch -t $$(date -d @$(SOURCE_DATE_EPOCH) +%Y%m%d0000) $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b | ||
@diffoscope $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b | ||
@rm -rf $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b | ||
|
||
.PHONY: $(TARGETS) | ||
$(TARGETS): | ||
@$(MAKE) docker-$@ TARGET_ARGS="--tag=$(REGISTRY_AND_USERNAME)/$@:$(TAG) --push=$(PUSH)" | ||
|
||
.PHONY: deps.png | ||
deps.png: ## Regenerate deps.png. | ||
@$(BLDR) graph | dot -Tpng > deps.png | ||
deps.png: ## Generates a dependency graph of the Pkgfile. | ||
@$(BLDR) graph | dot -Tpng -o deps.png | ||
|
||
.PHONY: rekres | ||
rekres: | ||
@docker pull $(KRES_IMAGE) | ||
@docker run --rm --net=host --user $(shell id -u):$(shell id -g) -v $(PWD):/src -w /src -e GITHUB_TOKEN $(KRES_IMAGE) | ||
|
||
.PHONY: help | ||
help: ## This help menu. | ||
@echo "$$HELP_MENU_HEADER" | ||
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: release-notes | ||
release-notes: | ||
mkdir -p $(ARTIFACTS) | ||
@ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG) | ||
|
||
.PHONY: conformance | ||
conformance: | ||
@docker pull $(CONFORMANCE_IMAGE) | ||
@docker run --rm -it -v $(PWD):/src -w /src $(CONFORMANCE_IMAGE) enforce | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.