Skip to content

Commit

Permalink
fix: refactor versioning (go ldflags)
Browse files Browse the repository at this point in the history
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
  • Loading branch information
moul committed Sep 17, 2020
1 parent df1f980 commit d85bd40
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 43 deletions.
17 changes: 1 addition & 16 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ builds:
#- darwin
#- windows
goarch:
#- 386
- amd64
#- arm
#- arm64
dir: go/cmd/berty
ignore:
-
Expand All @@ -25,7 +22,7 @@ builds:
flags:
- "-a"
ldflags:
- '-extldflags "-static" -X berty.tech/berty/v2/go/pkg/bertymessenger.VcsRef=$(VCS_REF) -X berty.tech/berty/v2/go/pkg/bertymessenger.Version=$(VERSION) -X berty.tech/berty/v2/go/pkg/bertymessenger.BuildTime=$(BUILD_DATE)'
- '-extldflags "-static" -X berty.tech/berty/v2/go/pkg/bertyversion.VcsRef=$(VCS_REF) -X berty.tech/berty/v2/go/pkg/bertyversion.Version=$(VERSION)'
checksum:
name_template: '{{.ProjectName}}_checksums.txt'
changelog:
Expand All @@ -50,15 +47,3 @@ archives:
goos: windows
format: zip
wrap_in_directory: true
# generate .deb and .rpm (disabled for now)
#nfpms:
# -
# file_name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
# homepage: https://github.com/berty/berty
# description: "berty"
# maintainer: "Berty Technologies <https://berty.tech>"
# license: "Apache-2.0 OR MIT"
# vendor: berty
# formats:
# - deb
# - rpm
2 changes: 2 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GO_TEST_PATH ?= ./...
BUILD_DATE ?= `date +%s`
VCS_REF ?= `git rev-parse --short HEAD`
VERSION ?= `git describe --tags --always`
LDFLAGS ?= -ldflags="-X berty.tech/berty/v2/go/pkg/bertymessenger.VcsRef=$(VCS_REF) -X berty.tech/berty/v2/go/pkg/bertymessenger.Version=$(VERSION)"
LDFLAGS ?= -ldflags="-X berty.tech/berty/v2/go/pkg/bertyversion.VcsRef=$(VCS_REF) -X berty.tech/berty/v2/go/pkg/bertyversion.Version=$(VERSION)"


##
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/berty/depaware.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ berty.tech/berty/v2/go/cmd/berty dependencies: (generated by github.com/tailscal
berty.tech/berty/v2/go/internal/handshake from berty.tech/berty/v2/go/pkg/bertyprotocol
berty.tech/berty/v2/go/internal/initutil from berty.tech/berty/v2/go/cmd/berty
berty.tech/berty/v2/go/internal/ipfsutil from berty.tech/berty/v2/go/internal/initutil+
berty.tech/berty/v2/go/internal/lifecycle from berty.tech/berty/v2/go/cmd/berty/mini+
berty.tech/berty/v2/go/internal/logutil from berty.tech/berty/v2/go/internal/initutil
berty.tech/berty/v2/go/internal/multipeer-connectivity-transport from berty.tech/berty/v2/go/internal/config+
berty.tech/berty/v2/go/internal/multipeer-connectivity-transport/driver from berty.tech/berty/v2/go/internal/multipeer-connectivity-transport
Expand All @@ -23,6 +24,7 @@ berty.tech/berty/v2/go/cmd/berty dependencies: (generated by github.com/tailscal
berty.tech/berty/v2/go/pkg/bertymessenger from berty.tech/berty/v2/go/cmd/berty+
berty.tech/berty/v2/go/pkg/bertyprotocol from berty.tech/berty/v2/go/cmd/berty+
berty.tech/berty/v2/go/pkg/bertytypes from berty.tech/berty/v2/go/cmd/berty+
berty.tech/berty/v2/go/pkg/bertyversion from berty.tech/berty/v2/go/cmd/berty+
berty.tech/berty/v2/go/pkg/errcode from berty.tech/berty/v2/go/cmd/berty+
berty.tech/go-ipfs-log from berty.tech/berty/v2/go/pkg/bertyprotocol+
berty.tech/go-ipfs-log/accesscontroller from berty.tech/berty/v2/go/pkg/bertyprotocol+
Expand Down
1 change: 0 additions & 1 deletion go/cmd/berty/mini/view_group_outgoing.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ func debugSystemCommand(ctx context.Context, v *groupView, _ string) error {
"Arch ": config.Arch,
"Version ": config.Version,
"VcsRef ": config.VcsRef,
"BuildTime ": config.BuildTime,
} {
v.messages.Append(&historyMessage{
messageType: messageTypeMeta,
Expand Down
10 changes: 5 additions & 5 deletions go/cmd/berty/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"runtime"

"berty.tech/berty/v2/go/pkg/bertymessenger"
"berty.tech/berty/v2/go/pkg/bertyversion"
"github.com/peterbourgon/ff/v3/ffcli"
)

Expand All @@ -14,11 +14,11 @@ func versionCommand() *ffcli.Command {
Name: "version",
ShortHelp: "print software version",
Exec: func(_ context.Context, _ []string) error {
fmt.Printf("git version %s\n", bertymessenger.Version)
if bertymessenger.VcsRef != "n/a" {
fmt.Printf("vcs https://github.com/berty/berty/commits/%s\n", bertymessenger.VcsRef)
fmt.Printf("version %s\n", bertyversion.Version)
if bertyversion.VcsRef != "n/a" {
fmt.Printf("vcs https://github.com/berty/berty/commits/%s\n", bertyversion.VcsRef)
}
fmt.Printf("go %s\n", runtime.Version())
fmt.Printf("go %s\n", runtime.Version())
return nil
},
}
Expand Down
4 changes: 3 additions & 1 deletion go/cmd/betabot/depaware.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ berty.tech/berty/v2/go/cmd/betabot dependencies: (generated by github.com/tailsc
berty.tech/berty/v2/go/internal/grpcutil from berty.tech/berty/v2/go/pkg/bertyprotocol
berty.tech/berty/v2/go/internal/handshake from berty.tech/berty/v2/go/pkg/bertyprotocol
berty.tech/berty/v2/go/internal/ipfsutil from berty.tech/berty/v2/go/pkg/bertyprotocol
berty.tech/berty/v2/go/internal/lifecycle from berty.tech/berty/v2/go/pkg/bertymessenger
berty.tech/berty/v2/go/internal/multipeer-connectivity-transport from berty.tech/berty/v2/go/internal/config
berty.tech/berty/v2/go/internal/multipeer-connectivity-transport/driver from berty.tech/berty/v2/go/internal/multipeer-connectivity-transport
D 💣 berty.tech/berty/v2/go/internal/multipeer-connectivity-transport/driver/mc-driver from berty.tech/berty/v2/go/internal/multipeer-connectivity-transport/driver
Expand All @@ -19,6 +20,7 @@ berty.tech/berty/v2/go/cmd/betabot dependencies: (generated by github.com/tailsc
berty.tech/berty/v2/go/pkg/bertymessenger from berty.tech/berty/v2/go/cmd/betabot
berty.tech/berty/v2/go/pkg/bertyprotocol from berty.tech/berty/v2/go/pkg/bertymessenger
berty.tech/berty/v2/go/pkg/bertytypes from berty.tech/berty/v2/go/internal/tracer+
berty.tech/berty/v2/go/pkg/bertyversion from berty.tech/berty/v2/go/pkg/bertymessenger+
berty.tech/berty/v2/go/pkg/errcode from berty.tech/berty/v2/go/internal/cryptoutil+
berty.tech/go-ipfs-log from berty.tech/berty/v2/go/pkg/bertyprotocol+
berty.tech/go-ipfs-log/accesscontroller from berty.tech/berty/v2/go/pkg/bertyprotocol+
Expand Down Expand Up @@ -792,7 +794,7 @@ berty.tech/berty/v2/go/cmd/betabot dependencies: (generated by github.com/tailsc
encoding from encoding/json+
encoding/asn1 from crypto/ecdsa+
encoding/base32 from github.com/ipfs/go-ipfs-cmds/http+
encoding/base64 from berty.tech/berty/v2/go/cmd/betabot+
encoding/base64 from berty.tech/berty/v2/go/internal/discordlog+
encoding/binary from archive/zip+
encoding/csv from github.com/gabriel-vasile/mimetype/internal/matchers
encoding/hex from berty.tech/berty/v2/go/pkg/bertyprotocol+
Expand Down
2 changes: 2 additions & 0 deletions go/framework/bertybridge/depaware.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ berty.tech/berty/v2/go/framework/bertybridge dependencies: (generated by github.
berty.tech/berty/v2/go/internal/grpcutil from berty.tech/berty/v2/go/framework/bertybridge+
berty.tech/berty/v2/go/internal/handshake from berty.tech/berty/v2/go/pkg/bertyprotocol
berty.tech/berty/v2/go/internal/ipfsutil from berty.tech/berty/v2/go/framework/bertybridge+
berty.tech/berty/v2/go/internal/lifecycle from berty.tech/berty/v2/go/framework/bertybridge+
berty.tech/berty/v2/go/internal/logutil from berty.tech/berty/v2/go/framework/bertybridge
berty.tech/berty/v2/go/internal/multipeer-connectivity-transport from berty.tech/berty/v2/go/framework/bertybridge+
berty.tech/berty/v2/go/internal/multipeer-connectivity-transport/driver from berty.tech/berty/v2/go/internal/multipeer-connectivity-transport
Expand All @@ -21,6 +22,7 @@ berty.tech/berty/v2/go/framework/bertybridge dependencies: (generated by github.
berty.tech/berty/v2/go/pkg/bertymessenger from berty.tech/berty/v2/go/framework/bertybridge
berty.tech/berty/v2/go/pkg/bertyprotocol from berty.tech/berty/v2/go/framework/bertybridge+
berty.tech/berty/v2/go/pkg/bertytypes from berty.tech/berty/v2/go/internal/tracer+
berty.tech/berty/v2/go/pkg/bertyversion from berty.tech/berty/v2/go/pkg/bertymessenger+
berty.tech/berty/v2/go/pkg/errcode from berty.tech/berty/v2/go/framework/bertybridge+
berty.tech/go-ipfs-log from berty.tech/berty/v2/go/pkg/bertyprotocol+
berty.tech/go-ipfs-log/accesscontroller from berty.tech/berty/v2/go/pkg/bertyprotocol+
Expand Down
2 changes: 1 addition & 1 deletion go/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/pkg/bertymessenger/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"berty.tech/berty/v2/go/internal/discordlog"
"berty.tech/berty/v2/go/pkg/bertytypes"
"berty.tech/berty/v2/go/pkg/bertyversion"
"berty.tech/berty/v2/go/pkg/errcode"
"github.com/gogo/protobuf/proto"
"go.uber.org/zap"
Expand Down Expand Up @@ -336,8 +337,8 @@ func (svc *service) SystemInfo(ctx context.Context, req *SystemInfo_Request) (*S
NumGoroutine: int64(runtime.NumGoroutine()),
OperatingSystem: runtime.GOOS,
Arch: runtime.GOARCH,
Version: Version,
VcsRef: VcsRef,
Version: bertyversion.Version,
VcsRef: bertyversion.VcsRef,
RlimitMax: rlimitNofile.Max,
}
if BuildTime != "n/a" {
Expand Down
3 changes: 2 additions & 1 deletion go/pkg/bertymessenger/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"berty.tech/berty/v2/go/internal/notification"
"berty.tech/berty/v2/go/pkg/bertyprotocol"
"berty.tech/berty/v2/go/pkg/bertytypes"
"berty.tech/berty/v2/go/pkg/bertyversion"
"berty.tech/berty/v2/go/pkg/errcode"

"github.com/golang/protobuf/proto" // nolint:staticcheck: not sure how to use the new protobuf api to unmarshal
"go.uber.org/zap"
"gorm.io/driver/sqlite"
Expand Down Expand Up @@ -87,6 +87,7 @@ func New(client bertyprotocol.ProtocolServiceClient, opts *Opts) (Service, error
return nil, errcode.TODO.Wrap(err)
}
opts.Logger = opts.Logger.Named("msg")
opts.Logger.Debug("initializing messenger", zap.String("version", bertyversion.Version))

if err := initDB(opts.DB); err != nil {
return nil, errcode.TODO.Wrap(err)
Expand Down
7 changes: 0 additions & 7 deletions go/pkg/bertymessenger/version.go

This file was deleted.

12 changes: 6 additions & 6 deletions go/pkg/bertyprotocol/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import (
"sync/atomic"
"time"

"berty.tech/go-orbit-db/baseorbitdb"
"berty.tech/go-orbit-db/pubsub/directchannel"
datastore "github.com/ipfs/go-datastore"
ds_sync "github.com/ipfs/go-datastore/sync"

"berty.tech/berty/v2/go/internal/ipfsutil"
"berty.tech/berty/v2/go/internal/tinder"
"berty.tech/berty/v2/go/pkg/bertytypes"
"berty.tech/berty/v2/go/pkg/bertyversion"
"berty.tech/berty/v2/go/pkg/errcode"

"berty.tech/go-orbit-db/baseorbitdb"
"berty.tech/go-orbit-db/pubsub/directchannel"
datastore "github.com/ipfs/go-datastore"
ds_sync "github.com/ipfs/go-datastore/sync"
ipfs_core "github.com/ipfs/go-ipfs/core"
ipfs_interface "github.com/ipfs/interface-go-ipfs-core"
"github.com/libp2p/go-libp2p-core/host"
Expand Down Expand Up @@ -154,6 +153,7 @@ func New(ctx context.Context, opts Opts) (Service, error) {
return nil, errcode.TODO.Wrap(err)
}
opts.Logger = opts.Logger.Named("pt")
opts.Logger.Debug("initializing protocol", zap.String("version", bertyversion.Version))

acc, err := opts.OrbitDB.openAccountGroup(ctx, nil)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions go/pkg/bertyversion/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package bertyversion

var (
Version = "n/a"
VcsRef = "n/a"
)
2 changes: 1 addition & 1 deletion js/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subs
check-program = $(foreach exec,$(1),$(if $(shell PATH="$(PATH)" which $(exec)),,$(error "Missing deps: no '$(exec)' in PATH")))
export PATH := $(PWD)/node_modules/.bin:$(PATH)
author = Berty Technologies <oss@berty.tech>
ext_ldflags = -ldflags="-X berty.tech/berty/go/pkg/bertymessenger.VcsRef=$(VCS_REF) -X berty.tech/berty/go/pkg/bertymessenger.Version=$(VERSION) -X berty.tech/berty/go/pkg/bertymessenger.BuildTime=$(BUILD_DATE)"
ext_ldflags = -ldflags="-X berty.tech/berty/go/pkg/bertyversion.VcsRef=$(VCS_REF) -X berty.tech/berty/go/pkg/bertyversion.Version=$(VERSION)"
pkg := $(dir $(wildcard $(PWD)/packages/*/package.json))
pkg_mod := $(patsubst %, %/node_modules, $(pkg)) node_modules
pkg_desc := $(patsubst %, %/package.json, $(pkg)) package.json
Expand Down
2 changes: 1 addition & 1 deletion js/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d85bd40

Please sign in to comment.