Skip to content

Commit

Permalink
Merge pull request #21 from StevenMaude/github-actions-build-releases
Browse files Browse the repository at this point in the history
Build releases with GitHub Actions
  • Loading branch information
StevenMaude authored Jul 26, 2020
2 parents 8702913 + 79f43a6 commit fbed1bc
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- name: Build code
run: |
make build
make build-linux
- name: Run code
run: |
./go-mailin8 | grep "Usage: go-mailin8 <address>"
./go-mailin8_linux_amd64 | grep "Usage: go-mailin8_linux_amd64 <address>"
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
on:
push:
tags:
- 'v*'

name: Build and release binary

jobs:
build:
name: Build and release binary
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Build Linux binary
run: |
make build-linux
- name: Build Windows binary
run: |
make build-windows
- name: Calculate SHA256
run: |
sha256sum go-mailin8_linux_amd64 go-mailin8.exe > SHA256SUMS
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false

- name: Upload Linux binary to GitHub
id: upload-linux-binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./go-mailin8_linux_amd64
asset_name: go-mailin8_linux_amd64
asset_content_type: application/octet-stream

- name: Upload Windows binary to GitHub
id: upload-windows-binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./go-mailin8.exe
asset_name: go-mailin8.exe
asset_content_type: application/octet-stream

- name: Upload SHA256SUMS to GitHub
id: upload-sha256sums
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./SHA256SUMS
asset_name: SHA256SUMS
asset_content_type: text/plain
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/go-mailin8
# Compiled binaries
/go-mailin8_linux_amd64
/go-mailin8.exe
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM golang:1.14-alpine

USER nobody:nogroup

ARG GOOS

ENV CGO_ENABLED=0 XDG_CACHE_HOME=/tmp/.cache

WORKDIR /go/src/go-mailin8
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
build:
build-linux:
docker build . -t go-mailin8
docker run --rm --entrypoint cat go-mailin8 /go/bin/go-mailin8 > go-mailin8
chmod u+x go-mailin8
docker run --rm --entrypoint cat go-mailin8 /go/bin/go-mailin8 > go-mailin8_linux_amd64
chmod u+x go-mailin8_linux_amd64

.PHONY: build
build-windows:
docker build --build-arg GOOS=windows . -t go-mailin8
docker run --rm --entrypoint cat go-mailin8 /go/bin/windows_amd64/go-mailin8.exe > go-mailin8.exe

.PHONY: build-linux build-windows
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@ email service.

## Build

### Download

If you don't want to build from source, [Linux and Windows
binaries](https://github.com/StevenMaude/go-mailin8/releases) are built
from tagged versions via GitHub Actions.

### With Go installed

`go build`
`go build` or `go install`

### With Docker installed

`make`
* `make build-linux` (for a Linux build)
* `make build-windows` (for a Windows build)

## Usage

1. Send, or get an email sent to a [nada](https://getnada.com) email
address of your choosing.
2. Run `go-mailin8 <email address>`
2. Run the binary supplying `<email address>` as an argument, e.g.
`go-mailin8_linux_amd64 <email_address>`

## TODO:

Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"net/http"
"os"
"path/filepath"
)

type mail struct {
Expand Down Expand Up @@ -85,7 +86,7 @@ func getInbox(address string) (inbox, error) {
func main() {
// TODO: consider allow to retrieve more than one message.
if len(os.Args) != 2 {
fmt.Println("Usage: go-mailin8 <address>")
fmt.Printf("Usage: %v <address>\n", filepath.Base(os.Args[0]))
os.Exit(1)
}

Expand Down

0 comments on commit fbed1bc

Please sign in to comment.