Skip to content

Commit

Permalink
Fix release pipline
Browse files Browse the repository at this point in the history
Squashed previous attempts to fix it.
  • Loading branch information
simplylizz committed Aug 12, 2023
1 parent 55956b4 commit 82f9a41
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
55 changes: 55 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
builds:
- id: smtp_to_telegram
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }}
goos:
- darwin
- linux
goarch:
- amd64
- arm64
- arm
goarm:
- '7'
binary: smtp_to_telegram
tags:
- urfave_cli_no_docs

dockers:
- image_templates:
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-amd64'
use: buildx
dockerfile: Dockerfile.release
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"

- image_templates:
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-arm64'
use: buildx
dockerfile: Dockerfile.release
build_flag_templates:
- "--pull"
- "--platform=linux/arm64/v8"

- image_templates:
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-armv7'
use: buildx
dockerfile: Dockerfile.release
build_flag_templates:
- "--pull"
- "--platform=linux/arm/v7"

docker_manifests:
- name_template: 'simplylizz/smtp_to_telegram:{{ .Tag }}'
image_templates:
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-amd64'
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-arm64'
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-armv7'
- name_template: 'simplylizz/smtp_to_telegram:latest'
image_templates:
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-amd64'
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-arm64'
- 'simplylizz/smtp_to_telegram:{{ .Tag }}-armv7'
12 changes: 6 additions & 6 deletions smtp_to_telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ func SendAttachmentToChat(
return nil
}

func FormatEmail(e *mail.Envelope, telegramConfig *TelegramConfig) (*FormattedEmail, error) {
reader := e.NewReader()
func FormatEmail(envelope *mail.Envelope, telegramConfig *TelegramConfig) (*FormattedEmail, error) {
reader := envelope.NewReader()
env, err := enmime.ReadEnvelope(reader)
if err != nil {
return nil, fmt.Errorf("%s\n\nError occurred during email parsing: %v", e, err)
return nil, fmt.Errorf("%s\n\nError occurred during email parsing: %v", envelope, err)
}
text := env.Text

Expand Down Expand Up @@ -514,7 +514,7 @@ func FormatEmail(e *mail.Envelope, telegramConfig *TelegramConfig) (*FormattedEm
}

if text == "" {
text = e.Data.String()
text = envelope.Data.String()
}

formattedAttachmentsDetails := ""
Expand All @@ -526,8 +526,8 @@ func FormatEmail(e *mail.Envelope, telegramConfig *TelegramConfig) (*FormattedEm
}

fullMessageText, truncatedMessageText := FormatMessage(
e.MailFrom.String(),
JoinEmailAddresses(e.RcptTo),
envelope.MailFrom.String(),
JoinEmailAddresses(envelope.RcptTo),
env.GetHeader("subject"),
text,
formattedAttachmentsDetails,
Expand Down
18 changes: 9 additions & 9 deletions smtp_to_telegram_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,19 @@ func TestAttachmentsSending(t *testing.T) {
m.Attach("attachment.jpg", goMailBody([]byte("JPG")))

expFiles := []*FormattedAttachment{
&FormattedAttachment{
{
filename: "inline.jpg",
caption: "inline.jpg",
content: []byte("JPG"),
fileType: ATTACHMENT_TYPE_PHOTO,
},
&FormattedAttachment{
{
filename: "hey.txt",
caption: "hey.txt",
content: []byte("hi"),
fileType: ATTACHMENT_TYPE_DOCUMENT,
},
&FormattedAttachment{
{
filename: "attachment.jpg",
caption: "attachment.jpg",
content: []byte("JPG"),
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestLargeMessageAggressivelyTruncated(t *testing.T) {
"\n" +
strings.Repeat("Hello_", 60)
expFiles := []*FormattedAttachment{
&FormattedAttachment{
{
filename: "full_message.txt",
caption: "Full message",
content: []byte(expFull),
Expand Down Expand Up @@ -387,7 +387,7 @@ func TestLargeMessageProperlyTruncated(t *testing.T) {
"\n" +
strings.Repeat("Hello_", 60)
expFiles := []*FormattedAttachment{
&FormattedAttachment{
{
filename: "full_message.txt",
caption: "Full message",
content: []byte(expFull),
Expand Down Expand Up @@ -447,13 +447,13 @@ func TestLargeMessageWithAttachmentsProperlyTruncated(t *testing.T) {
"Attachments:\n" +
"- 📎 attachment.jpg (image/jpeg) 3B, sending..."
expFiles := []*FormattedAttachment{
&FormattedAttachment{
{
filename: "full_message.txt",
caption: "Full message",
content: []byte(expFull),
fileType: ATTACHMENT_TYPE_DOCUMENT,
},
&FormattedAttachment{
{
filename: "attachment.jpg",
caption: "attachment.jpg",
content: []byte("JPG"),
Expand Down Expand Up @@ -529,7 +529,7 @@ hoho
.`

expFiles := []*FormattedAttachment{
&FormattedAttachment{
{
filename: "tt",
caption: "tt",
content: []byte("hoho\n"),
Expand Down Expand Up @@ -606,7 +606,7 @@ aG9obwo=
.`

expFiles := []*FormattedAttachment{
&FormattedAttachment{
{
filename: "tt",
caption: "./tt",
content: []byte("hoho\n"),
Expand Down

0 comments on commit 82f9a41

Please sign in to comment.