Skip to content

Commit

Permalink
Merge pull request #9 from Songmu/versioning
Browse files Browse the repository at this point in the history
add version.go
  • Loading branch information
Songmu authored Sep 13, 2021
2 parents c5ad93d + a4a5b66 commit 4a85193
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: setup go
uses: actions/setup-go@v2
with:
go-version: 1.x
- name: checkout
uses: actions/checkout@v2
- name: release
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
run: |
make crossbuild upload
13 changes: 13 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: reviewdog
on: [pull_request]
jobs:
staticcheck:
name: staticcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reviewdog/action-staticcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
fail_on_error: true
32 changes: 32 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: test
on:
push:
branches:
- "**"
pull_request: {}
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
- name: setup go
uses: actions/setup-go@v2
with:
go-version: 1.x
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
if: "matrix.os == 'windows-latest'"
- name: checkout
uses: actions/checkout@v2
- name: test
run: go test -coverprofile coverage.out -covermode atomic ./...
- name: Send coverage
uses: codecov/codecov-action@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.*
!.gitignore
!.github
bin/
secret.yaml
42 changes: 25 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
VERSION = $(shell godzil show-version)
CURRENT_REVISION = $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS = "-s -w -X github.com/Songmu/deglacer.revision=$(CURRENT_REVISION)"
u := $(if $(update),-u)

export GO111MODULE=on

.PHONY: build
build: deps
go build -ldflags=$(BUILD_LDFLAGS) -o bin/deglacer ./cmd/deglacer

.PHONY: deps
deps:
go get ${u} -d
go mod tidy

.PHONY: devel-deps
devel-deps:
sh -c '\
tmpdir=$$(mktemp -d); \
cd $$tmpdir; \
go get ${u} \
golang.org/x/lint/golint \
github.com/Songmu/godzil/cmd/godzil; \
rm -rf $$tmpdir'
go install github.com/Songmu/godzil/cmd/godzil@latest
go install github.com/tcnksm/ghr@latest

.PHONY: test
test:
go test -race
go test

.PHONY: build
build:
go build -ldflags=$(BUILD_LDFLAGS) -o bin/deglacer ./cmd/deglacer

.PHONY: lint
lint: devel-deps
golint -set_exit_status
.PHONY: install
install:
go install -ldflags=$(BUILD_LDFLAGS) ./cmd/deglacer

.PHONY: release
release: devel-deps
godzil release

CREDITS: go.sum deps devel-deps
godzil credits -w

.PHONY: crossbuild
crossbuild: CREDITS
godzil crossbuild -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) \
-os=linux,darwin -d=./dist/v$(VERSION) ./cmd/*

.PHONY: upload
upload:
ghr -body="$$(godzil changelog --latest -F markdown)" v$(VERSION) dist/v$(VERSION)
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment: false
2 changes: 1 addition & 1 deletion deglacer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func initialize() error {
func index(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
fmt.Fprintf(w, "Hello")
fmt.Fprintf(w, "Hello! (deglacer version: %s, rev: %s)", version, revision)
case http.MethodPost:
body, err := ioutil.ReadAll(r.Body)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package deglacer

const version = "0.0.0"

var revision = "HEAD"

0 comments on commit 4a85193

Please sign in to comment.