Skip to content

Commit

Permalink
build: replace Makefile with Taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Madh93 committed Dec 31, 2024
1 parent 1f36dbe commit 5756267
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .air.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build]
cmd = "/usr/bin/make install"
cmd = "task install"
bin = "/usr/bin/true"
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
air 1.43.0
golang 1.22.0
air 1.61.5
task 3.40.1
23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Install Go if it is not already installed. You can download it from the official
Clone the Terraform Provider Manager repository to build and install the binary:

```shell
git clone https://github.com/Madh93/tpm && cd tpm && make install
git clone https://github.com/Madh93/tpm && cd tpm && task install
```

## Usage
Expand Down
61 changes: 61 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: "3"

vars:
APP_NAME: tpm
APP_VERSION:
sh: git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"
COMMIT_HASH:
sh: git rev-parse HEAD
LD_FLAG_VERSION: "-X github.com/Madh93/tpm/internal/version.appVersion={{.APP_VERSION}}"
LD_FLAG_COMMIT: "-X github.com/Madh93/tpm/internal/version.commitHash={{.COMMIT_HASH}}"

env:
GCO_ENABLED: 0

tasks:
default:
desc: "Build and run"
cmds:
- task update-dependencies
- task build
- task install

clean:
desc: "Clean build artifacts"
cmds:
- go clean
- rm -rf bin

install:
desc: "Install the application"
cmds:
- go install -trimpath -ldflags "-s -w {{.LD_FLAG_VERSION}} {{.LD_FLAG_COMMIT}}"

test:
desc: "Run tests"
cmds:
- go test ./...

lint:
desc: "Run linters"
cmds:
- golangci-lint run

update-dependencies:
desc: "Update dependencies"
cmds:
- go get -u all && go mod tidy

#############
### BUILD ###
#############

build:
desc: "Build the application"
cmds:
- go build -trimpath -ldflags "-s -w {{.LD_FLAG_VERSION}} {{.LD_FLAG_COMMIT}}" -o bin/{{.APP_NAME}} main.go

build:debug:
desc: "Build the application for debug mode"
cmds:
- go build -ldflags "{{.LD_FLAG_VERSION}} {{.LD_FLAG_COMMIT}}" -gcflags=all="-N -l" -o bin/{{.APP_NAME}}-debug main.go

0 comments on commit 5756267

Please sign in to comment.