diff --git a/.gitlab/Makefile b/.gitlab/Makefile new file mode 100644 index 0000000..75a6988 --- /dev/null +++ b/.gitlab/Makefile @@ -0,0 +1,36 @@ +SHELL := /bin/bash + +VERSION ?= $(shell cat VERSION) +IMAGE ?= $(shell cat IMAGE):$(VERSION) +IMAGE_LATEST ?= $(shell cat IMAGE):latest +PWD ?= $(shell pwd) +STASH ?= "common-update-stash" + +include .gitlab/make/docker.makefile +include .gitlab/make/helm.makefile +include .gitlab/make/kaniko.makefile +include .gitlab/make/truenas.makefile +include .gitlab/make/git.makefile + +.PHONY: warning +warning: + @printf "Running a potentially destructive command. If a conflict occurs, fix the conflict and re-run the command.\n" + @printf "Cancel with ctrl + c within 3 seconds." + @sleep 3 + +.PHONY: make-stash-drop +make-stash-drop: + @if [ ! -z "$$(git stash list | grep -r 'stash@{0}.*common')" ]; then git stash drop; fi + +.PHONY: make-update +make-update: + -git remote add common git@gitlab.ducoterra.net:services/common.git + -git subtree pull --prefix .gitlab --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git main + +.PHONY: make-push +make-push: warning + @make make-update + @git remote add common git@gitlab.ducoterra.net:services/common.git + @git subtree split --branch common-minecraft --prefix .gitlab + @git subtree push --prefix .gitlab common main + @git remote remove common diff --git a/.gitlab/README.md b/.gitlab/README.md new file mode 100644 index 0000000..8aa1cbe --- /dev/null +++ b/.gitlab/README.md @@ -0,0 +1,9 @@ +# Adding the "common" subtree as your .gitlab folder + +```bash +# Add the subtree as a remote +git subtree add --prefix .gitlab git@gitlab.ducoterra.net:services/common.git main --squash + +# Now you can run the following to update +make make-update +``` diff --git a/.gitlab/make/docker.makefile b/.gitlab/make/docker.makefile new file mode 100644 index 0000000..23e4a52 --- /dev/null +++ b/.gitlab/make/docker.makefile @@ -0,0 +1,29 @@ +.PHONY: docker-init +docker-init: + @touch VERSION + @touch IMAGE + +.PHONY: buildx-context +buildx-context: + docker buildx create --name container-builder --use --platform linux/amd64,linux/arm64 + +.PHONY: buildx-clear +buildx-clear: + docker buildx rm container-builder + +.PHONY: build +build: + docker buildx build --load . -t $(IMAGE) + @docker buildx build --load . -t $(IMAGE_LATEST) + +.PHONY: push +push: + -make buildx-clear + @make buildx-context + docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE) + @docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE_LATEST) + +.PHONY: docker-release +docker-release: + @yq e ".services.minecraft.image = \"$(IMAGE)\"" -i docker-compose.yaml + @make push diff --git a/.gitlab/make/git.makefile b/.gitlab/make/git.makefile new file mode 100644 index 0000000..f80a243 --- /dev/null +++ b/.gitlab/make/git.makefile @@ -0,0 +1,5 @@ +.PHONY: git-release +git-release: + @git add . + @git commit -m "Automated release for version $(VERSION)" + @git tag $(VERSION) diff --git a/.gitlab/make/helm.makefile b/.gitlab/make/helm.makefile new file mode 100644 index 0000000..f603af4 --- /dev/null +++ b/.gitlab/make/helm.makefile @@ -0,0 +1,4 @@ +.PHONY: helm-release +helm-release: + @yq e ".version = \"$(shell cat VERSION)\"" -i helm/Chart.yaml + @yq e ".appVersion = \"$(shell cat VERSION)\"" -i helm/Chart.yaml diff --git a/.gitlab/make/kaniko.makefile b/.gitlab/make/kaniko.makefile new file mode 100644 index 0000000..e69de29 diff --git a/.gitlab/make/truenas.makefile b/.gitlab/make/truenas.makefile new file mode 100644 index 0000000..c6fb58c --- /dev/null +++ b/.gitlab/make/truenas.makefile @@ -0,0 +1,3 @@ +.PHONY: chart-release +chart-release: + @rsync -av $(CHART)/helm/ charts/$(CHART)/$(shell cat $(CHART)/VERSION)/