Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with goreleaser #17

Merged
merged 1 commit into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: golangci-lint
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: goreleaser

on:
push:
tags:
- '*'

jobs:
goreleaser:
runs-on: ubuntu-20.04
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.so
*.dylib
bin/
dist/

# Test binary, built with `go test -c`
*.test
Expand Down
65 changes: 65 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
before:
hooks:
- go mod download

builds:
- env:
- CGO_ENABLED=0
main: ./cmd/replicator/main.go
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.buildDate={{.Date}}
goarch:
- amd64

archives:
- files:
- LICENSE
- README.md
- config/*

checksum:
name_template: 'checksums.txt'
# Algorithm to be used.
# Accepted options are sha256, sha512, sha1, crc32, md5, sha224 and sha384.
# Default is sha256.
algorithm: sha256

snapshot:
name_template: "{{ .Tag }}-SNAPSHOT-{{.ShortCommit}}"

changelog:
skip: true

nfpms:
- id: default
package_name: mysql-tarantool-replicator

maintainer: Pavel Parshin <parshin.pn@gmail.com>
homepage: https://github.com/pparshin/go-mysql-tarantool
description: MySQL - Tarantool replicator
license: MIT

formats:
- deb
- rpm

dependencies: ~
recommends:
- mysql-client
suggests: ~
conflicts: ~

bindir: /usr/local/bin

epoch: 1
release: 1

scripts:
postinstall: "scripts/postinstall.sh"
preremove: "scripts/preremove.sh"

files:
"scripts/etc/systemd/**": "/etc/systemd/system"

config_files:
"config/replicator.conf.yml": "/etc/mysql-tarantool/conf.yml"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lint:

.PHONY: run
run: build
bin/${BINARY} -config=configs/dev.yml
bin/${BINARY} -config=config/replicator.conf.yml

.PHONY: run_short_tests
run_short_tests:
Expand Down
4 changes: 2 additions & 2 deletions configs/example.yml → config/replicator.conf.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
app:
listen_addr: ':8080'
data_file: '/etc/mysql-tarantool-replicator/state.info'
data_file: '/etc/mysql-tarantool/state.info'
logging:
level: 'debug'
syslog_enabled: false
file_enabled: true
file_name: '/tmp/mysql-tarantool-repl.log'
file_name: '/var/log/mysql-tarantool-replicator.log'
file_max_size: 256
file_max_backups: 3
file_max_age: 5
Expand Down
13 changes: 13 additions & 0 deletions scripts/etc/systemd/mysql-tarantool-replicator.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=mysql-tarantool-replicator: MySQL binlog replication to Tarantool.
Documentation=https://github.com/pparshin/go-mysql-tarantool
After=syslog.target network.target

[Service]
Type=simple
WorkingDirectory=/usr/local/bin
ExecStart=/usr/local/bin/mysql-tarantool-replicator -config /etc/mysql-tarantool/conf.yml
TimeoutSec=30

[Install]
WantedBy=multi-user.target
7 changes: 7 additions & 0 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

systemctl --system daemon-reload >/dev/null || true
systemctl enable mysql-tarantool-replicator.service >/dev/null || true

deb_systemctl=$(command -v deb-systemd-invoke || echo systemctl)
${deb_systemctl} restart mysql-tarantool-replicator.service >/dev/null || true
7 changes: 7 additions & 0 deletions scripts/preremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

deb_systemctl=$(command -v deb-systemd-invoke || echo systemctl)
${deb_systemctl} stop mysql-tarantool-replicator.service >/dev/null || true

systemctl disable mysql-tarantool-replicator.service >/dev/null || true
systemctl --system daemon-reload >/dev/null || true