Skip to content

Commit

Permalink
add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Mar 4, 2021
1 parent 27a56b7 commit 39a3889
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 58 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release

on:
push:
tags:
- '*'

jobs:
release:
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 }}
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
stable: 'true'
go-version: '1.16'
- name: Generate test coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Dependency directories (remove the comment below to include it)
# vendor/
bin
dist/
coverage.txt
.multi/
.DS_Store
36 changes: 36 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: multiverse
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
builds:
- main: ./cmd/multi/main.go
id: "multi"
binary: multi
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- replacements:
darwin: darwin
linux: linux
windows: win32
386: ia32
amd64: x64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
2 changes: 2 additions & 0 deletions .multignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
dist/
41 changes: 2 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
GOCC = go

.PHONY: multi install test multi-cross
.PHONY: multi-darwin multi-darwin-386 multi-darwin-amd64
.PHONY: multi-linux multi-linux-386 multi-linux-amd64
.PHONY: multi-windows multi-windows-386 multi-windows-amd64
.PHONY: all install test install-systemd

all: multi

multi:
all:
$(GOCC) build -o ./bin/multi ./cmd/multi

install:
Expand All @@ -19,35 +14,3 @@ install-systemd: install

test:
$(GOCC) test ./... -cover

multi-cross: multi-darwin multi-linux multi-windows
@echo "Full cross compilation done."

multi-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(GOCC) build -o ./bin/multi-darwin-amd64 ./cmd/multi
@echo "Darwin amd64 cross compilation done."

multi-darwin: multi-darwin-amd64
@echo "Darwin cross compilation done."

multi-linux-386:
GOOS=linux GOARCH=386 $(GOCC) build -o ./bin/multi-linux-386 ./cmd/multi
@echo "Linux 386 cross compilation done."

multi-linux-amd64:
GOOS=linux GOARCH=amd64 $(GOCC) build -o ./bin/multi-linux-amd64 ./cmd/multi
@echo "Linux amd64 cross compilation done."

multi-linux: multi-linux-386 multi-linux-amd64
@echo "Linux cross compilation done."

multi-windows-386:
GOOS=windows GOARCH=386 $(GOCC) build -o ./bin/multi-windows-386 ./cmd/multi
@echo "Windows 386 cross compilation done."

multi-windows-amd64:
GOOS=windows GOARCH=amd64 $(GOCC) build -o ./bin/multi-windows-amd64 ./cmd/multi
@echo "Windows amd64 cross compilation done."

multi-windows: multi-windows-386 multi-windows-amd64
@echo "Windows cross compilation done."
13 changes: 12 additions & 1 deletion cmd/multi/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package main

import (
"os"
"fmt"

"github.com/multiverse-vcs/go-multiverse/pkg/command"
)

// version is set by goreleaser
var version = "dev"

func main() {
command.Execute()
app := command.NewApp()
app.Version = version

if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
9 changes: 2 additions & 7 deletions internal/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ package git
import (
"context"
"testing"
"path/filepath"

"github.com/ipfs/go-merkledag/dagutils"
)

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

path, err := filepath.Abs("./../../")
if err != nil {
t.Fatal("failed to get absolute path")
}

_, err = ImportFromFS(ctx, mem, "test", path)
_, err := ImportFromURL(ctx, mem, "test", url)
if err != nil {
t.Fatal("failed to import git repo")
}
Expand Down
12 changes: 2 additions & 10 deletions pkg/command/command.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package command

import (
"fmt"
"os"
"time"

"github.com/multiverse-vcs/go-multiverse/pkg/command/author"
"github.com/multiverse-vcs/go-multiverse/pkg/command/branch"
Expand All @@ -14,11 +13,11 @@ import (
// NewApp returns a new cli app.
func NewApp() *cli.App {
return &cli.App{
Compiled: time.Now(),
Name: "multi",
HelpName: "multi",
Usage: "Multiverse command line interface",
Description: `Multiverse is a decentralized version control system for peer-to-peer software development.`,
Version: "0.0.5",
Authors: []*cli.Author{
{Name: "Keenan Nemetz", Email: "[email protected]"},
},
Expand All @@ -39,10 +38,3 @@ func NewApp() *cli.App {
},
}
}

// Execute runs the cli app.
func Execute() {
if err := NewApp().Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}

0 comments on commit 39a3889

Please sign in to comment.