Skip to content

Commit

Permalink
prepare first release
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Sep 25, 2022
1 parent cae3e53 commit 5270b3c
Show file tree
Hide file tree
Showing 11 changed files with 693 additions and 25 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: goreleaser

on:
push:
tags:
- '*'


jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ~1.19

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Install eget
run: go install github.com/zyedidia/eget@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ test.yaml
/coverage.out
/.vscode/*.log
/go.work*
/dist
62 changes: 62 additions & 0 deletions .godownloader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
project_name: imap

builds:
- id: imap_targz
env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
- windows
goarch:
- 386
- amd64
- arm
- arm64
goarm:
- 6
- 7
ignore:
- goos: darwin
goarch: arm
- goos: freebsd
goarch: arm64
- goos: windows
goarch: arm
- goos: windows
goarch: arm64

- id: imap_zip
env:
- CGO_ENABLED=0
goos:
- darwin
- windows
goarch:
- 386
- amd64

archives:
- id: targz
builds:
- imap_targz
format: tar.gz

- id: zip
builds:
- imap_zip
format: zip

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
123 changes: 123 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
project_name: imap

builds:
- id: imap_targz
env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
- windows
goarch:
- "386"
- amd64
- arm
- arm64
goarm:
- "6"
- "7"
ignore:
- goos: darwin
goarch: arm
- goos: freebsd
goarch: arm64
- goos: windows
goarch: arm
- goos: windows
goarch: arm64

- id: imap_zip
env:
- CGO_ENABLED=0
goos:
- darwin
- windows
goarch:
- "386"
- amd64

archives:
- id: targz
builds:
- imap_targz
format: tar.gz

- id: zip
builds:
- imap_zip
format: zip

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

dockers:
- image_templates:
- "creativeprojects/imap:latest-amd64"
- "creativeprojects/imap:{{ .RawVersion }}-amd64"
ids:
- imap_targz
use: buildx
goos: linux
goarch: amd64
dockerfile: build/Dockerfile
build_flag_templates:
- "--platform=linux/amd64"
- "--build-arg=ARCH=amd64"
- image_templates:
- "creativeprojects/imap:latest-arm64v8"
- "creativeprojects/imap:{{ .RawVersion }}-arm64v8"
ids:
- imap_targz
use: buildx
goos: linux
goarch: arm64
dockerfile: build/Dockerfile
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--build-arg=ARCH=arm64"

docker_manifests:
- name_template: creativeprojects/imap:{{ .RawVersion }}
image_templates:
- creativeprojects/imap:{{ .RawVersion }}-amd64
- creativeprojects/imap:{{ .RawVersion }}-arm64v8
- name_template: creativeprojects/imap:latest
image_templates:
- creativeprojects/imap:latest-amd64
- creativeprojects/imap:latest-arm64v8

brews:
-
name: imap
ids:
- targz
goarm: "6"
tap:
owner: creativeprojects
name: "homebrew-tap"
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
commit_author:
name: goreleaser
email: fred@creativeprojects.tech
folder: Formula
homepage: https://github.com/creativeprojects/{{ .ProjectName }}
description: "IMAP tools: backup, copy, move your emails between servers and locally"
license: "GPL-3.0-only"
custom_block: |
head "https://github.com/creativeprojects/{{ .ProjectName }}.git"
install: |
bin.install "{{ .ProjectName }}"
release:
draft: true
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOTOOL=$(GOCMD) tool
GOMOD=$(GOCMD) mod
GOPATH?=`$(GOCMD) env GOPATH`
GOPATH?=$(shell $(GOCMD) env GOPATH)
GOBIN?=$(shell $(GOCMD) env GOBIN)

BINARY=imap
BINARY_LINUX=$(BINARY)_linux
Expand All @@ -20,7 +21,7 @@ BUILD_DATE=`date`
BUILD_COMMIT=`git rev-parse HEAD`

all: download test build
.PHONY: all download test build build-linux install dovecot
.PHONY: all download test coverage build build-linux install dovecot nightly generate-install

download:
@echo "[*] $@"
Expand Down Expand Up @@ -49,4 +50,20 @@ install: download

dovecot:
@echo "[*] $@"
docker run -d --rm -p 143:143 -p 993:993 dovecot/dovecot:latest
docker run -d --rm -p 143:143 -p 993:993 dovecot/dovecot:latest

$(GOBIN)/eget:
@echo "[*] $@"
go install -v github.com/zyedidia/eget@latest

$(GOBIN)/goreleaser: $(GOBIN)/eget
@echo "[*] $@"
eget goreleaser/goreleaser --to $(GOBIN)

nightly: $(GOBIN)/goreleaser
@echo "[*] $@"
goreleaser --snapshot --skip-publish --rm-dist

generate-install:
@echo "[*] $@"
godownloader .godownloader.yml -r creativeprojects/imap -o install.sh
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ Backup, copy, move your emails from and to IMAP servers. It can also load and sa

## commands implemented:

* list (mailboxes)
* copy all message from one backend to another one
* `list`: list mailboxes from the account
* `copy`: copy all messages from one account to another one (incremental copy)

## keeping history for the incremental copy

The copy command will save a history of messages copied from the source. The history is saved on the destination backend. This is needed to associate the messages IDs of the source with the destination.

The way the history is saved is different for each backend:
* local: the history is saved in the database besides the messages
* Maildir: the history is saved in a file `<mailbox name>.history.json`
* imap: the history is saved in a folder `.cache`

The incremental copy will break if you delete the history: all messages will be copied again.

## configuration file

Expand Down
13 changes: 13 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:latest

LABEL maintainer Fred <fred@gcreativeprojects.tech>

ARG ARCH=amd64

COPY imap /usr/bin/imap

VOLUME /imap
WORKDIR /imap

ENTRYPOINT ["imap"]
CMD ["--help"]
1 change: 1 addition & 0 deletions cmd/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func runCopy(cmd *cobra.Command, args []string) error {
if err != nil {
term.Error(err.Error())
}
// we still save history even if an error occurred
if len(entries) > 0 {
action := mailbox.HistoryAction{
SourceAccountTag: mailbox.AccountTag(accountSource.ServerURL, accountSource.Username),
Expand Down
Loading

0 comments on commit 5270b3c

Please sign in to comment.