diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b7ed819 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7da6ce..525359d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 ./... diff --git a/.gitignore b/.gitignore index 339359b..2cd523b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ # Dependency directories (remove the comment below to include it) # vendor/ bin +dist/ coverage.txt .multi/ .DS_Store diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..17a83f6 --- /dev/null +++ b/.goreleaser.yml @@ -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:' diff --git a/.multignore b/.multignore new file mode 100644 index 0000000..c3c5eb9 --- /dev/null +++ b/.multignore @@ -0,0 +1,2 @@ +.DS_Store +dist/ \ No newline at end of file diff --git a/Makefile b/Makefile index d991690..ec68b3b 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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." diff --git a/cmd/multi/main.go b/cmd/multi/main.go index 588c702..75fe6e7 100644 --- a/cmd/multi/main.go +++ b/cmd/multi/main.go @@ -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) + } } diff --git a/internal/git/git_test.go b/internal/git/git_test.go index e6e8278..b4adffb 100644 --- a/internal/git/git_test.go +++ b/internal/git/git_test.go @@ -3,7 +3,6 @@ package git import ( "context" "testing" - "path/filepath" "github.com/ipfs/go-merkledag/dagutils" ) @@ -11,13 +10,9 @@ import ( 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") } diff --git a/pkg/command/command.go b/pkg/command/command.go index 595a08a..582f815 100644 --- a/pkg/command/command.go +++ b/pkg/command/command.go @@ -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" @@ -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: "keenan.nemetz@pm.me"}, }, @@ -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) - } -}