-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9b0191b
Showing
5 changed files
with
540 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/binaries | ||
/release | ||
/emoji |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
Oops, something went wrong.