From 515baef0dc2ac21d023b5293484b7c6185b25d57 Mon Sep 17 00:00:00 2001 From: Jan Seidl Date: Fri, 27 Oct 2023 17:24:36 +0200 Subject: [PATCH] experiment with central Makefile and extended calver workflow --- .github/workflows/service.yaml | 14 ++++++++++++++ Makefile.inc | 21 +++++++++++++++++++++ services/a/Dockerfile | 6 ++++++ services/a/Makefile | 3 +++ services/a/service.sh | 9 +++++++++ 5 files changed, 53 insertions(+) create mode 100644 Makefile.inc create mode 100644 services/a/Dockerfile create mode 100644 services/a/Makefile create mode 100644 services/a/service.sh diff --git a/.github/workflows/service.yaml b/.github/workflows/service.yaml index 91c2455..b7ad115 100644 --- a/.github/workflows/service.yaml +++ b/.github/workflows/service.yaml @@ -19,3 +19,17 @@ jobs: - name: Run service ${{ inputs.service_name }} test script run: ./test.sh + + - name: Get next version + uses: reecetech/version-increment@2023.9.3 + id: version + with: + scheme: calver + + - name: Build docker image + run: make build + + - name: Release docker image + env: + VERSION: ${{ steps.version.outputs.version }} + run: make release diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 0000000..6105a52 --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,21 @@ +.PHONY: test build release + +ifndef SERVICE_NAME + $(error SERVICE_NAME is not set) +endif + +ifndef VERSION + $(error VERSION is not set) +endif + +# Make sure there are no spaces. +SERVICE_NAME := $(SERVICE_NAME: =_) + +test: + ./test.sh + +build: + docker build -t $(SERVICE_NAME) . + +release: + docker tag $(SERVICE_NAME) $(SERVICE_NAME):$(VERSION) diff --git a/services/a/Dockerfile b/services/a/Dockerfile new file mode 100644 index 0000000..8403778 --- /dev/null +++ b/services/a/Dockerfile @@ -0,0 +1,6 @@ +FROM debian:12-slim + +COPY ./service.sh /service.sh +RUN chmod +x /service.sh + +ENTRYPOINT ["/service.sh"] diff --git a/services/a/Makefile b/services/a/Makefile new file mode 100644 index 0000000..8bfc898 --- /dev/null +++ b/services/a/Makefile @@ -0,0 +1,3 @@ +SERVICE_NAME = $(shell basename $(shell pwd)) + +include ../../Makefile.inc diff --git a/services/a/service.sh b/services/a/service.sh new file mode 100644 index 0000000..ac3ee60 --- /dev/null +++ b/services/a/service.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +counter=1 + +while true; do + echo "Service '$SERVICE_NAME': $counter" + ((counter++)) + sleep 1 +done