Skip to content

Commit 39a3889

Browse files
committed
add goreleaser
1 parent 27a56b7 commit 39a3889

File tree

9 files changed

+83
-58
lines changed

9 files changed

+83
-58
lines changed

.github/workflows/release.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: '1.16'
20+
- name: Run GoReleaser
21+
uses: goreleaser/goreleaser-action@v2
22+
with:
23+
version: latest
24+
args: release --rm-dist
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v2
1616
with:
17-
stable: 'true'
1817
go-version: '1.16'
1918
- name: Generate test coverage
2019
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
1616
bin
17+
dist/
1718
coverage.txt
1819
.multi/
1920
.DS_Store

.goreleaser.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This is an example .goreleaser.yml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
project_name: multiverse
4+
before:
5+
hooks:
6+
# You may remove this if you don't use go modules.
7+
- go mod download
8+
# you may remove this if you don't need go generate
9+
- go generate ./...
10+
builds:
11+
- main: ./cmd/multi/main.go
12+
id: "multi"
13+
binary: multi
14+
env:
15+
- CGO_ENABLED=0
16+
goos:
17+
- linux
18+
- windows
19+
- darwin
20+
archives:
21+
- replacements:
22+
darwin: darwin
23+
linux: linux
24+
windows: win32
25+
386: ia32
26+
amd64: x64
27+
checksum:
28+
name_template: 'checksums.txt'
29+
snapshot:
30+
name_template: "{{ .Tag }}"
31+
changelog:
32+
sort: asc
33+
filters:
34+
exclude:
35+
- '^docs:'
36+
- '^test:'

.multignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
dist/

Makefile

+2-39
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
GOCC = go
22

3-
.PHONY: multi install test multi-cross
4-
.PHONY: multi-darwin multi-darwin-386 multi-darwin-amd64
5-
.PHONY: multi-linux multi-linux-386 multi-linux-amd64
6-
.PHONY: multi-windows multi-windows-386 multi-windows-amd64
3+
.PHONY: all install test install-systemd
74

8-
all: multi
9-
10-
multi:
5+
all:
116
$(GOCC) build -o ./bin/multi ./cmd/multi
127

138
install:
@@ -19,35 +14,3 @@ install-systemd: install
1914

2015
test:
2116
$(GOCC) test ./... -cover
22-
23-
multi-cross: multi-darwin multi-linux multi-windows
24-
@echo "Full cross compilation done."
25-
26-
multi-darwin-amd64:
27-
GOOS=darwin GOARCH=amd64 $(GOCC) build -o ./bin/multi-darwin-amd64 ./cmd/multi
28-
@echo "Darwin amd64 cross compilation done."
29-
30-
multi-darwin: multi-darwin-amd64
31-
@echo "Darwin cross compilation done."
32-
33-
multi-linux-386:
34-
GOOS=linux GOARCH=386 $(GOCC) build -o ./bin/multi-linux-386 ./cmd/multi
35-
@echo "Linux 386 cross compilation done."
36-
37-
multi-linux-amd64:
38-
GOOS=linux GOARCH=amd64 $(GOCC) build -o ./bin/multi-linux-amd64 ./cmd/multi
39-
@echo "Linux amd64 cross compilation done."
40-
41-
multi-linux: multi-linux-386 multi-linux-amd64
42-
@echo "Linux cross compilation done."
43-
44-
multi-windows-386:
45-
GOOS=windows GOARCH=386 $(GOCC) build -o ./bin/multi-windows-386 ./cmd/multi
46-
@echo "Windows 386 cross compilation done."
47-
48-
multi-windows-amd64:
49-
GOOS=windows GOARCH=amd64 $(GOCC) build -o ./bin/multi-windows-amd64 ./cmd/multi
50-
@echo "Windows amd64 cross compilation done."
51-
52-
multi-windows: multi-windows-386 multi-windows-amd64
53-
@echo "Windows cross compilation done."

cmd/multi/main.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
package main
22

33
import (
4+
"os"
5+
"fmt"
6+
47
"github.com/multiverse-vcs/go-multiverse/pkg/command"
58
)
69

10+
// version is set by goreleaser
11+
var version = "dev"
12+
713
func main() {
8-
command.Execute()
14+
app := command.NewApp()
15+
app.Version = version
16+
17+
if err := app.Run(os.Args); err != nil {
18+
fmt.Fprintln(os.Stderr, err)
19+
}
920
}

internal/git/git_test.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,16 @@ package git
33
import (
44
"context"
55
"testing"
6-
"path/filepath"
76

87
"github.com/ipfs/go-merkledag/dagutils"
98
)
109

1110
func TestImportFromURL(t *testing.T) {
1211
ctx := context.Background()
1312
mem := dagutils.NewMemoryDagService()
13+
url := "https://github.com/multiverse-vcs/go-multiverse"
1414

15-
path, err := filepath.Abs("./../../")
16-
if err != nil {
17-
t.Fatal("failed to get absolute path")
18-
}
19-
20-
_, err = ImportFromFS(ctx, mem, "test", path)
15+
_, err := ImportFromURL(ctx, mem, "test", url)
2116
if err != nil {
2217
t.Fatal("failed to import git repo")
2318
}

pkg/command/command.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package command
22

33
import (
4-
"fmt"
5-
"os"
4+
"time"
65

76
"github.com/multiverse-vcs/go-multiverse/pkg/command/author"
87
"github.com/multiverse-vcs/go-multiverse/pkg/command/branch"
@@ -14,11 +13,11 @@ import (
1413
// NewApp returns a new cli app.
1514
func NewApp() *cli.App {
1615
return &cli.App{
16+
Compiled: time.Now(),
1717
Name: "multi",
1818
HelpName: "multi",
1919
Usage: "Multiverse command line interface",
2020
Description: `Multiverse is a decentralized version control system for peer-to-peer software development.`,
21-
Version: "0.0.5",
2221
Authors: []*cli.Author{
2322
{Name: "Keenan Nemetz", Email: "[email protected]"},
2423
},
@@ -39,10 +38,3 @@ func NewApp() *cli.App {
3938
},
4039
}
4140
}
42-
43-
// Execute runs the cli app.
44-
func Execute() {
45-
if err := NewApp().Run(os.Args); err != nil {
46-
fmt.Fprintln(os.Stderr, err)
47-
}
48-
}

0 commit comments

Comments
 (0)