diff --git a/.drone.yml b/.drone.yml index 4dca524..c163138 100644 --- a/.drone.yml +++ b/.drone.yml @@ -44,18 +44,14 @@ pipeline: environment: GOPATH: /go commands: - - go get -u golang.org/x/lint/golint - - golint -set_exit_status $(go list ./...) - - go vet ./... - - go test -cover ./... + - make test static: image: golang:1.10 pull: true environment: GOPATH: /go commands: - - go get -u github.com/mitchellh/gox - - gox -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -output "releases/gitea-github-migrator_{{.OS}}_{{.Arch}}" + - make release when: event: [ tag ] clean: @@ -76,4 +72,13 @@ pipeline: - sha256 - md5 when: - event: [ tag ] \ No newline at end of file + event: [ tag ] + docker: + image: plugins/docker:17.12 + secrets: [ docker_username, docker_password ] + pull: true + repo: jonasfranz/gitea-github-migrator + default_tags: true + when: + event: [ push, tag ] + branch: [ master ] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..75344ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +#Build stage +FROM golang:1.10-alpine3.7 AS build-env + +#Build deps +RUN apk --no-cache add build-base git + +#Setup repo +COPY . ${GOPATH}/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator +WORKDIR ${GOPATH}/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator + +RUN make docker-binary + +FROM alpine:3.7 +LABEL maintainer="info@jonasfranz.software" + +COPY --from=build-env /go/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/gitea-github-migrator /usr/local/bin/gitea-github-migrator + +ENTRYPOINT ["/usr/local/bin/gitea-github-migrator"] diff --git a/Gopkg.toml b/Gopkg.toml index bb32991..1b60a8d 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,30 +1,3 @@ -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - [prune] go-tests = true unused-packages = true diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e4d5b86 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +IMPORT := git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator +GO ?= go + +BUILD=$(or ${DRONE_BUILD_NUMBER},${DRONE_BUILD_NUMBER},0) + +ifneq ($(DRONE_TAG),) + VERSION ?= $(subst v,,$(DRONE_TAG)) +else + ifneq ($(DRONE_BRANCH),) + VERSION ?= $(subst release/v,,$(DRONE_BRANCH)) + else + VERSION ?= master + endif +endif + +LDFLAGS := -X main.Version=$(VERSION) -X main.build=$(BUILD) + +.PHONY: all +all: + +.PHONY: docker-binary +docker-binary: + go build -ldflags "$(LDFLAGS)" -o gitea-github-migrator + +.PHONY: release +release: + @hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GO) get -u github.com/mitchellh/gox; \ + fi + gox -ldflags "$(LDFLAGS)" -output "releases/gitea-github-migrator_{{.OS}}_{{.Arch}}" + +.PHONY: lint +lint: + @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GO) get -u golang.org/x/lint/golint; \ + fi + golint -set_exit_status $(go list ./...) + +.PHONY: vet +vet: + go vet ./... + +.PHONY: test +test: lint vet + go test -cover ./... + \ No newline at end of file diff --git a/README.md b/README.md index 2f98ec5..85b3cda 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # gitea-github-migrator [![Build Status](https://drone.jonasfranz.software/api/badges/JonasFranzDEV/gitea-github-migrator/status.svg)](https://drone.jonasfranz.software/JonasFranzDEV/gitea-github-migrator) +[![Latest Release](https://img.shields.io/badge/dynamic/json.svg?label=release&url=https%3A%2F%2Fgit.jonasfranz.software%2Fapi%2Fv1%2Frepos%2FJonasFranzDEV%2Fgitea-github-migrator%2Freleases&query=%24%5B0%5D.tag_name)](https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/releases) +[![Docker Pulls](https://img.shields.io/docker/pulls/jonasfranz/gitea-github-migrator.svg)](https://hub.docker.com/r/jonasfranz/gitea-github-migrator/) A tool to migrate [GitHub](https://github.com) Repositories to [Gitea](https://gitea.io) including all issues, labels, milestones and comments.