Magefile initial conversion
This commit is contained in:
parent
118e2f12c6
commit
1ae4d1686b
3 changed files with 61 additions and 0 deletions
5
go.mod
Normal file
5
go.mod
Normal file
|
@ -0,0 +1,5 @@
|
|||
module DigitalStorageTweaks
|
||||
|
||||
go 1.24.3
|
||||
|
||||
require github.com/magefile/mage v1.15.0
|
2
go.sum
Normal file
2
go.sum
Normal file
|
@ -0,0 +1,2 @@
|
|||
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
|
||||
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
54
magefile.go
Normal file
54
magefile.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
//go:build mage
|
||||
// +build mage
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
)
|
||||
|
||||
const (
|
||||
zipName = "DigitalStorageTweaks.zip"
|
||||
filesToCopy = "./ContentLib ./DigitalStorageTweaks.uplugin"
|
||||
targetDirs = "Windows WindowsServer LinuxServer"
|
||||
)
|
||||
|
||||
// Default target to run when none is specified
|
||||
var Default = Package
|
||||
|
||||
// Package creates the distribution zip file
|
||||
func Package() error {
|
||||
mg.Deps(Clean)
|
||||
|
||||
fmt.Println("Creating target directories...")
|
||||
for _, dir := range []string{"Windows", "WindowsServer", "LinuxServer"} {
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return fmt.Errorf("failed to create directory %s: %v", dir, err)
|
||||
}
|
||||
|
||||
fmt.Printf("Copying files to %s...\n", dir)
|
||||
if err := sh.Run("cp", "-r", "./ContentLib", "./DigitalStorageTweaks.uplugin", dir+"/"); err != nil {
|
||||
return fmt.Errorf("failed to copy files to %s: %v", dir, err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Creating zip archive...")
|
||||
return sh.Run("7z", "a", "-r", zipName, "Windows/", "LinuxServer/", "WindowsServer/")
|
||||
}
|
||||
|
||||
// Clean removes generated directories and zip file
|
||||
func Clean() error {
|
||||
fmt.Println("Cleaning up...")
|
||||
toRemove := []string{"Windows", "WindowsServer", "LinuxServer", zipName}
|
||||
|
||||
for _, path := range toRemove {
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
return fmt.Errorf("failed to remove %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue