Skip to content

Commit

Permalink
Merge pull request #141 from tcnksm/maint
Browse files Browse the repository at this point in the history
introduce modern releng stack
  • Loading branch information
Songmu authored Sep 26, 2022
2 parents 8583968 + 2b92508 commit 5aad1db
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 43 deletions.
19 changes: 19 additions & 0 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: release
description: release maltmill
inputs:
token:
description: GitHub token
required: true
runs:
using: composite
steps:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: 1.x
- name: release
run: |
make crossbuild upload
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.token }}
14 changes: 14 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: ./.github/actions/release
with:
token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/tagpr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: tagpr
on:
push:
branches:
- "master"
jobs:
tagpr:
runs-on: ubuntu-latest
steps:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: 1.x
- name: checkout
uses: actions/checkout@v3
- name: tagpr
id: tagpr
uses: Songmu/tagpr@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/release
with:
tag: ${{ steps.tagpr.outputs.tag }}
token: ${{ secrets.GITHUB_TOKEN }}
if: "steps.tagpr.outputs.tag != ''"
19 changes: 6 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Test
on:
push:
pull_request:

branches:
- "**"
jobs:
test:
name: Test
Expand All @@ -14,37 +14,30 @@ jobs:
- ubuntu-latest
- macos-latest
- windows-latest
go:
- "1.x"

steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

go-version: 1.x
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: restore cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: make cover
env:
GITHUB_TOKEN: ${{ secrets.GHTOOLS_GITHUB_TOKEN }}

- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: cover.out
parallel: true
flag-name: OS-${{ matrix.os }}-Go-${{ matrix.go }}
flag-name: OS-${{ matrix.os }}-Go-1.x

# notifies that all test jobs are finished.
finish:
Expand Down
35 changes: 5 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
VERSION = $(shell godzil show-version)
COMMIT = $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS = "-s -w -X main.GitCommit=$(COMMIT)"
EXTERNAL_TOOLS = \
golang.org/x/lint/golint \
github.com/Songmu/godzil/cmd/godzil \
github.com/Songmu/ghch/cmd/ghch \
github.com/mattn/goveralls \
github.com/Songmu/gocredits/cmd/gocredits \
golang.org/x/tools/cmd/cover

ifdef update
u=-u
endif

export GO111MODULE=on

.PHONY: default
default: test

Expand All @@ -26,26 +16,19 @@ deps:
# install external tools for this project
.PHONY: devel-deps
devel-deps: deps
@for tool in $(EXTERNAL_TOOLS) ; do \
echo "Installing $$tool" ; \
go install $$tool@latest; \
done
go install github.com/Songmu/godzil/cmd/godzil@latest

# build generate binary on './bin' directory.
.PHONY: build
build:
go build -ldflags=$(BUILD_LDFLAGS) -o bin/ghr

.PHONY: bump
bump: devel-deps
godzil release

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

.PHONY: crossbuild
crossbuild: CREDITS
goxz -pv=v${VERSION} -build-ldflags=$(BUILD_LDFLAGS) \
godzil crossbuild -pv=v${VERSION} -build-ldflags=$(BUILD_LDFLAGS) \
-arch=amd64 -d=./pkg/dist/v${VERSION}
cd pkg/dist/v${VERSION} && shasum -a 256 * > ./v${VERSION}_SHASUMS

Expand All @@ -57,10 +40,7 @@ install:
.PHONY: upload
upload: build devel-deps
bin/ghr -v
bin/ghr -body="$$(ghch --latest -F markdown)" v$(VERSION) pkg/dist/v$(VERSION)

.PHONY: test-all
test-all: lint test
bin/ghr v$(VERSION) pkg/dist/v$(VERSION)

.PHONY: test
test: deps
Expand All @@ -70,15 +50,10 @@ test: deps
test-race:
go test -v -race ./...

.PHONY: lint
lint: devel-deps
go vet ./...
golint -set_exit_status ./...

.PHONY: cover
cover:
go test -coverprofile=cover.out
go tool cover -html cover.out

.PHONY: release
release: bump crossbuild upload
release: crossbuild upload

0 comments on commit 5aad1db

Please sign in to comment.