1. Quick Start
Install CONR, then run one command to produce a Go module zip:
# Install conr
go install code.nicktrevino.com/conr/cmd/conr@latest
conr --mod ./cool-module --outDir ./dist --clean
Within ./dist, you’ll see a structured output for each discovered tag, including
zip archives (.zip) and accompanying metadata (.mod, .info).
This matches Go’s official module layout so that downstream tooling recognizes it.
2. Features
- Golang Module Packaging: Creates valid module zip files for each tagged release.
- Selective Downloads: Target only the files you want, thanks to flexible
--includeand--excludepatterns. - Ephemeral Clones: Safely clones repositories into temp directories, leaving your local repos untouched.
- Metadata Generation: Produces
.mod,.info, andlistfiles for each tag, plus sets@latest. - Concurrency: Processes multiple modules (and tags) in parallel, cutting down on build times.
- Regex-based Filtering: Integrate custom or built-in exclude patterns (like
.git/**/*and test files) as needed. - Logging & Debugging: Use
--showSkipsto see which files were excluded, or verify includes in real time.
3. How It Works
CONR clones your repo, enumerates v* tags, then checks
each out in turn, copying relevant Go source files into a streamed zip.
We also build go.mod-like files (.mod), version info (.info),
and a list of tags, all structured in @v subdirectories.
Finally, @latest is updated to the newest version.
Workflow Outline
- Clone: Provide
--modfor each repo or path. CONR clones them into fresh temp directories. - Tag Discovery: We gather Git tags beginning with
v(e.g.v1.2.3), then sort them. - Checkout & Packaging: For each tag, the tool checks out the commit, includes/excludes the right files, and zips them up as Go module archives.
- Metadata Prep: We generate
list(containing all discovered tags),@latest,.mod, and.infoso that Go tooling sees a valid module structure. - Cleanup: Once done, the temporary clone is removed, leaving your local machine clutter-free.
4. Advanced Usage
- Multiple Modules: Pass multiple
--modflags to process multiple repos concurrently. - Include & Exclude Files: Use
--include/--excludeor load patterns from--includeListFile/--excludeListFileto refine your build output. - Built-In Rules: By default, CONR excludes Git internals (
.git/*) and test files (*_test.go), but you can skip these built-ins with--skipBuiltinExcludes. - VCS Agnostic: The
--vcsflag (defaultgit) and an internal interface allow for future expansion to other version control systems. - Clean Output: Use
--cleanto overwrite an existing output directory if needed, or--showSkipsfor debugging.
5. Internals
- Implementation: Written in Go, orchestrating ephemeral clones via
go-gitand streaming archives witharchive/zip. - CLI Framework: Built with Cobra for robust subcommands, flags, and usage screens.
- Regex-Based Globs: Our
**/expansions are turned into case-insensitive regex for precise file matching. - Parallelization: We spawn goroutines to handle multiple modules in parallel, speeding up large builds.
- Minimal Memory Footprint: Everything is streamed to zip files—no massive in-memory buffers.
6. Q&As
Why "Code Only, No Repo"?
- Hosting your own modules should be easy!
- Go actually prefers if you do not use a VCS!
- Many modules use GitHub which imposes its own requirements on code ingeneral. You don't fully own it.
- Many CI/CD tasks only need the actual code—commits, branches, and full Git history are unnecessary overhead.
Does it replace standard Git usage entirely?
Not exactly. We rely on Git under the hood, but CONR automates and abstracts the process of checking out tags, filtering, and archiving the code.
How does this compare to gopack or similar tools?
Some existing tools like gopack also offer packaging functionalities. The key differences with CONR are:
- Ephemeral Clones and Tag Filtering: CONR automatically clones your repo in a temp directory for each run, enumerates all
v*tags, and applies flexible--include/--excludepatterns. - Built-In Module Structure: CONR expects to produce valid Go module zips with
.modand.infofiles, plus version lists and@latestpointers, mirroring the Go proxy layout. - Interface Approach: Our design accommodates multiple version control systems, concurrency, and advanced skipping logic. While gopack might handle smaller or straightforward module builds, CONR aims to be more flexible for large or multi-repo environments.