Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
b3n4kh committed Jan 22, 2023
1 parent f0d7ad5 commit 77cc8f4
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 19 deletions.
44 changes: 27 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,40 @@ on:
tags:
- '**'

permissions:
contents: write
packages: write

jobs:
build_container:
name: build container
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
cache: true
- name: get ghcr owner repository
run: |
echo "GHCR_OWNER=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: get ghcr owner repository
run: |
echo "GHCR_OWNER=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
- name: Checkout
uses: actions/checkout@v3
- name: Create Config
run: |
cp config.default.yml config.yml
- name: Build and push image
uses: docker/build-push-action@v3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
context: .
push: true
tags: |
ghcr.io/${{ env.GHCR_OWNER }}/mailwhale:latest
ghcr.io/${{ env.GHCR_OWNER }}/learners:${{ github.ref_name }}
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHCR_OWNER: ${{ env.GHCR_OWNER }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
config*.yml
!config.default.yml
mailwhale
*.db
node_modules
package-lock.json
package.json
dist
*.db
55 changes: 55 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
builds:
- id: mailwhale-builds
binary: mailwhale
dir: .
before:
hooks:
- sudo npm install -g yarn
- yarn --cwd webui
- yarn --cwd webui build
- cp config.default.yml config.yml
archives:
- id: mailwhale-archives
builds:
- mailwhale-builds
files:
- LICENSE
- README.md
- webui/public/*
- config.default.yml
- templates/*
- version.txt
replacements:
darwin: Darwin
linux: Linux
386: i386
amd64: x86_64
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
dockers:
- ids:
- mailwhale-builds
goos: linux
goarch: amd64
extra_files:
- "./go.mod"
- "./go.sum"
- "main.go"
- "version.txt"
- "config.yml"
- "LICENSE"
- "README.md"
- "assets/"
- "config/"
- "service/"
- "templates/"
- "types/"
- "util/"
- "web/"
- "webui/"

image_templates:
- "ghcr.io/{{ .Env.GHCR_OWNER }}/mailwhale:latest"
- "ghcr.io/{{ .Env.GHCR_OWNER }}/mailwhale:{{ .Tag }}"
release:
mode: replace
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ $ GO111MODULE=on go build
$ ./mailwhale
```

### From GitHub Release

```bash
# 1. Download latest release
curl -s https://api.github.com/repos/muety/mailwhale/releases/latest | jq -r ".assets[] | select(.name|match(\"Linux_$(arch).tar.gz\")) | .browser_download_url" | wget -qi -

# 2. Extract
mkdir /opt/mailwhale
tar xf mailwhale_*.tar.gz -C /opt/mailwhale
cd /opt/mailwhale

# 3. Adapt config to your needs, i.e. set your SMTP server and credentials, etc.
cp config.default.yml config.yml
vi config.yml

# 4. Run it
$ ./mailwhale
```

### With Docker Image

```bash
Expand All @@ -65,7 +84,7 @@ $ docker run -d \
-v "$(pwd)/config.yml":/app/config.yml:ro \
-v mailwhale_data:/data \
--name mailwhale \
docker pull ghcr.io/b3n4kh/mailwhale
docker pull ghcr.io/muety/mailwhale
```

### Build custom Docker Image
Expand Down

0 comments on commit 77cc8f4

Please sign in to comment.