Skip to content

Commit 1cda0aa

Browse files
committed
feat: gobake
1 parent ff03cc2 commit 1cda0aa

File tree

14 files changed

+734
-1
lines changed

14 files changed

+734
-1
lines changed
416 KB
Loading

public/projects/gobake/cta.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Get started with gobake today
2+
3+
```bash
4+
go install github.com/fezcode/gobake/cmd/gobake@latest
5+
```

public/projects/gobake/details.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Installation
2+
3+
```bash
4+
go install github.com/fezcode/gobake/cmd/gobake@latest
5+
```
6+
7+
## Quick Start
8+
9+
1. **Initialize a new project:**
10+
11+
```bash
12+
mkdir my-project
13+
cd my-project
14+
gobake init
15+
```
16+
17+
This creates a `recipe.piml` and a `Recipe.go`.
18+
19+
2. **Run a task:**
20+
21+
```bash
22+
gobake build
23+
```
24+
25+
## Usage
26+
27+
### Commands
28+
29+
* `gobake init`: Scaffolds a new `Recipe.go` and `recipe.piml`.
30+
* `gobake version`: Displays the current version of gobake.
31+
* `gobake help`: Displays the list of commands and available tasks.
32+
* `gobake bump [patch|minor|major]`: Increments the version in `recipe.piml`.
33+
34+
### The `Recipe.go` File
35+
36+
```go
37+
package main
38+
import "github.com/fezcode/gobake"
39+
40+
func main() {
41+
bake := gobake.NewEngine()
42+
bake.LoadRecipeInfo("recipe.piml")
43+
bake.Task("build", "Builds the binary", func(ctx *gobake.Context) error {
44+
return ctx.BakeBinary("linux", "amd64", "bin/app")
45+
})
46+
bake.Execute()
47+
}
48+
```
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# gobake Examples
2+
3+
## 1. Cross-Compilation for Multiple Platforms
4+
5+
This recipe builds your application for Windows, Linux, and macOS.
6+
7+
```go
8+
package main
9+
10+
import (
11+
"fmt"
12+
"github.com/fezcode/gobake"
13+
)
14+
15+
func main() {
16+
bake := gobake.NewEngine()
17+
bake.LoadRecipeInfo("recipe.piml")
18+
19+
bake.Task("release", "Build for all platforms", func(ctx *gobake.Context) error {
20+
platforms := []struct {
21+
OS string
22+
Arch string
23+
Ext string
24+
}{
25+
{"linux", "amd64", ""},
26+
{"windows", "amd64", ".exe"},
27+
{"darwin", "arm64", ""},
28+
}
29+
30+
for _, p := range platforms {
31+
output := fmt.Sprintf("dist/%s-%s-%s%s",
32+
bake.Info.Name, p.OS, p.Arch, p.Ext)
33+
34+
err := ctx.BakeBinary(p.OS, p.Arch, output, "-ldflags", "-s -w")
35+
if err != nil {
36+
return err
37+
}
38+
}
39+
return nil
40+
})
41+
42+
bake.Execute()
43+
}
44+
```
45+
46+
## 2. Using External Tools
47+
48+
This recipe installs `stringer` and uses it to generate code before building.
49+
50+
**recipe.piml:**
51+
```piml
52+
(name) my-app
53+
(tools)
54+
> golang.org/x/tools/cmd/stringer@latest
55+
```
56+
57+
**Recipe.go:**
58+
```go
59+
package main
60+
61+
import "github.com/fezcode/gobake"
62+
63+
func main() {
64+
bake := gobake.NewEngine()
65+
bake.LoadRecipeInfo("recipe.piml")
66+
67+
bake.Task("generate", "Generates code", func(ctx *gobake.Context) error {
68+
// Ensure tools are installed first
69+
if err := ctx.InstallTools(); err != nil {
70+
return err
71+
}
72+
ctx.Log("Running stringer...")
73+
return ctx.Run("go", "generate", "./...")
74+
})
75+
76+
bake.Task("build", "Builds app", func(ctx *gobake.Context) error {
77+
if err := ctx.Run("gobake", "generate"); err != nil {
78+
return err
79+
}
80+
return ctx.Run("go", "build", ".")
81+
})
82+
83+
bake.Execute()
84+
}
85+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
:::feature
2+
title: Go-Native
3+
icon: Code
4+
creator: Fezcode
5+
role: CREATOR
6+
description: Write your build scripts in Go. No new syntax to learn. Benefit from Go's type safety and performance.
7+
:::
8+
9+
:::feature
10+
title: Zero Dependencies
11+
icon: ShieldCheck
12+
creator: Samil B.
13+
role: ARCHITECT
14+
description: The build system is just a Go program. It compiles itself on the fly, requiring nothing but the Go toolchain.
15+
:::
16+
17+
:::feature
18+
title: Metadata Management
19+
icon: NewspaperClipping
20+
creator: Fezcoddy
21+
role: DESIGNER
22+
description: Manage versions, tools, and dependencies in a central `recipe.piml` file.
23+
:::
24+
25+
:::feature
26+
title: Self-Bootstrapping
27+
icon: Cpu
28+
creator: Neural Nexus
29+
role: KERNEL
30+
description: Just run `gobake`. It handles the rest, ensuring your build environment is always consistent.
31+
:::

public/projects/gobake/guide.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Core Concepts
2+
3+
`gobake` operates on a simple principle: **Your build system should be as robust as your application.**
4+
5+
Instead of relying on fragile shell scripts or complex Makefiles, `gobake` uses:
6+
1. **Engine:** The core Go library that manages tasks.
7+
2. **Context:** A helper object passed to every task, providing access to the shell, logging, and metadata.
8+
3. **Recipe:** The `Recipe.go` file that ties it all together.
9+
10+
# CLI Command Reference
11+
12+
## Project Management
13+
14+
* **`gobake init`**: Initialize a new project in the current directory.
15+
* **`gobake version`**: Show the current version of gobake.
16+
* **`gobake help`**: Show the list of available commands and project tasks.
17+
* **`gobake template <git-url>`**: Clone a repository and initialize it.
18+
19+
## Dependency & Tool Management
20+
21+
* **`gobake add-tool <url>`**: Adds a tool to the `(tools)` list in `recipe.piml`.
22+
* **`gobake add-dep <url>`**: Adds a library dependency to `go.mod`.
23+
24+
## Versioning
25+
26+
* **`gobake bump [patch|minor|major]`**: Increments the project version in `recipe.piml`.
27+
28+
# Metadata (`recipe.piml`)
29+
30+
The `recipe.piml` file is the single source of truth for your project.
31+
32+
```piml
33+
(name) my-project
34+
(version) 1.2.3
35+
(authors)
36+
> Ahmed <ahmed@example.com>
37+
(tools)
38+
> github.com/swaggo/swag/cmd/swag@latest
39+
```
40+
41+
# Task Management
42+
43+
Tasks are defined using `bake.Task(name, description, function)`.
44+
45+
## Task Dependencies
46+
47+
You can define tasks that depend on other tasks using `bake.TaskWithDeps`.
48+
49+
```go
50+
bake.Task("test", "Run tests", func(ctx *gobake.Context) error { ... })
51+
bake.TaskWithDeps("build", "Build app", []string{"test"}, func(ctx *gobake.Context) error { ... })
52+
```

public/projects/gobake/hero.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# gobake
2+
A Go-native build orchestrator, type-safe and dependency-free.
3+
4+
**gobake** is a Go-native build orchestrator. It replaces Makefiles and shell scripts with a single, type-safe `Recipe.go` file. Inspired by `nob.h`, it allows you to write your build logic in Go, which is then compiled and executed on the fly.

public/projects/gobake/line.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:::card
2+
type: install
3+
title: Quick Installation
4+
code: go install github.com/fezcode/gobake/cmd/gobake@latest
5+
btnText: INSTALL!
6+
btnLink: #installation
7+
:::
8+
9+
:::card
10+
type: code
11+
title: Define Recipe
12+
code: bake.Task("build", func(ctx) {
13+
return ctx.Bake("bin/app")
14+
})
15+
btnText: GUIDE!
16+
btnLink: #docs
17+
:::
18+
19+
:::card
20+
type: command
21+
title: Run Task
22+
code: gobake build
23+
btnText: SOURCE!
24+
btnLink: https://github.com/fezcode/gobake
25+
:::
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)