|
| 1 | +version: "3" |
| 2 | + |
| 3 | +env: |
| 4 | + INSTALL_DIR: "/usr/local/bin" |
| 5 | + IMAGE_TAG: "gatecheck:latest" |
| 6 | + |
| 7 | +tasks: |
| 8 | + build: |
| 9 | + desc: "Build the gatecheck binary" |
| 10 | + vars: |
| 11 | + BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" now "UTC"}}' |
| 12 | + CLI_VERSION: |
| 13 | + sh: git describe --tags || git rev-parse --short HEAD || "v0.0.0-unknown" |
| 14 | + GIT_COMMIT: |
| 15 | + sh: git rev-parse HEAD |
| 16 | + GIT_DESCRIPTION: |
| 17 | + sh: git log -1 --pretty=%B |
| 18 | + cmds: |
| 19 | + - mkdir -p bin |
| 20 | + - go build -ldflags="-X 'main.cliVersion={{.CLI_VERSION}}' -X 'main.gitCommit={{.GIT_COMMIT}}' -X 'main.buildDate={{.BUILD_DATE}}' -X 'main.gitDescription={{.GIT_DESCRIPTION}}'" -o ./bin ./cmd/gatecheck |
| 21 | + sources: |
| 22 | + - cmd/* |
| 23 | + - pkg/* |
| 24 | + - go* |
| 25 | + generates: |
| 26 | + - bin/gatecheck |
| 27 | + |
| 28 | + install: |
| 29 | + desc: "Install the gatecheck binary" |
| 30 | + prompt: 'Install gatecheck binary to {{joinPath .INSTALL_DIR "gatecheck"}} ...Continue?' |
| 31 | + deps: |
| 32 | + - build |
| 33 | + cmds: |
| 34 | + - cp ./bin/gatecheck {{joinPath .INSTALL_DIR "gatecheck"}} |
| 35 | + sources: |
| 36 | + - ./bin/gatecheck |
| 37 | + generates: |
| 38 | + - '{{joinPath .INSTALL_DIR "gatecheck"}}' |
| 39 | + |
| 40 | + uninstall: |
| 41 | + desc: "Uninstall the gatecheck binary" |
| 42 | + prompt: 'Will remove binary {{joinPath .INSTALL_DIR "gatecheck"}}' |
| 43 | + cmds: |
| 44 | + - rm '{{joinPath .INSTALL_DIR "gatecheck"}}' |
| 45 | + |
| 46 | + test: |
| 47 | + desc: "Run unit tests with coverage" |
| 48 | + cmds: |
| 49 | + - go test -cover ./... |
| 50 | + |
| 51 | + lint: |
| 52 | + desc: "Run golangci-lint in view-only mode" |
| 53 | + cmds: |
| 54 | + - golangci-lint run --fast |
| 55 | + |
| 56 | + fix: |
| 57 | + desc: "Fix linting errors and format code" |
| 58 | + cmds: |
| 59 | + - golangci-lint run --fast --fix |
| 60 | + |
| 61 | + release-snapshot: |
| 62 | + desc: "Create a snapshot release" |
| 63 | + cmds: |
| 64 | + - goreleaser release --snapshot --rm-dist |
| 65 | + |
| 66 | + release: |
| 67 | + desc: "Create a release" |
| 68 | + cmds: |
| 69 | + - goreleaser release --rm-dist |
| 70 | + |
| 71 | + upgrade: |
| 72 | + desc: "Upgrade package dependencies" |
| 73 | + preconditions: |
| 74 | + - sh: git status --porcelain | grep -q . |
| 75 | + msg: "Repository is dirty, commit changes before upgrading." |
| 76 | + cmds: |
| 77 | + - go get -u ./... |
| 78 | + - go mod tidy |
| 79 | + |
| 80 | + serve-docs: |
| 81 | + desc: "Serve documentation locally" |
| 82 | + cmds: |
| 83 | + - mdbook serve |
| 84 | + |
| 85 | + clean: |
| 86 | + desc: "Clean up build directory" |
| 87 | + cmds: |
| 88 | + - rm -rf ./bin |
0 commit comments