Skip to content

Commit

Permalink
Merge pull request #1 from jeff-roche/goreleaser
Browse files Browse the repository at this point in the history
feat: githooks, deploy script, and goreleaser config
  • Loading branch information
jeff-roche authored Jun 2, 2022
2 parents f972e92 + 2688258 commit c633f12
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

STAGED_GO_FILES=$(git diff --cached --name-only -- '*.go')

if [[ $STAGED_GO_FILES != "" ]]; then
echo "-- Formatting staged go files"
for file in $STAGED_GO_FILES; do
go fmt $file
git add $file
done

echo "-- Tidying go.mod"
go mod tidy
git add go.mod go.sum

echo "-- Running go vet"
go vet .
fi
7 changes: 7 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

echo "-- Cleaning test cache"
go clean -testcache

echo "-- Running tests"
go test ./...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ biome
vendor/

# Go workspace file
go.work
go.work
dist/
35 changes: 35 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
# - go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ $ onstaging ./bin/ci/deploy-service.sh
## Future Plans
- Implement goreleaser for binary building
- Use semantic versioning
- Add a version command
- Accept all valid yaml file extensions
- Build a Drone CI/CD pipeline
- Implement some tests
- Loading Environment variables from a .env file
Expand Down
20 changes: 20 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Fetch the latest tags
git fetch --tags

CURRENT=$(svu current)
NEXT=$(svu next)

if [ $CURRENT != $NEXT ]
then
echo "Tagging with" $NEXT
git tag $NEXT
git tag latest
git push --tags

# Do the release
VERSION=$NEXT goreleaser --rm-dist
else
echo "No new version detected. Skipping release."
fi
7 changes: 7 additions & 0 deletions scripts/install_deploy_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Install svu for version comparison
go install github.com/caarlos0/[email protected]

# Install goreleaser to do the release
go install github.com/goreleaser/[email protected]

0 comments on commit c633f12

Please sign in to comment.