diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e44f09..0c6893c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,16 +5,20 @@ jobs: build: name: build and test runs-on: ubuntu-latest + env: + BUILDER_NAME: "GitHub Actions" + BUILDER_EMAIL: noreply@actions.github.com + steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 + - name: Set up Go 1.17 + uses: actions/setup-go@v2 with: - go-version: 1.13 + go-version: 1.17 id: go - name: Check out code - uses: actions/checkout@master + uses: actions/checkout@v2 with: fetch-depth: 1 @@ -24,26 +28,8 @@ jobs: sudo dpkg -i pandoc-2.7.3-1-amd64.deb - name: build and run unit tests - run: BUILDER_NAME=CI BUILDER_EMAIL=ci@test.only make clean all test + run: make clean all test - name: Run checkmake on Makefile run: ./checkmake Makefile - docker: - needs: build - name: docker image build and release - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Build the Docker image - run: docker build --build-arg BUILDER_NAME=CI --build-arg BUILDER_EMAIL=ci@test.only . --file Dockerfile --tag mrtazz/checkmake:${GITHUB_SHA} --tag mrtazz/checkmake:latest - - - name: push the docker image to docker hub - if: github.ref == 'refs/heads/main' - run: | - echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u mrtazz --password-stdin - docker push mrtazz/checkmake:${GITHUB_SHA} - docker push mrtazz/checkmake:latest - docker logout hub.docker.com diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 4e03680..a63d2a9 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -1,4 +1,4 @@ -name: packages +name: release on: push: tags: @@ -6,22 +6,22 @@ on: jobs: packages: - name: build and deploy + name: packagecloud runs-on: ubuntu-latest env: - BUILDER_NAME: CI - BUILDER_EMAIL: ci@actions.github.com + BUILDER_NAME: "GitHub Actions" + BUILDER_EMAIL: noreply@actions.github.com steps: - name: Set up Go 1.13 - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.13 id: go - name: Check out code - uses: actions/checkout@master + uses: actions/checkout@v2 with: fetch-depth: 1 @@ -40,7 +40,59 @@ jobs: env: PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} + release: + name: github + runs-on: ubuntu-latest + env: + BUILDER_NAME: "GitHub Actions" + BUILDER_EMAIL: noreply@actions.github.com + + steps: + + - name: Set up Go 1.17 + uses: actions/setup-go@v2 + with: + go-version: 1.17 + id: go + + - name: Check out code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: install dependencies + run: | + sudo wget https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-1-amd64.deb + sudo dpkg -i pandoc-2.7.3-1-amd64.deb + + - name: build for platforms + run: | + BUILD_GOARCH=amd64 BUILD_GOOS=freebsd make build-standalone + BUILD_GOARCH=amd64 BUILD_GOOS=linux make build-standalone + BUILD_GOARCH=amd64 BUILD_GOOS=darwin make build-standalone + - name: create release run: make github-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + docker: + name: docker + env: + BUILDER_NAME: "GitHub Actions" + BUILDER_EMAIL: noreply@actions.github.com + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Build the Docker image + run: docker build --build-arg BUILDER_NAME=CI --build-arg BUILDER_EMAIL=ci@test.only . --file Dockerfile --tag mrtazz/checkmake:${GITHUB_SHA} --tag mrtazz/checkmake:latest + + - name: push the docker image to docker hub + if: github.ref == 'refs/heads/main' + run: | + echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u mrtazz --password-stdin + docker push mrtazz/checkmake:${GITHUB_SHA} + docker push mrtazz/checkmake:latest + docker logout hub.docker.com diff --git a/.gitignore b/.gitignore index 071a31f..0e6ac9c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ profile.out *.rpm *.deb .idea/ +.release_artifacts/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b28d60b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -sudo: false -language: go -go: -- tip -addons: - apt: - packages: - - rpm - - pandoc -before_install: -- gem install fpm -- gem install package_cloud -- go get github.com/axw/gocov/gocov -- go get github.com/mattn/goveralls -- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi -script: -- make clean all test -- ./checkmake Makefile -after_success: - - make coverage && $HOME/gopath/bin/goveralls -coverprofile=cover.out -service=travis-ci -deploy: - provider: script - script: make deploy-packages - skip_cleanup: true - on: - tags: true -env: - global: - - secure: STk08ygMm5ua4iCaPYa5VR9W/H1NMzi0w170jSzCCu/bpHuOsGK56N+9h+U9sJJ49bhF+mGbjDicY0I4oJwSIpxBzY9ATycsAgagUUD1V7QRfapISHzPs3PfHmfbGwm0fkrdNcSUBKxt5sZm2gCZYkP4ToTGMVL6p9TF1CO/Q7rdO9NrOwO5adcv5f6BOBGOGOW9KFsfYOpvO2fHw2SSw0lYpQDZlczpWg5bh++zWWsIzW1JM9IQcROXetccIE2+5uyX1Lz+rrBbfhFiiB+inkUm0t8DMXc3augveWfcgdbg/55isZxTwdiFc5YD/kQ84Cr4/HzC/Ol6gozfOL5+yrtTd3xc3Lxk/u+CLzc/zMPiQY/sRoTUa9MkiMCsTQSjvPGXwm7MiW/Ly4/boG5BoSxMGVjQlVe7P1GrJE2yqELLZSkZUO5cYy37jx4kc0aLAc+j0VTNdcZ5Fi3vAAmv3nKxOirB/r8Pp/r8MJRtbCBJ+0s9G+tuSXiP/2zzVjUHaup0b3ZjbTEzaEiqX95V6b7Iqj2xmdD7odbVhghnLPe0iVG3hmP8ZbOKz+aMwOXlcyUnji5UpDuWFqT/459zVJxhKn/lwIfpnI4pNDr1Jb23nEGI9VE7LrBeCv/65gJ8tyKqd3fMtV6ze+8cFHXnOeFtAvU5FE3ZHI2+0mTG0N8= diff --git a/Makefile b/Makefile index 19d8fd3..e792990 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ # some housekeeping tasks # -export GO15VENDOREXPERIMENT = 1 export GO111MODULE = on export GOFLAGS = -mod=vendor @@ -15,6 +14,15 @@ GOVERSION := $(shell go version) BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") BUILDDATE := $(shell date -u +"%B %d, %Y") +BUILD_GOOS ?= $(shell go env GOOS) +BUILD_GOARCH ?= $(shell go env GOARCH) + +RELEASE_ARTIFACTS_DIR := .release_artifacts +CHECKSUM_FILE := checksums.txt + +$(RELEASE_ARTIFACTS_DIR): + install -d $@ + BUILDER_NAME := $(if $(BUILDER_NAME),$(BUILDER_NAME),$(shell git config user.name)) ifndef BUILDER_NAME $(error "You must set environment variable BUILDER_NAME or set a user.name in your git configuration.") @@ -25,7 +33,7 @@ ifndef EMAIL $(error "You must set environment variable BUILDER_EMAIL or set a user.email in your git configuration.") endif -BUILDER := $(shell echo "${NAME} <${EMAIL}>") +BUILDER := $(shell echo "${BUILDER_NAME} <${EMAIL}>") PKG_RELEASE ?= 1 PROJECT_URL := "https://github.com/mrtazz/$(NAME)" @@ -46,7 +54,7 @@ INSTALLED_TARGETS = $(addprefix $(PREFIX)/bin/, $(TARGETS)) INSTALLED_MAN_TARGETS = $(addprefix $(PREFIX)/share/man/man1/, $(MAN_TARGETS)) %: cmd/%/main.go - go build -ldflags "$(LDFLAGS)" -o $@ $< + GOOS=$(BUILD_GOOS) GOARCH=$(BUILD_GOARCH) go build -ldflags "$(LDFLAGS)" -o $@ $< %.1: man/man1/%.1.md sed "s/REPLACE_DATE/$(BUILDDATE)/" $< | pandoc -s -t man -o $@ @@ -129,10 +137,15 @@ deb: $(SOURCES) --vendor mrtazz \ usr +.PHONY: build-standalone +build-standalone: all $(RELEASE_ARTIFACTS_DIR) + mv checkmake.1 $(RELEASE_ARTIFACTS_DIR) + mv checkmake $(RELEASE_ARTIFACTS_DIR)/checkmake-$(VERSION).$(BUILD_GOOS).$(BUILD_GOARCH) + cd $(RELEASE_ARTIFACTS_DIR) && shasum -a 256 checkmake-$(VERSION).$(BUILD_GOOS).$(BUILD_GOARCH) >> $(CHECKSUM_FILE) + .PHONY: github-release github-release: - gh release create $(VERSION) --title 'Release $(VERSION)' --notes-file docs/releases/$(VERSION).md $(NAME)_$(VERSION)-$(PKG_RELEASE)_amd64.deb $(NAME)-$(VERSION)-$(PKG_RELEASE).x86_64.rpm - + gh release create $(VERSION) --title 'Release $(VERSION)' --notes-file docs/releases/$(VERSION).md $(RELEASE_ARTIFACTS_DIR)/* # clean up tasks diff --git a/README.md b/README.md index 339f8c5..5daa02e 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ There are packages for linux up [on packagecloud.io](https://packagecloud.io/mrt To build checkmake you will need to have [golang](https://golang.org/) installed. Once you have Go installed, you can simply clone the repo and build the binary and man page yourself with the following commands. ```sh -go get github.com/mrtazz/checkmake -cd "$GOPATH"/src/github.com/mrtazz/checkmake +git clone https://github.com/mrtazz/checkmake +cd checkmake make ``` diff --git a/go.mod b/go.mod index a738af0..b36ebfd 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,16 @@ module github.com/mrtazz/checkmake -go 1.13 +go 1.17 require ( - github.com/davecgh/go-spew v1.1.1 // indirect github.com/docopt/docopt-go v0.0.0-20141128170934-854c423c8108 github.com/go-ini/ini v1.11.0 github.com/olekukonko/tablewriter v0.0.0-20150822215231-b9346ac189c5 - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/testify v1.1.4-0.20160615092844-d77da356e56a ) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/smartystreets/goconvey v1.7.2 // indirect +) diff --git a/go.sum b/go.sum index 0e06da2..612b731 100644 --- a/go.sum +++ b/go.sum @@ -4,9 +4,22 @@ github.com/docopt/docopt-go v0.0.0-20141128170934-854c423c8108 h1:WJse1njqIlgvQj github.com/docopt/docopt-go v0.0.0-20141128170934-854c423c8108/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/go-ini/ini v1.11.0 h1:EDp2zFK6TR11mvDrWDask1bXLBUgqbIqG4R6Lq3EoKI= github.com/go-ini/ini v1.11.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/olekukonko/tablewriter v0.0.0-20150822215231-b9346ac189c5 h1:ZxRrPRTX45eVRfhXfZUgH1MG173pWRdOMFsnJoTaxwU= github.com/olekukonko/tablewriter v0.0.0-20150822215231-b9346ac189c5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= +github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= +github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= +github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= github.com/stretchr/testify v1.1.4-0.20160615092844-d77da356e56a h1:UWu0XgfW9PCuyeZYNe2eGGkDZjooQKjVQqY/+d/jYmc= github.com/stretchr/testify v1.1.4-0.20160615092844-d77da356e56a/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= diff --git a/vendor/modules.txt b/vendor/modules.txt index 675c0d9..0b5276a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,13 +1,21 @@ # github.com/davecgh/go-spew v1.1.1 +## explicit github.com/davecgh/go-spew/spew # github.com/docopt/docopt-go v0.0.0-20141128170934-854c423c8108 +## explicit github.com/docopt/docopt-go # github.com/go-ini/ini v1.11.0 +## explicit github.com/go-ini/ini # github.com/olekukonko/tablewriter v0.0.0-20150822215231-b9346ac189c5 +## explicit github.com/olekukonko/tablewriter # github.com/pmezard/go-difflib v1.0.0 +## explicit github.com/pmezard/go-difflib/difflib +# github.com/smartystreets/goconvey v1.7.2 +## explicit; go 1.16 # github.com/stretchr/testify v1.1.4-0.20160615092844-d77da356e56a +## explicit github.com/stretchr/testify/assert github.com/stretchr/testify/require