From 2d31f8f68fcea694129d74aa5711a3700f7e1bdf Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sat, 2 Mar 2024 14:28:17 +0100
Subject: [PATCH] feat(images): Rework release process for postfix and dovecot

---
 images/dovecot/.release  |  1 -
 images/dovecot/Earthfile | 14 ++++++++------
 images/postfix/.release  |  1 -
 images/postfix/Earthfile | 13 +++++++------
 4 files changed, 15 insertions(+), 14 deletions(-)
 delete mode 100644 images/dovecot/.release
 delete mode 100644 images/postfix/.release

diff --git a/images/dovecot/.release b/images/dovecot/.release
deleted file mode 100644
index 802d813b7..000000000
--- a/images/dovecot/.release
+++ /dev/null
@@ -1 +0,0 @@
-release=0.4.1
diff --git a/images/dovecot/Earthfile b/images/dovecot/Earthfile
index d79209b7b..f14663621 100644
--- a/images/dovecot/Earthfile
+++ b/images/dovecot/Earthfile
@@ -1,12 +1,7 @@
 VERSION 0.7
 
-container:
+container-internal:
     FROM ../mirror+alpine
-    ARG registry=quay.io/shivering-isles/dovecot
-    COPY .release ./
-    ARG tag=$(awk -F'=' '$1 == "release" {print $2}' .release)
-    ARG latest=false
-    # Update base system
     RUN apk add --no-cache ca-certificates
     RUN update-ca-certificates
 
@@ -48,6 +43,13 @@ container:
     EXPOSE 24 110 143 993 995 4190 12345
 
     ENTRYPOINT ["/usr/sbin/dovecot", "-F"]
+
+container:
+    FROM +container-internal
+    ARG registry=quay.io/shivering-isles/dovecot
+    ARG tag=$(dovecot --version | awk '{print $1}')
+    ARG latest=false
+    
     DO ../.utils/+LABEL --image=dovecot --version=main
     IF [ $latest = "true" ]
         SAVE IMAGE --push ${registry}:latest
diff --git a/images/postfix/.release b/images/postfix/.release
deleted file mode 100644
index 97107f2c6..000000000
--- a/images/postfix/.release
+++ /dev/null
@@ -1 +0,0 @@
-release=3.8.5
diff --git a/images/postfix/Earthfile b/images/postfix/Earthfile
index edd3e97dd..f2a4c5ffb 100644
--- a/images/postfix/Earthfile
+++ b/images/postfix/Earthfile
@@ -9,13 +9,8 @@ dhparams:
     RUN openssl dhparam -out ./postfix_dhparams.pem 2048 2>/dev/null
     SAVE ARTIFACT ./postfix_dhparams.pem
 
-container:
+container-internal:
     FROM ../mirror+alpine
-    ARG registry=quay.io/shivering-isles/postfix
-    COPY .release ./
-    ARG tag=$(awk -F'=' '$1 == "release" {print $2}' .release)
-    ARG latest=false
-
     # Install pre-requirements
     RUN apk add --no-cache ca-certificates
     RUN update-ca-certificates
@@ -28,6 +23,12 @@ container:
     EXPOSE 25 465 587
 
     ENTRYPOINT [ "postfix", "start-fg"]
+
+container:
+    FROM +container-internal    
+    ARG registry=quay.io/shivering-isles/postfix
+    ARG tag=$(postconf mail_version | sed -e 's/mail_version = //')
+    ARG latest=false
     DO ../.utils/+LABEL --image=postfix --version=main
     IF [ $latest = "true" ]
         SAVE IMAGE --push ${registry}:latest
-- 
GitLab