https://github.com/zc2638/releaser
A tool for Golang programs that automatically generate versions at build time.
https://github.com/zc2638/releaser
autoversion version version-control
Last synced: 4 months ago
JSON representation
A tool for Golang programs that automatically generate versions at build time.
- Host: GitHub
- URL: https://github.com/zc2638/releaser
- Owner: zc2638
- License: apache-2.0
- Created: 2022-02-25T10:34:45.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-16T03:02:24.000Z (over 3 years ago)
- Last Synced: 2024-06-21T19:58:12.244Z (almost 2 years ago)
- Topics: autoversion, version, version-control
- Language: Go
- Homepage:
- Size: 126 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# releaser
A tool for Golang programs that automatically generate versions at build time.
## Quick Start
### Use in direct
```shell
go build -ldflags="-X github.com/zc2638/releaser.ver=0.0.1" main.go
```
### Use in rely
#### 1. Code import
```go
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
```shell
go build -ldflags="-X $(releaser get)" main.go
```
## Install
### Install from source
```shell
go install -v github.com/zc2638/releaser/cmd/releaser@latest
```
### Install from Docker
```shell
docker run --rm -it zc2638/releaser:latest
```
### Build from source
#### 1. Clone
```shell
git clone https://github.com/zc2638/releaser.git releaser && cd "$_"
```
#### 2. Build
```shell
go build -ldflags="-X $(go run github.com/zc2638/releaser/cmd get)" -o releaser github.com/zc2638/releaser/cmd
```
## Commands
### init project
```shell
releaser init
```
### create service
```shell
releaser create
```
### set
#### use for project
```shell
releaser set --version 1.0.0 --meta status=ok --meta repo=github
```
#### use for service
```shell
releaser set --version 1.0.0 --meta status=ok --meta repo=github
```
### get
#### use for project
```shell
# 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
```shell
# 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
```
### delete
```shell
releaser delete
```
### walk
```shell
releaser walk --command 'echo "$name $version $meta_status"'
```