commit 04a6000a4ecec688e545a9e05336ad51bd02f15f Author: ☙◦ The Tablet ❀ GamerGirlandCo ◦❧ Date: Thu Sep 12 19:35:20 2024 -0400 hello world! 🌸 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9016277 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# ---> Go +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +go.work.sum + +# env file +.env + +.idea/material_theme_project_new.xml \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..1c2fda5 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/gopack-internal.iml b/.idea/gopack-internal.iml new file mode 100644 index 0000000..338a266 --- /dev/null +++ b/.idea/gopack-internal.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..d20b53d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8f67527 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..01969dc --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# gopack + +internal utility to create zip files from go module directories + +## usage + +``` +gopack PACKAGE-NAME VERSION [PATH] +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..24a1583 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module rockfic.com/gopack + +go 1.23.0 + +require golang.org/x/mod v0.21.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..da3e33a --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= diff --git a/main.go b/main.go new file mode 100644 index 0000000..f4d3b76 --- /dev/null +++ b/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "golang.org/x/mod/module" + "golang.org/x/mod/zip" + "log" + "os" + "path/filepath" + "strings" +) + +func main() { + args := os.Args[1:] + if len(args) < 2 { + log.Fatal("usage: PACKAGE-NAME VERSION [PATH]") + } + version := args[1] + if !strings.HasPrefix(version, "v") { + version = fmt.Sprintf("v%s", version) + } + + var absPath string + if len(args) < 3 { + absPath, _ = os.Getwd() + } else { + absPath, _ = filepath.Abs(args[2]) + } + buildFile := fmt.Sprintf(filepath.Join(absPath, "build", "%s.zip"), version) + _ = os.Remove(buildFile) + f, _ := os.Create(buildFile) + err := zip.CreateFromVCS(f, module.Version{ + Version: version, + Path: args[0], + }, absPath, version, "") + if err != nil { + log.Fatal(err) + } +}