-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
134 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15 | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
bin/ | ||
makefile-e | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
project_name: safe | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- main: ./cmd/safe/safe.go | ||
binary: safe | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
|
||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
format: tar.gz | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- none* | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-snapshot" | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- README | ||
- typo | ||
|
||
release: | ||
github: | ||
owner: nobe4 | ||
name: safe | ||
prerelease: auto | ||
name_template: '{{ .Tag }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,42 @@ | ||
APP=safe | ||
PROJECT=github.com/nobe4/${APP} | ||
|
||
GO?=go | ||
GOOS?=darwin | ||
GOARCH?=amd64 | ||
|
||
# YYYY.MM.Count | ||
RELEASE?=2021.04.2 | ||
VERSION?=2021.04.2 | ||
COMMIT?=$(shell git rev-parse --short HEAD) | ||
BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S') | ||
|
||
BUILD_PATH=./bin/${GOOS}-${GOARCH}/${APP} | ||
MAIN_PATH=${PROJECT}/cmd/${APP} | ||
|
||
default: | build | ||
|
||
.PHONY: version | ||
version: | ||
@echo -n ${RELEASE} | ||
@echo -n ${VERSION} | ||
|
||
.PHONY: app-name | ||
app-name: | ||
@echo -n ${APP} | ||
|
||
build: | ||
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} \ | ||
go build -a \ | ||
-ldflags="-s -w \ | ||
-X 'main.Version=${RELEASE}' \ | ||
-X 'main.Commit=${COMMIT}' \ | ||
-X 'main.Build=${BUILD_TIME}' "\ | ||
-o ${BUILD_PATH} ${MAIN_PATH} | ||
|
||
.PHONY: lint | ||
goreleaser --snapshot --rm-dist | ||
|
||
# Used for manually releasing, normally running in github actions. | ||
release: | ||
ifneq ($(shell git symbolic-ref --short HEAD),master) | ||
$(error Not on master branch) | ||
endif | ||
|
||
goreleaser --rm-dist | ||
|
||
lint: | ||
golangci-lint run | ||
|
||
.PHONY: test | ||
test: | ||
go test ./... | ||
|
||
.PHONY: bump | ||
bump: | ||
./build/bump.sh | ||
./scripts/bump.sh | ||
git add makefile | ||
git commit -m "Bump version" --edit | ||
|
||
.PHONY: tag | ||
tag: | ||
./build/tag.sh | ||
./scripts/tag.sh | ||
|
||
.PHONY: bump tag lint test app-name version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
current_version=$(make version) | ||
|
||
# awk -F. split by '.', increase the last number, add the '.' back | ||
next_version=$(echo "$current_version" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') | ||
|
||
echo "Bump version $current_version to version $next_version" | ||
|
||
sed -i -e "s/$current_version/$next_version/" makefile | ||
|
||
echo "Don't forget to push the new tag before you merge." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
if [ "$(git symbolic-ref --short HEAD)" != "master" ]; then | ||
echo "Not on master branch, not tagging" | ||
exit 1 | ||
fi | ||
|
||
release=$(make version) | ||
|
||
if git rev-parse "$release" >/dev/null 2>&1 | ||
then | ||
echo "Tag $release already present, run 'make bump'" | ||
else | ||
git tag "$release" | ||
git push origin "$release" | ||
fi |