Skip to content
Permalink
Browse files

Deliver artifacts through goreleaser

  • Loading branch information...
crazy-max committed Feb 17, 2019
1 parent 1f906af commit b74b3418336ae1cad1e5b839b5a95f4109533e1c
Showing with 120 additions and 21 deletions.
  1. +2 βˆ’0 .dockerignore
  2. +1 βˆ’0 .gitignore
  3. +41 βˆ’0 .goreleaser.yml
  4. +27 βˆ’10 .travis.yml
  5. +2 βˆ’1 CHANGELOG.md
  6. +33 βˆ’4 README.md
  7. +13 βˆ’6 build.sh
  8. +1 βˆ’0 go.sum
@@ -6,8 +6,10 @@
/.github
/.res
/bin
/dist
/.editorconfig
/.gitignore
/.goreleaser.yml
/.travis.yml
/build.sh
/CHANGELOG.md
@@ -3,3 +3,4 @@

/.dev
/bin
/dist
@@ -0,0 +1,41 @@
before:
hooks:
- go mod download
builds:
-
main: ./cmd/main.go
ldflags:
- -s -w -X main.version={{.Version}}
env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- freebsd
- windows
goarch:
- 386
- amd64
- arm
- arm64
goarm:
- 6
- 7
ignore:
- goos: freebsd
goarch: arm
- goos: freebsd
goarch: arm64
archive:
replacements:
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- README.md
- CHANGELOG.md
checksum:
name_template: 'checksums.txt'
@@ -1,11 +1,18 @@
sudo: required
language: go
go:
- 1.11.x

services:
- docker

addons:
apt:
packages:
- docker-ce

env:
global:
- VERSION=0.2.1
- GO111MODULE=on
- DOCKER_LOGIN=crazymax
- DOCKER_USERNAME=crazymax
- DOCKER_REPONAME=swarm-cronjob
@@ -16,18 +23,28 @@ env:
- secure: Si24RzA40uuVEBf6lwjGpARSDJsw4e1SRBJRUHcTa6yw8u6aeQBloRadniua/VxPXpMKW4XXBB3wbF0NHWVDZGvD3W5AEWtZztdW6oX8Xn8w8TeoCRB+Kdie6yDLh8qSFFbkB0tQSn+RXQG/GgJ+Q/xqvg+jWHmr6djiwQyqjp3iPAO+m6SXW7UhTJOeFFZi8Ndhju1O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fK1QeAqfhrcwqRcMQVEsiWs40dVotPaKSHaZMKlHCLy46V3+cidicYLUPYvyQzmc65EMerrDDuRsqDPrSMpnqNHoWs2gLIfH0RTyCWjJ48= # QUAY_PASSWORD

addons:
apt:
packages:
- docker-ce

before_install:
- sudo apt-get update
- docker --version
- export ADVERTISE_ADDR=$(dig +short myip.opendns.com @resolver1.opendns.com)

install:
- curl -sL https://git.io/goreleaser | head -n -2 | bash
- tar -xf /tmp/goreleaser.tar.gz -C $GOPATH/bin
- goreleaser -v

script: ./build.sh

notifications:
webhooks:
secure: atDBHzaQWT23RVZ17YgM08Bja7SZrsPIq1LYgMQkRUXCm9I5iAqzAeLWE3+MlnVVvIBbX1hQu3g9gDFdWpfqJZoQYIE+pNK9fuNc5skZPBxLTZbKOvMblCmYr6E5mbexR0OdolHsFEx5/pAVkzICRhGpHemY3C262QjTw5DDtqysLhx3BckzKe0O71k4jjtckml2FWVucWqUGUxyfWJDT73ffPBKMprDi0IpSNzCIAEuxzuL0iR1EzJLGqg1MAZbsda9Y6F/rMi5z7l3k5V/hjCwGcYhZCKHvIP/uhStFxyTXnZscl/Qv+v4Fc5W9U9eZ5Oc4nGTzkxq71Q0wMnpkq718nEQ+7v+VBcP6XC+AXiVCqQcOKvbewPYXzOWHbG0j1D8hYB/QrOnW29QcDr+burVoCv77hsOhCzN1QzDnw8AEso5EkYjKq70Hdw++sFlxxMrZ49VVe36xKfOoVRY3ylvX2YwoS5gMZUCxcI+c5JnRcUiR/g+9xNDDTHnSTexfFOHpRCZd1LyJeBlAWSq6NriClsOUiHGxgaLskU/lEKtmgAQl5uxeMAn03otGGNTaHO/ZYkcpECDF81CL2UVN8zZK+/7FXKBeqctS4L/uDr7KABVV6YpQLO8m8UNwZy8lJOF815hWbkTqxxvtlHr9r6ZYWG+uvuYAQChK6oatU4=
deploy:
provider: releases
api_key:
secure: Tu4MQ2Yt4L7Dn4MdQ3XrRVlPleFJy5PtwgTabNfpaNO/Lb5zul38xoJsUslWuPO05yAig58p3vhwfj/0mEHqDDgDkeRhLakVPXYHRfhneuw23CrTd7IVfR79tLnhO63arjAN06w8pSY09WnM2fdSUOliT8iVOsRMc7fm2x7jF+Mx3hU/mXZ1SDHddHRwO31aVSlr43ntSgfjjUFAIjCSOPnMNSovoxX51tYNZP0/9nerhaIG551W1D7kGgXoyFchThCpLU8nOKlGWAw+Xc2zNQ5FxsitH46VauLHUEHxLQixp3r565szmwfcwvle0ciF22loywOq3NH9+qjHlf0TzzFewgdlQBCp3uCVqh8m2OlruHEgtbgNkt3uqcFTN2WgQW6R2zmCD5MbDkua6EBKjNEQdDF3AgCiDOY0WIfWhYAQ62JUkE/5Sv8pM7BlyI3IzEHZqsxTM6WqSe3U1cTiSdBjWDll+WCuJrwH2UnASVcliFQ82MGCtRDOfLV3snB+H2TRMbhd18MG2/bk1RIpxjS4/epKBwHAqSt1XY8KBhIh4luoQSTfkB0NgQGsk8ZL777iotC+xLv91vdve3xqWXRdrEvtO+g9MILjjI7y+WpdN7njerzTiqgzAlzedwDc2kDWiZqBQpaz1ppMoNcPg/Qj0pqZF9mylkFK+keyRao=
file_glob: true
file:
- dist/checksums.txt
- dist/*.tar.gz
- dist/*.zip
skip_cleanup: true
draft: true
on:
tags: true
@@ -1,8 +1,9 @@
# Changelog

## 1.0.0 (2019/02/16)
## 1.0.0 (2019/02/17)

* Add JSON log output
* Deliver artifacts through goreleaser
* Review project structure

## 0.2.1 (2019/01/24)
@@ -32,7 +32,7 @@
## Quickstart
### Deploy swarm-cronjob
### Swarm cluster
Create a service that uses the swarm-cronjob image :
@@ -49,8 +49,6 @@ Alternatively, you can deploy the stack [swarm_cronjob.yml](.res/example/swarm_c
`docker stack deploy -c swarm_cronjob.yml swarm_cronjob`
### Deploy a stack
Now that we have a swarm-cronjob instance up and running, we will deploy new services.
Create a new stack based on [this one (date)](.res/example/date.yml). You can include any configuration as long as you abide with the following conditions :
@@ -69,7 +67,38 @@ Once ready, deploy your cron stack on the swarm cluster :
> :bulb: More examples can be found [here](.res/example)
### Logs
### Without Docker
swarm-cronjob binaries are available in [releases](https://github.com/crazy-max/swarm-cronjob/releases) page.
Choose the archive matching the destination platform and extract swarm-cronjob:
```
$ cd /opt
$ wget -qO- https://github.com/crazy-max/swarm-cronjob/releases/download/1.0.0/swarm-cronjob_1.0.0_linux_x86_64.tar.gz | tar -zxvf - swarm-cronjob
```
After getting the binary, it can be tested with `swarm-cronjob --help` or moved to a permanent location.
When launched manually, swarm-cronjob can be killed using `Ctrl+C`:
```
$ swarm-cronjob --help
usage: swarm-cronjob [<flags>]
Create jobs on a time-based schedule on Swarm. More info on
https://github.com/crazy-max/swarm-cronjob
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--timezone="UTC" Timezone assigned to the scheduler.
--log-level="info" Set log level.
--log-json Enable JSON logging output.
--version Show application version.
```
## Logs
Here is a sample output:
```
$ docker service logs swarm_cronjob_app
@@ -2,6 +2,7 @@
set -e

PROJECT=swarm-cronjob
VERSION=${TRAVIS_TAG:-dev}
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
BUILD_TAG=docker_build
BUILD_WORKINGDIR=${BUILD_WORKINGDIR:-.}
@@ -18,17 +19,17 @@ QUAY_USERNAME=${QUAY_USERNAME:-crazymax}
QUAY_LOGIN=${QUAY_LOGIN:-crazymax}
QUAY_REPONAME=${QUAY_REPONAME:-swarm-cronjob}

# Check local or travis
# Check dev or travis
BRANCH=${TRAVIS_BRANCH:-local}
if [[ ${TRAVIS_PULL_REQUEST} == "true" ]]; then
BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}
fi
DOCKER_TAG=${BRANCH:-local}
if [[ "$BRANCH" == "master" ]]; then
DOCKER_TAG=latest
VERSION=${VERSION#v}
elif [[ "$BRANCH" == "local" ]]; then
BUILD_DATE=
VERSION=local
fi

echo "PROJECT=${PROJECT}"
@@ -51,8 +52,14 @@ echo "BRANCH=${BRANCH}"
echo "DOCKER_TAG=${DOCKER_TAG}"
echo

# Build
echo "### Build"
echo "### Goreleaser"
if [[ -n "$TRAVIS_TAG" ]]; then
goreleaser release --skip-publish --rm-dist
else
goreleaser release --snapshot --rm-dist
fi

echo "### Docker build"
docker build \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg VCS_REF=${VCS_REF} \
@@ -92,8 +99,8 @@ done < <(docker service logs -f ${PROJECT} 2>&1)
echo
docker swarm leave --force > /dev/null 2>&1 || true

if [ "${VERSION}" == "local" -o "${TRAVIS_PULL_REQUEST}" == "true" ]; then
echo "INFO: This is a PR or a local build, skipping push..."
if [ "${VERSION}" == "dev" -o "${TRAVIS_PULL_REQUEST}" == "true" ]; then
echo "INFO: This is a PR or a dev build, skipping push..."
exit 0
fi
if [[ ! -z ${DOCKER_PASSWORD} ]]; then
1 go.sum
@@ -17,6 +17,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/engine v0.0.0-20180718150940-a3ef7e9a9bda h1:v1VUX0+ILrFSsGTp2FUvfgHSiQ6wmI1NnCho1MQ9CYU=
github.com/docker/engine v0.0.0-20180718150940-a3ef7e9a9bda/go.mod h1:3CPr2caMgTHxxIAZgEMd3uLYPDlRvPqCpyeRf6ncPcY=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=

0 comments on commit b74b341

Please sign in to comment.
You can’t perform that action at this time.