Skip to content

Commit

Permalink
Release 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreben committed Dec 21, 2018
0 parents commit 9b0191b
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/binaries
/release
/emoji
75 changes: 75 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
VERSION = 1.1.2

APP := slack-emoji-upload
PACKAGES := $(shell go list -f {{.Dir}} ./...)
GOFILES := $(addsuffix /*.go,$(PACKAGES))
GOFILES := $(wildcard $(GOFILES))

.PHONY: clean release

clean:
rm -rf binaries/
rm -rf release/

release: zip README.md
git add README.md
git add Makefile
git commit -am "Release $(VERSION)" || true
git push
hub release create $(VERSION) -m "$(VERSION)" -a release/$(APP)_$(VERSION)_osx_x86_64.zip -a release/$(APP)_$(VERSION)_windows_x86_64.zip -a release/$(APP)_$(VERSION)_linux_x86_64.zip -a release/$(APP)_$(VERSION)_osx_x86_32.zip -a release/$(APP)_$(VERSION)_windows_x86_32.zip -a release/$(APP)_$(VERSION)_linux_x86_32.zip -a release/$(APP)_$(VERSION)_linux_arm64.zip

docker-build-cron: $(GOFILES)
docker build -t slack-emoji-upload-cron -f contrib/cron/Dockerfile .

zip: release/$(APP)_$(VERSION)_osx_x86_64.zip release/$(APP)_$(VERSION)_windows_x86_64.zip release/$(APP)_$(VERSION)_linux_x86_64.zip release/$(APP)_$(VERSION)_osx_x86_32.zip release/$(APP)_$(VERSION)_windows_x86_32.zip release/$(APP)_$(VERSION)_linux_x86_32.zip release/$(APP)_$(VERSION)_linux_arm64.zip

binaries: binaries/osx_x86_64/$(APP) binaries/windows_x86_64/$(APP).exe binaries/linux_x86_64/$(APP) binaries/osx_x86_32/$(APP) binaries/windows_x86_32/$(APP).exe binaries/linux_x86_32/$(APP)

release/$(APP)_$(VERSION)_osx_x86_64.zip: binaries/osx_x86_64/$(APP)
mkdir -p release
cd ./binaries/osx_x86_64 && zip -r -D ../../release/$(APP)_$(VERSION)_osx_x86_64.zip $(APP)

binaries/osx_x86_64/$(APP): $(GOFILES)
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/osx_x86_64/$(APP)

release/$(APP)_$(VERSION)_windows_x86_64.zip: binaries/windows_x86_64/$(APP).exe
mkdir -p release
cd ./binaries/windows_x86_64 && zip -r -D ../../release/$(APP)_$(VERSION)_windows_x86_64.zip $(APP).exe

binaries/windows_x86_64/$(APP).exe: $(GOFILES)
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/windows_x86_64/$(APP).exe

release/$(APP)_$(VERSION)_linux_x86_64.zip: binaries/linux_x86_64/$(APP)
mkdir -p release
cd ./binaries/linux_x86_64 && zip -r -D ../../release/$(APP)_$(VERSION)_linux_x86_64.zip $(APP)

binaries/linux_x86_64/$(APP): $(GOFILES)
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/linux_x86_64/$(APP)

release/$(APP)_$(VERSION)_osx_x86_32.zip: binaries/osx_x86_32/$(APP)
mkdir -p release
cd ./binaries/osx_x86_32 && zip -r -D ../../release/$(APP)_$(VERSION)_osx_x86_32.zip $(APP)

binaries/osx_x86_32/$(APP): $(GOFILES)
GOOS=darwin GOARCH=386 go build -ldflags "-X main.version=$(VERSION)" -o binaries/osx_x86_32/$(APP)

release/$(APP)_$(VERSION)_windows_x86_32.zip: binaries/windows_x86_32/$(APP).exe
mkdir -p release
cd ./binaries/windows_x86_32 && zip -r -D ../../release/$(APP)_$(VERSION)_windows_x86_32.zip $(APP).exe

binaries/windows_x86_32/$(APP).exe: $(GOFILES)
GOOS=windows GOARCH=386 go build -ldflags "-X main.version=$(VERSION)" -o binaries/windows_x86_32/$(APP).exe

release/$(APP)_$(VERSION)_linux_x86_32.zip: binaries/linux_x86_32/$(APP)
mkdir -p release
cd ./binaries/linux_x86_32 && zip -r -D ../../release/$(APP)_$(VERSION)_linux_x86_32.zip $(APP)

binaries/linux_x86_32/$(APP): $(GOFILES)
GOOS=linux GOARCH=386 go build -ldflags "-X main.version=$(VERSION)" -o binaries/linux_x86_32/$(APP)

release/$(APP)_$(VERSION)_linux_arm64.zip: binaries/linux_arm64/$(APP)
mkdir -p release
cd ./binaries/linux_arm64 && zip -r -D ../../release/$(APP)_$(VERSION)_linux_arm64.zip $(APP)

binaries/linux_arm64/$(APP): $(GOFILES)
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/linux_arm64/$(APP)
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# slack-emoji-upload

Upload custom Slack emoji from the CLI.

<!-- TOC -->

- [Get it](#get-it)
- [Use it](#use-it)
- [Authentication](#authentication)
- [Token](#token)
- [Password](#password)
- [Example](#example)
- [Token auth](#token-auth)
- [Password auth](#password-auth)

<!-- /TOC -->


## Get it

- Either download the statically linked binary from [the latest release](https://github.com/sgreben/slack-emoji-upload/releases/latest)

- ...or use `go get`:
```sh
go get github.com/sgreben/slack-emoji-upload
```

## Use it

```text
slack-emoji-upload OPTIONS [FILES]
Options:
-token string
Slack API token
-email string
user email (required when -token not specified)
-password string
user password (required when -token not specified)
-team string
Slack team (required when -token not specified)
```

## Authentication

### Token

To authenticate with a token (`-token` option), you need to use a `xoxs-*` Slack API token, not a regular user token. It looks something like this:

```
xoxs-abcdefghij-klmnopqrstuv-wxyzabcdefgh-ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst
```
### Password
Alternatively, you can provide your `-team`, `-email` and `-password` to let the app obtain a `xoxs-*` API token for you.
## Example
### Token auth
```sh
$ slack-emoji-upload -token "$MY_TOKEN" emoji/*.*
2018/09/11 11:34:53 reeeeee: uploading "/tmp/emoji/reeeeee.gif"
2018/09/11 11:34:55 reeeeee: uploaded
2018/09/11 11:34:55 yeet: uploading "/tmp/emoji/yeet.png"
2018/09/11 11:34:57 yeet: uploaded
```

### Password auth

```sh
$ slack-emoji-upload -team my-team -email "me@example.com" -password "hunter2" emoji/*.*
2018/09/11 11:34:53 reeeeee: uploading "/tmp/emoji/reeeeee.gif"
2018/09/11 11:34:55 reeeeee: uploaded
2018/09/11 11:34:55 yeet: uploading "/tmp/emoji/yeet.png"
2018/09/11 11:34:57 yeet: uploaded
```
31 changes: 31 additions & 0 deletions contrib/cron/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:1.11-alpine AS minicron
RUN apk add --no-cache git
ENV CGO_ENABLED 0
RUN go get -u github.com/networkteam/minicron && \
cp "${GOPATH}/bin/minicron" /app

FROM golang:1.11-alpine AS build
COPY . "${GOPATH}"/src/app/
ENV CGO_ENABLED 0
RUN go install app && \
cp "${GOPATH}/bin/app" /app

FROM alpine:3.7
RUN apk add --no-cache ca-certificates

COPY --from=minicron /app /minicron
COPY --from=build /app /slack-emoji-upload

VOLUME [ "/emoji" ]
RUN >/task printf "%s\n" "#!/bin/sh -eu" && \
>>/task printf "%s\n" '/slack-emoji-upload $* /emoji/*.*' && \
chmod +x /task
RUN >/entrypoint printf "%s\n" "#!/bin/sh -eu" && \
>>/entrypoint printf "%s\n" 'SCHEDULE=$1' && \
>>/entrypoint printf "%s\n" 'shift' && \
>>/entrypoint printf "%s\n" '/minicron -v -c emoji "$SCHEDULE" "/task $*"' && \
chmod +x /entrypoint

# Example usage:
# docker run -v ~/Emoji:/emoji slack-emoji-upload-cron "@every 12h" -team my-team -token "$SLACK_API_TOKEN"
ENTRYPOINT [ "/entrypoint" ]
Loading

0 comments on commit 9b0191b

Please # to comment.