https://github.com/livekit/mageutil
https://github.com/livekit/mageutil
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/livekit/mageutil
- Owner: livekit
- License: apache-2.0
- Created: 2022-09-27T19:45:03.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-05-11T04:50:21.000Z (about 1 year ago)
- Last Synced: 2025-08-23T06:09:58.311Z (10 months ago)
- Language: Go
- Size: 15.6 KB
- Stars: 3
- Watchers: 16
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mageutil
A collection of common helpers meant for use in [magefiles](https://magefile.org/).
## Examples:
Single command
```go
func Build() error {
ctx := context.Background()
return mageutil.RunDir(ctx, "cmd/server", "go build -o ../../bin/livekit-server")
}
```
Multiple commands
```go
const gstVersion = 1.20.3
func BuildDocker(version string) error {
return mageutil.Run(context.Background(),
fmt.Sprintf("docker pull livekit/gstreamer:%s-dev", gstVersion),
fmt.Sprintf("docker pull livekit/gstreamer:%s-prod", gstVersion),
fmt.Sprintf("docker build -t livekit/egress:v%s -f build/Dockerfile .", version),
)
}
```
Updating repos
```go
func BuildLivekit() error {
ctx := context.Background()
dir, err := filepath.Abs("..")
if err != nil {
return err
}
if err = mageutil.CloneRepo("livekit", "livekit", dir); err != nil {
return err
}
dir, err = filepath.Abs("../livekit")
if err != nil {
return err
}
return mageutil.RunDir(ctx, dir, "mage build")
}
```
Tools
```go
func Generate() error {
ctx := context.Background()
err := mageutil.InstallTool("github.com/google/wire/cmd/wire", "latest", false)
if err != nil {
return err
}
return mageutil.Run(ctx, "go generate ./...")
}
```
Group
```go
func RunLivekitWithEgress() error {
ctx := context.Background()
group := mageutil.NewGroup(ctx)
group.Go(func () error {
return RunDir(ctx, "../livekit", "bin/livekit-server --dev")
})
group.Go(func () error {
return Run(ctx, "docker run --rm -e EGRESS_CONFIG_FILE=/out/local.yaml -v ~/livekit/egress/test:/out livekit/egress")
})
group.Wait()
}
```