Browse Source

add release distribution with Goreleaser (https://goreleaser.com)

fix/packr-gorelease
Pantani 3 years ago
parent
commit
88b17cbe99
5 changed files with 83 additions and 18 deletions
  1. +29
    -0
      .github/workflows/release.yml
  2. +36
    -0
      .goreleaser.yml
  3. +6
    -6
      Makefile
  4. +2
    -2
      README.md
  5. +10
    -10
      cli/node/main.go

+ 29
- 0
.github/workflows/release.yml

@ -0,0 +1,29 @@
name: goreleaser
on:
push:
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 36
- 0
.goreleaser.yml

@ -0,0 +1,36 @@
before:
hooks:
- go mod download
builds:
- main: ./cli/node/main.go
binary: node
id: node
goos:
- linux
- darwin
- windows
hooks:
pre: make migration-pack
post: make migration-clean
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

+ 6
- 6
Makefile

@ -3,8 +3,8 @@
# Project variables.
PACKAGE := github.com/hermeznetwork/hermez-node
VERSION := $(shell git describe --tags --always)
BUILD := $(shell git rev-parse --short HEAD)
BUILD_DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
PROJECT_NAME := $(shell basename "$(PWD)")
# Go related variables.
@ -23,7 +23,7 @@ CONFIG ?= $(GOBASE)/cli/node/cfg.buidler.toml
POSTGRES_PASS ?= yourpasswordhere
# Use linker flags to provide version/build settings.
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -X=main.Date=$(BUILD_DATE)"
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
# PID file will keep the process id of the server.
PID_PROOF_MOCK := /tmp/.$(PROJECT_NAME).proof.pid
@ -94,11 +94,11 @@ install:
@echo " > Checking if there is any missing dependencies..."
$(GOENVVARS) go get $(GOCMD)/... $(get)
## run: Run Hermez node.
run:
## run-node: Run Hermez node.
run-node:
@bash -c "$(MAKE) clean build"
@echo " > Running $(PROJECT_NAME)"
@$(GOBIN)/$(GOBINARY) --mode $(MODE) --cfg $(CONFIG) run
@$(GOBIN)/$(GOBINARY) run --mode $(MODE) --cfg $(CONFIG)
## run-proof-mock: Run proof server mock API.
run-proof-mock: stop-proof-mock

+ 2
- 2
README.md

@ -25,13 +25,13 @@ there are more information about the config file into [cli/node/README.md](cli/n
After setting the config, you can build and run the Hermez Node as a synchronizer:
```shell
$ make run
$ make run-node
```
Or build and run as a coordinator, and also passing the config file from other location:
```shell
$ MODE=sync CONFIG=cli/node/cfg.buidler.toml make run
$ MODE=sync CONFIG=cli/node/cfg.buidler.toml make run-node
```
To check the useful make commands:

+ 10
- 10
cli/node/main.go

@ -35,18 +35,18 @@ const (
)
var (
// Version represents the program based on the git tag
Version = "v0.1.0"
// Build represents the program based on the git commit
Build = "dev"
// Date represents the date of application was built
Date = ""
// version represents the program based on the git tag
version = "v0.1.0"
// commit represents the program based on the git commit
commit = "dev"
// date represents the date of application was built
date = ""
)
func cmdVersion(c *cli.Context) error {
fmt.Printf("Version = \"%v\"\n", Version)
fmt.Printf("Build = \"%v\"\n", Build)
fmt.Printf("Date = \"%v\"\n", Date)
fmt.Printf("Version = \"%v\"\n", version)
fmt.Printf("Build = \"%v\"\n", commit)
fmt.Printf("Date = \"%v\"\n", date)
return nil
}
@ -420,7 +420,7 @@ func getConfigAPIServer(c *cli.Context) (*ConfigAPIServer, error) {
func main() {
app := cli.NewApp()
app.Name = "hermez-node"
app.Version = Version
app.Version = version
flags := []cli.Flag{
&cli.StringFlag{
Name: flagMode,

Loading…
Cancel
Save