From 2e15caa03e558bfc33ed68f76db2880103e6d5d3 Mon Sep 17 00:00:00 2001 From: Samuel Cattini-Schultz Date: Wed, 22 Nov 2023 01:16:21 +1100 Subject: [PATCH] Add make target for publishing releases --- Difficalcy.Catch/Dockerfile | 3 +++ Difficalcy.Mania/Dockerfile | 3 +++ Difficalcy.Osu/Dockerfile | 3 +++ Difficalcy.Taiko/Dockerfile | 3 +++ Makefile | 18 ++++++++++++++++++ docker-compose.override.publish.yml | 12 ++++++++++++ tooling.Dockerfile | 6 ++++++ 7 files changed, 48 insertions(+) create mode 100644 docker-compose.override.publish.yml diff --git a/Difficalcy.Catch/Dockerfile b/Difficalcy.Catch/Dockerfile index 9523e1b..e6f8b40 100644 --- a/Difficalcy.Catch/Dockerfile +++ b/Difficalcy.Catch/Dockerfile @@ -1,4 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base + +LABEL org.opencontainers.image.source https://github.com/Syriiin/difficalcy + WORKDIR /app EXPOSE 80 ENV ASPNETCORE_URLS=http://+:80 diff --git a/Difficalcy.Mania/Dockerfile b/Difficalcy.Mania/Dockerfile index dbd4ec8..d7e984b 100644 --- a/Difficalcy.Mania/Dockerfile +++ b/Difficalcy.Mania/Dockerfile @@ -1,4 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base + +LABEL org.opencontainers.image.source https://github.com/Syriiin/difficalcy + WORKDIR /app EXPOSE 80 ENV ASPNETCORE_URLS=http://+:80 diff --git a/Difficalcy.Osu/Dockerfile b/Difficalcy.Osu/Dockerfile index 42834cd..3e2c53d 100644 --- a/Difficalcy.Osu/Dockerfile +++ b/Difficalcy.Osu/Dockerfile @@ -1,4 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base + +LABEL org.opencontainers.image.source https://github.com/Syriiin/difficalcy + WORKDIR /app EXPOSE 80 ENV ASPNETCORE_URLS=http://+:80 diff --git a/Difficalcy.Taiko/Dockerfile b/Difficalcy.Taiko/Dockerfile index 77d12fd..1fee49f 100644 --- a/Difficalcy.Taiko/Dockerfile +++ b/Difficalcy.Taiko/Dockerfile @@ -1,4 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base + +LABEL org.opencontainers.image.source https://github.com/Syriiin/difficalcy + WORKDIR /app EXPOSE 80 ENV ASPNETCORE_URLS=http://+:80 diff --git a/Makefile b/Makefile index 0592d5b..15e9f85 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ COMPOSE_TOOLING_RUN = docker compose -f docker-compose.tooling.yml run --rm --bu COMPOSE_E2E = docker compose -f docker-compose.yml -f docker-compose.override.e2e.yml COMPOSE_E2E_RUN = $(COMPOSE_E2E) run --rm --build e2e-test-runner COMPOSE_APP_DEV = docker compose -f docker-compose.yml -f docker-compose.override.yml +COMPOSE_PUBLISH = docker compose -f docker-compose.yml -f docker-compose.override.publish.yml help: ## Show this help @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' @@ -24,3 +25,20 @@ start-dev: build-dev ## Starts development environment clean-dev: ## Cleans development environment $(COMPOSE_APP_DEV) down --remove-orphans + +# TODO: move gh into tooling container (requires env var considerations) +VERSION = +release: ## Pushes docker images to ghcr.io and create a github release +ifndef VERSION + $(error VERSION is undefined) +endif +ifndef GITHUB_PAT + $(error GITHUB_PAT env var is not set) +endif +ifndef GITHUB_USERNAME + $(error GITHUB_USERNAME env var is not set) +endif + echo $$GITHUB_PAT | docker login ghcr.io --username $$GITHUB_USERNAME --password-stdin + VERSION=$(VERSION) $(COMPOSE_PUBLISH) build + VERSION=$(VERSION) $(COMPOSE_PUBLISH) push difficalcy-osu difficalcy-taiko difficalcy-catch difficalcy-mania + gh release create "$(VERSION)" --generate-notes diff --git a/docker-compose.override.publish.yml b/docker-compose.override.publish.yml new file mode 100644 index 0000000..e891d69 --- /dev/null +++ b/docker-compose.override.publish.yml @@ -0,0 +1,12 @@ +services: + difficalcy-osu: + image: ghcr.io/syriiin/difficalcy-osu:${VERSION} + + difficalcy-taiko: + image: ghcr.io/syriiin/difficalcy-taiko:${VERSION} + + difficalcy-catch: + image: ghcr.io/syriiin/difficalcy-catch:${VERSION} + + difficalcy-mania: + image: ghcr.io/syriiin/difficalcy-mania:${VERSION} diff --git a/tooling.Dockerfile b/tooling.Dockerfile index c1e1b3d..1dd5d78 100644 --- a/tooling.Dockerfile +++ b/tooling.Dockerfile @@ -1,5 +1,11 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base +RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && apt update \ + && apt install gh -y + WORKDIR /app COPY Difficalcy.sln .