Skip to content

Commit b2bf5a2

Browse files
committed
Adjust project structure
1 parent d95f68d commit b2bf5a2

File tree

3 files changed

+41
-33
lines changed

3 files changed

+41
-33
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- master
99
workflow_dispatch: {}
1010
jobs:
11+
# Runs on every push and pull request on the selected branches.
12+
# Can also be executed manually.
1113
test:
1214
name: code quality and correctness
1315
runs-on: ubuntu-latest
@@ -23,7 +25,7 @@ jobs:
2325
- name: Checkout repository
2426
uses: actions/checkout@v2
2527

26-
# Configure runner environment
28+
# Prepare runner environment
2729
- name: Set up runner environment
2830
run: ./.github/workflows/assets/utils.sh setup
2931
env:
@@ -33,7 +35,7 @@ jobs:
3335
# If "vendor" is in cache, restore.
3436
# To run conditional steps use:
3537
# if: steps.vendor-cache.outputs.cache-hit != 'true'
36-
- name: Restore modules from cache
38+
- name: Restore vendor from cache
3739
id: vendor-cache
3840
uses: actions/cache@v2
3941
env:
@@ -55,7 +57,7 @@ jobs:
5557

5658
# Ensure project compile and build successfully
5759
- name: Build
58-
run: make build
60+
run: make build-for os=linux arch=amd64
5961

6062
# Save artifacts
6163
- name: Save artifacts

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ name: release
22
on:
33
push:
44
tags:
5-
- v*
5+
- '*'
66
jobs:
77
# Publish project package(s)
88
publish:
99
name: publish package
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 10
12-
if: ${{ contains(github.ref, 'refs/tags/') }}
12+
if: startsWith(github.ref, 'refs/tags/')
1313
steps:
1414
# Go 1.14
1515
- name: Set up Go 1.14
@@ -33,7 +33,7 @@ jobs:
3333
# If "vendor" is in cache, restore.
3434
# To run conditional steps use:
3535
# if: steps.vendor-cache.outputs.cache-hit != 'true'
36-
- name: Restore modules from cache
36+
- name: Restore vendor from cache
3737
id: vendor-cache
3838
uses: actions/cache@v2
3939
env:
@@ -42,10 +42,14 @@ jobs:
4242
path: ./vendor
4343
key: ${{ env.cache-name }}-${{ hashFiles('go.sum') }}
4444

45+
# Ensure project compile and build successfully
46+
- name: Build
47+
run: make build-for os=linux arch=amd64
48+
4549
# Use goreleaser to create the new release
4650
- name: Create release
4751
uses: goreleaser/goreleaser-action@v2
48-
if: startsWith(github.ref, 'refs/tags/v')
52+
if: startsWith(github.ref, 'refs/tags/')
4953
with:
5054
version: latest
5155
args: release --rm-dist --skip-validate

Makefile

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
# Project setup
55
BINARY_NAME=tredctl
6+
MAINTAINERS='Ben Cessa <ben@pixative.com>'
67

78
# State values
89
GIT_COMMIT_DATE=$(shell TZ=UTC git log -n1 --pretty=format:'%cd' --date='format-local:%Y-%m-%dT%H:%M:%SZ')
910
GIT_COMMIT_HASH=$(shell git log -n1 --pretty=format:'%H')
10-
GIT_TAG=$(shell git describe --abbrev=0 --match='v*' --always | cut -c 1-8)
11+
GIT_TAG=$(shell git describe --tags --always --abbrev=0 | cut -c 1-8)
1112

1213
# Linker tags
1314
# https://golang.org/cmd/link/
@@ -21,15 +22,16 @@ help:
2122
@echo "Commands available"
2223
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' | sort
2324

24-
## updates: List available updates for direct dependencies
25-
updates:
26-
# https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies
27-
go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all 2> /dev/null
25+
## build: Build for the default architecture in use
26+
build:
27+
go build -v -ldflags '$(LD_FLAGS)' -o $(BINARY_NAME)
2828

29-
## scan: Look for known vulnerabilities in the project dependencies
30-
# https://github.com/sonatype-nexus-community/nancy
31-
scan:
32-
@nancy -quiet go.sum
29+
## build-for: Build the available binaries for the specified 'os' and 'arch'
30+
# make build-for os=linux arch=amd64
31+
build-for:
32+
CGO_ENABLED=0 GOOS=$(os) GOARCH=$(arch) \
33+
go build -v -ldflags '$(LD_FLAGS)' \
34+
-o $(BINARY_NAME)_$(os)_$(arch)$(suffix)
3335

3436
## clean: Verify dependencies and remove intermediary products
3537
clean:
@@ -38,29 +40,29 @@ clean:
3840
go mod tidy
3941
go mod verify
4042

43+
## install: Install the binary to '$GOPATH/bin'
44+
install:
45+
go build -v -ldflags '$(LD_FLAGS)' -i -o ${GOPATH}/bin/$(BINARY_NAME)
46+
4147
## lint: Static analysis
4248
lint:
4349
golangci-lint run -v ./...
4450

51+
## release: Prepare the artifacts for a new tagged release
52+
release:
53+
goreleaser release --skip-validate --skip-publish --rm-dist
54+
55+
## scan: Look for known vulnerabilities in the project dependencies
56+
# https://github.com/sonatype-nexus-community/nancy
57+
scan:
58+
@nancy -quiet go.sum
59+
4560
## test: Run unit tests excluding the vendor dependencies
4661
test:
4762
go test -v -race -failfast -coverprofile=coverage.report ./...
4863
go tool cover -html coverage.report -o coverage.html
4964

50-
## build: Build for the default architecture in use
51-
build:
52-
go build -v -ldflags '$(LD_FLAGS)' -o $(BINARY_NAME)
53-
54-
## install: Install the binary to '$GOPATH/bin'
55-
install:
56-
go build -v -ldflags '$(LD_FLAGS)' -i -o ${GOPATH}/bin/$(BINARY_NAME)
57-
58-
## build-for: Build the available binaries for the specified 'os' and 'arch'
59-
build-for:
60-
CGO_ENABLED=0 GOOS=$(os) GOARCH=$(arch) \
61-
go build -v -ldflags '$(LD_FLAGS)' \
62-
-o $(BINARY_NAME)_$(os)_$(arch)$(suffix)
63-
64-
## release: Prepare the artifacts for a new tagged release
65-
release:
66-
goreleaser release --skip-validate --skip-publish --rm-dist
65+
## updates: List available updates for direct dependencies
66+
updates:
67+
# https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies
68+
go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all 2> /dev/null

0 commit comments

Comments
 (0)