releaser

package module
v0.0.0-...-90fd5b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

README

releaser

A tool for Golang programs that automatically generate versions at build time.

Quick Start

Use in direct
go build -ldflags="-X github.com/zc2638/releaser.ver=0.0.1" main.go
Use in rely
1. Code import
package main

import (
	"fmt"

	"github.com/zc2638/releaser"
)

func main() {
	fmt.Printf("version: %s\n", releaser.Version.String())
	fmt.Printf("gitCommit: %s\n", releaser.Version.Git.Commit)
	fmt.Printf("goVersion: %s\n", releaser.Version.GoVersion)
	fmt.Printf("compiler: %s\n", releaser.Version.Compiler)
	fmt.Printf("platform: %s\n", releaser.Version.Platform)
	fmt.Printf("buildDate: %s\n", releaser.Version.BuildDate)
}
2. Run Build
go build -ldflags="-X $(releaser get)" main.go

Install

Install from source
go install -v github.com/zc2638/releaser/cmd/releaser@latest
Install from Docker
docker run --rm -it zc2638/releaser:latest
Build from source
1. Clone
git clone https://github.com/zc2638/releaser.git releaser && cd "$_"
2. Build
go build -ldflags="-X $(go run github.com/zc2638/releaser/cmd get)" -o releaser github.com/zc2638/releaser/cmd

Commands

init project
releaser init <project name>
create service
releaser create <service name>
set
use for project
releaser set --version 1.0.0 --meta status=ok --meta repo=github
use for service
releaser set <service name> --version 1.0.0 --meta status=ok --meta repo=github
get
use for project
# get build info, output format `gobuild` is default
releaser get [-o gobuild|json]
# get version
releaser get --filter version
# get metadata field value
releaser get --filter meta.status
use for service
# get build info, output format `gobuild` is default
releaser get <service name> [-o gobuild|json]
# get version
releaser get <service name> --filter version
# get metadata field value
releaser get <service name> --filter meta.status
delete
releaser delete <service name>
walk
releaser walk --command 'echo "$name $version $meta_status"'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data string, out interface{}) error

func Encode

func Encode(in interface{}) (string, error)

Types

type VersionEntry

type VersionEntry struct {
	Version   *semver.Version   `json:"version,omitempty" yaml:"version,omitempty"`
	Git       *VersionGit       `json:"git,omitempty" yaml:"git,omitempty"`
	Metadata  map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	BuildDate string            `json:"buildDate,omitempty" yaml:"buildDate,omitempty"`
	GoVersion string            `json:"goVersion,omitempty" yaml:"goVersion,omitempty"`
	Compiler  string            `json:"compiler,omitempty" yaml:"compiler,omitempty"`
	Platform  string            `json:"platform,omitempty" yaml:"platform,omitempty"`
}
var Version *VersionEntry

func (*VersionEntry) Complete

func (ve *VersionEntry) Complete()

func (VersionEntry) String

func (ve VersionEntry) String() string

type VersionGit

type VersionGit struct {
	Branch    string `json:"branch,omitempty" yaml:"branch,omitempty"`
	Commit    string `json:"commit,omitempty" yaml:"commit,omitempty"`
	Tag       string `json:"tag,omitempty" yaml:"tag,omitempty"`
	RecentTag string `json:"recentTag,omitempty" yaml:"recentTag,omitempty"`
}

Directories

Path Synopsis
cmd
pkg
git

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL