Dan Anglin
d23e6e531f
- Mage can now render templates for all services using: mage render all - Mage can now deploy all services using: mage deploy all - Deploy now depends on Render - If rendering Forgejo templates mage ensures that the Forgejo binary is downloaded first.
55 lines
985 B
Go
55 lines
985 B
Go
//go:build mage
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/magefile/mage/sh"
|
|
)
|
|
|
|
const (
|
|
configFile string = "./config/services.json"
|
|
rootBuildDir string = "./build"
|
|
templateExtension string = ".gotmpl"
|
|
rootTemplatesDir string = "./templates"
|
|
)
|
|
|
|
// Clean cleans the workspace.
|
|
func Clean() error {
|
|
buildDir := "./build"
|
|
|
|
objects, err := os.ReadDir(buildDir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for i := range objects {
|
|
name := objects[i].Name()
|
|
|
|
if name != ".gitkeep" {
|
|
if err := sh.Rm(buildDir + "/" + name); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// DownloadForgejo downloads the Forgejo binary from Codeberg.
|
|
func DownloadForgejo() error {
|
|
cfg, err := newConfig(configFile)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to load the configuration; %v", err)
|
|
}
|
|
|
|
version := cfg.Forgejo.Version
|
|
|
|
if err := downloadForgejo(version); err != nil {
|
|
return fmt.Errorf("unable to download Forgejo %s; %w", version, err)
|
|
}
|
|
|
|
return nil
|
|
}
|