diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..84e4289 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,66 @@ +--- +name: CD +on: + push: + tags: + - "v*" +jobs: + release: + name: Release + timeout-minutes: 5 + strategy: + matrix: + os: ["ubuntu-latest"] + go-ver: ["1.13"] + runs-on: ${{ matrix.os }} + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-ver }} + + - name: Add $GOPATH/bin to $PATH + run: echo "::add-path::$(go env GOPATH)/bin" + + - name: Install goxz + run: | + wget https://github.com/Songmu/${PKG_NAME}/releases/download/${PKG_VER}/${PKG_NAME}_${PKG_VER}_${GOOS}_${GOARCH}.tar.gz + tar zxf ${PKG_NAME}_${PKG_VER}_${GOOS}_${GOARCH}.tar.gz + mkdir -p $(go env GOPATH)/bin + mv ${PKG_NAME}_${PKG_VER}_${GOOS}_${GOARCH}/${PKG_NAME} $(go env GOPATH)/bin/ + env: + PKG_NAME: goxz + PKG_VER: v0.6.0 + GOOS: linux + GOARCH: amd64 + + - name: Install ghr + run: | + wget https://github.com/tcnksm/${PKG_NAME}/releases/download/${PKG_VER}/${PKG_NAME}_${PKG_VER}_${GOOS}_${GOARCH}.tar.gz + tar zxf ${PKG_NAME}_${PKG_VER}_${GOOS}_${GOARCH}.tar.gz + mkdir -p $(go env GOPATH)/bin + mv ${PKG_NAME}_${PKG_VER}_${GOOS}_${GOARCH}/${PKG_NAME} $(go env GOPATH)/bin/ + env: + PKG_NAME: ghr + PKG_VER: v0.13.0 + GOOS: linux + GOARCH: amd64 + + - name: Cross Compile + run: make cross-compile + + - name: Create Release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Assets + run: make upload-assets + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..1b10ae5 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,32 @@ +--- +name: CI +on: [push] +jobs: + test: + name: Test + timeout-minutes: 5 + strategy: + matrix: + os: ["ubuntu-latest"] + go-ver: ["1.13"] + runs-on: ${{ matrix.os }} + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-ver }} + + - name: Add $GOPATH/bin to $PATH + run: echo "::add-path::$(go env GOPATH)/bin" + + - name: Get dependencies + run: go get golang.org/x/lint/golint + + - name: Test + run: make test + + - name: Lint + run: make lint diff --git a/.gitignore b/.gitignore index 0373240..d3d5bf7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ mackerel-plugin-solrdih +main __debug_bin /dist/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 220cc9b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -language: go -notifications: - email: false -go: - - 1.12.x -env: - global: - - GO111MODULE=on -install: - - sudo apt-get update - - go get golang.org/x/lint/golint - - go get github.com/Songmu/goxz/cmd/goxz - - go get github.com/tcnksm/ghr -script: - - make all -after_success: - - if [[ $TRAVIS_TAG =~ ^v[0-9].*$ ]]; then ./release.sh; fi diff --git a/README.md b/README.md index 90cade9..a68d83b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -mackerel-plugin-solrdih [![Build Status](https://travis-ci.org/supercaracal/mackerel-plugin-solrdih.svg?branch=master)](https://travis-ci.org/supercaracal/mackerel-plugin-solrdih) +mackerel-plugin-solrdih ![](https://github.com/supercaracal/mackerel-plugin-solrdih/workflows/CI/badge.svg) ![](https://github.com/supercaracal/mackerel-plugin-solrdih/workflows/CD/badge.svg) ===================== Apache Solr DataImportHandler status metrics plugin for mackerel.io agent. diff --git a/go.mod b/go.mod index e259136..9d654e2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module mackerel-plugin-solrdih -go 1.12 +go 1.13 require ( github.com/mackerelio/go-mackerel-plugin-helper v0.0.0-20190712052147-cc61b45daff1 diff --git a/makefile b/makefile index b54339e..9b937dc 100644 --- a/makefile +++ b/makefile @@ -1,20 +1,29 @@ -SHELL := /bin/bash +SHELL := /bin/bash +owner_id := supercaracal +app_name := mackerel-plugin-solrdih +latest_tag := $(shell git describe --abbrev=0 --tags) -all: - @$(MAKE) --no-print-directory lint - @$(MAKE) --no-print-directory test - @$(MAKE) --no-print-directory build +all: build test lint build: mackerel-plugin-solrdih mackerel-plugin-solrdih: main.go - GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o $@ + go build -ldflags="-s -w" -trimpath -o $@ + +test: + go test lint: - @go vet - @golint -set_exit_status + go vet + golint -set_exit_status -test: - @go test +clean: + @rm -f mackerel-plugin-solrdih main + +cross-compile: + goxz -d dist/${latest_tag} -z -os windows,darwin,linux -arch amd64,386 + +upload-assets: + ghr -u ${owner_id} -r ${app_name} ${latest_tag} dist/${latest_tag} -.PHONY: all build lint test +.PHONY: all build test lint clean cross-compile upload-assets diff --git a/release.sh b/release.sh deleted file mode 100755 index 7978082..0000000 --- a/release.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -latest_tag=$(git describe --abbrev=0 --tags) -goxz -d dist/$latest_tag -z -os windows,darwin,linux -arch amd64,386 -ghr -u supercaracal -r mackerel-plugin-solrdih $latest_tag dist/$latest_tag