Compare commits

..

4 commits

Author SHA1 Message Date
27a1025eba
Bump version 0.2 -> 0.3 2020-04-29 10:20:56 +02:00
348a404288
Add example config 2020-04-29 10:20:43 +02:00
697ce20234
Add makefile and version automation 2020-04-29 10:20:38 +02:00
8f3eaa6e2f
Change docker image 2020-04-29 10:13:02 +02:00
7 changed files with 92 additions and 13 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/output/*

View file

@ -1,4 +1,4 @@
FROM golang:1.13 AS builder
FROM golang:1.14 AS builder
WORKDIR /app
COPY go.mod go.sum /app/
@ -6,18 +6,13 @@ RUN go mod download
COPY *go /app/
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -tags netgo -o /sendmail ./...
FROM busybox:latest AS shell
FROM gcr.io/distroless/static
ENV sm_server ""
ENV sm_port "465"
ENV sm_user ""
ENV sm_password ""
ENV sm_from ""
ENV sm_to ""
ENV sm_sub ""
COPY --from=builder /sendmail /
WORKDIR /
COPY --from=builder /sendmail /
COPY --from=shell /bin/cat /bin/date /bin/sh /bin/
COPY sendmail.sh /sendmail.sh
ENTRYPOINT ["/sendmail"]
ENTRYPOINT ["/sendmail.sh"]

34
Makefile Normal file
View file

@ -0,0 +1,34 @@
VERS_MAJOR := 0
VERS_MINOR := 3
VERSION := $(VERS_MAJOR).$(VERS_MINOR)
NEW_MINOR := $$(( $(VERS_MINOR) + 1 ))
NEW_MAJOR := $$(( $(VERS_MAJOR) + 1 ))
output:
output/sendmail: output
go build -o output/sendmail -ldflags "-X main.version=$(VERSION)" ./...
build: output/sendmail
bumpvers-minor:
sed -i"" "s/VERS_MINOR := $(VERS_MINOR)/VERS_MINOR := $(NEW_MINOR)/" Makefile
git add Makefile
git commit -m "Bump version $(VERSION) -> $(VERS_MAJOR).$(NEW_MINOR)"
git tag $(VERS_MAJOR).$(NEW_MINOR)
bumpvers-major:
sed -i"" "s/VERS_MAJOR := $(VERS_MAJOR)/VERS_MAJOR := $$(( $(VERS_MAJOR) + 1 ))/" Makefile
git add Makefile
git commit -m "Bump version $(VERSION) -> $(NEW_MAJOR).$(VERS_MINOR)"
git tag $(NEW_MAJOR).$(VERS_MINOR)
release-min:
make bumpvers-minor
make build
release-maj:
make bumpvers-major
make build
PHONY: bumpvers-minor bumpvers-major release-min release-maj

11
docker_test.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
docker run \
-e M_SERVER_ADDRESS=smtp.autistici.org \
-e M_USER=problemi.ma@anche.no \
-e M_PASSWORD=$(pass personal/ai/otp/mail/sendmail-stakhanov) \
-e M_FROM=blallo@autistici.org \
-e M_TO=blallo@riseup.net \
-e M_SUB="test mail from docker image" \
-e M_TEXT="Test from docker image" \
-ti leophys/sendmail:latest

16
examples/sendmail.toml Normal file
View file

@ -0,0 +1,16 @@
[default]
from = "my.default@example.com"
[default.server]
address = "mail.example.com"
port = 587
user = "my.default@example.com"
password = "correcthorsebatterystaple"
[other-account]
from = "my.other@mailprovider.org"
[ai.server]
address = "smtp.mailprovider.org"
port = 587
user = "my.correct.username@mailprovider.org"

View file

@ -8,7 +8,8 @@ import (
"strings"
)
var version = "0.1"
var noVersion = "dev"
var version string
func readFromConsole() string {
var text, line string
@ -90,7 +91,11 @@ func main() {
LogInit(dbg)
if versionFlag {
Info.F("Version: %s", version)
showVersion := noVersion
if version != "" {
showVersion = version
}
Info.F("Version: %s", showVersion)
os.Exit(0)
}

17
sendmail.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
cat << EOM | /sendmail \
-server-address=${M_SERVER_ADDRESS} \
-server-port=465 \
-user=${M_USER} \
-password=${M_PASSWORD} \
-from=${M_FROM} \
-to=${M_TO} \
-sub="${M_SUB}"
$(date +%Y-%m-%d_%H:%M)
---
${M_TEXT}
EOM