-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetails.txt
More file actions
61 lines (44 loc) · 1.57 KB
/
details.txt
File metadata and controls
61 lines (44 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
## Installation
```bash
go install github.com/fezcode/gobake/cmd/gobake@latest
```
## Quick Start
1. **Initialize a new project:**
```bash
mkdir my-project
cd my-project
gobake init
```
The `init` command is smart: it handles `go mod init` (if needed), scaffolds your `recipe.piml` and `Recipe.go`, and runs `go mod tidy` to automatically pull in the `github.com/fezcode/gobake` library as a dependency.
2. **Run a task:**
```bash
gobake build
```
## Usage
### Commands
* **`gobake init`**: Scaffolds a new `Recipe.go` and `recipe.piml`. Handles `go.mod` and dependencies.
* **`gobake version`**: Displays the current version of gobake.
* **`gobake help`**: Displays the list of commands and available tasks.
* **`gobake bump [patch|minor|major]`**: Increments the version in `recipe.piml`.
* **`gobake template <git-url>`**: Initialize from a remote repository template.
### The `Recipe.go` File
```go
//go:build gobake
package bake_recipe
import (
"fmt"
"github.com/fezcode/gobake"
)
func Run(bake *gobake.Engine) error {
if err := bake.LoadRecipeInfo("recipe.piml"); err != nil {
return fmt.Errorf("error loading recipe.piml: %v", err)
}
bake.Task("test", "Runs project tests", func(ctx *gobake.Context) error {
return ctx.Run("go", "test", "./...")
})
bake.TaskWithDeps("build", "Builds the binary", []string{"test"}, func(ctx *gobake.Context) error {
return ctx.BakeBinary("linux", "amd64", "bin/app")
})
return nil
}
```