mirror of
https://github.com/F1bonacc1/process-compose.git
synced 2024-08-16 23:10:26 +03:00
Added version command - prints process-compose version and build info
This commit is contained in:
parent
00a321125e
commit
0f168946c7
@ -29,7 +29,11 @@ builds:
|
||||
goarch: arm
|
||||
dir: src
|
||||
ldflags:
|
||||
- -X github.com/f1bonacc1/process-compose/src/config.Version={{.Tag}} -X github.com/f1bonacc1/process-compose/src/config.CheckForUpdates=true -s -w
|
||||
- -X github.com/f1bonacc1/process-compose/src/config.Version={{.Tag}}
|
||||
- -X github.com/f1bonacc1/process-compose/src/config.CheckForUpdates=true
|
||||
- -X github.com/f1bonacc1/process-compose/src/config.Commit={{.ShortCommit}}
|
||||
- -X github.com/f1bonacc1/process-compose/src/config.Date={{.Date}}
|
||||
- -s -w
|
||||
archives:
|
||||
- replacements:
|
||||
darwin: Darwin
|
||||
|
13
Makefile
13
Makefile
@ -1,11 +1,16 @@
|
||||
NAME=process-compose
|
||||
RM=rm
|
||||
VERSION = $(shell git describe --abbrev=0)
|
||||
GIT_REV ?= $(shell git rev-parse --short HEAD)
|
||||
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
NUMVER = $(shell echo ${VERSION} | cut -d"v" -f 2)
|
||||
PKG = github.com/f1bonacc1/process-compose
|
||||
PKG = github.com/f1bonacc1/${NAME}
|
||||
SHELL := /bin/bash
|
||||
LD_FLAGS := -ldflags="-X ${PKG}/src/config.Version=${VERSION} -X ${PKG}/src/config.CheckForUpdates=true -s -w"
|
||||
|
||||
LD_FLAGS := -ldflags="-X ${PKG}/src/config.Version=${VERSION} \
|
||||
-X ${PKG}/src/config.CheckForUpdates=true \
|
||||
-X ${PKG}/src/config.Commit=${GIT_REV} \
|
||||
-X ${PKG}/src/config.Date=${DATE} \
|
||||
-s -w"
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXT=.exe
|
||||
RM = cmd /C del /Q /F
|
||||
@ -58,3 +63,5 @@ clean:
|
||||
release:
|
||||
source exports
|
||||
goreleaser release --rm-dist --skip-validate
|
||||
snapshot:
|
||||
goreleaser release --snapshot --rm-dist
|
||||
|
20
default.nix
20
default.nix
@ -1,10 +1,18 @@
|
||||
{ buildGoModule, config, lib, pkgs, installShellFiles, version ? "latest" }:
|
||||
{ buildGoModule, config, lib, pkgs, installShellFiles, date, commit }:
|
||||
|
||||
buildGoModule {
|
||||
buildGoModule rec {
|
||||
pname = "process-compose";
|
||||
version = version;
|
||||
version = "0.29.1";
|
||||
pkg = "github.com/f1bonacc1/process-compose/src/config";
|
||||
|
||||
src = ./.;
|
||||
ldflags = [ "-X github.com/f1bonacc1/process-compose/src/config.Version=v${version} -s -w" ];
|
||||
ldflags = [
|
||||
"-X ${pkg}.Version=v${version}"
|
||||
"-X ${pkg}.Date=${date}"
|
||||
"-X ${pkg}.Commit=${commit}"
|
||||
"-s"
|
||||
"-w"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
|
||||
@ -21,9 +29,9 @@ buildGoModule {
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description =
|
||||
"Process Compose is like docker-compose, but for orchestrating a suite of processes, not containers.";
|
||||
description = "A simple and flexible scheduler and orchestrator to manage non-containerized applications";
|
||||
homepage = "https://github.com/F1bonacc1/process-compose";
|
||||
changelog = "https://github.com/F1bonacc1/process-compose/releases/tag/v${version}";
|
||||
license = licenses.asl20;
|
||||
mainProgram = "process-compose";
|
||||
};
|
||||
|
@ -16,7 +16,9 @@
|
||||
in {
|
||||
overlays.default = final: prev: {
|
||||
process-compose = final.callPackage ./default.nix {
|
||||
version = self.shortRev or "dirty";
|
||||
#version = self.shortRev or "dirty";
|
||||
date = self.lastModifiedDate;
|
||||
commit = self.shortRev or "dirty";
|
||||
};
|
||||
};
|
||||
overlay = self.overlays.default;
|
||||
|
30
src/cmd/version.go
Normal file
30
src/cmd/version.go
Normal file
@ -0,0 +1,30 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/f1bonacc1/process-compose/src/config"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// versionCmd represents the version command
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print version and build info",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
printVersion()
|
||||
},
|
||||
}
|
||||
|
||||
func printVersion() {
|
||||
format := "%-15s %s\n"
|
||||
fmt.Println("Process Compose")
|
||||
fmt.Printf(format, "Version:", config.Version)
|
||||
fmt.Printf(format, "Commit:", config.Commit)
|
||||
fmt.Printf(format, "Date (UTC):", config.Date)
|
||||
fmt.Printf(format, "License:", config.License)
|
||||
fmt.Println("\nWritten by Eugene Berger")
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
@ -9,8 +9,13 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var Version = "undefined"
|
||||
var CheckForUpdates = "false"
|
||||
var (
|
||||
Version = "undefined"
|
||||
Commit = "undefined"
|
||||
Date = "undefined"
|
||||
CheckForUpdates = "false"
|
||||
License = "Apache-2.0"
|
||||
)
|
||||
|
||||
const (
|
||||
pcConfigEnv = "PROC_COMP_CONFIG"
|
||||
|
Loading…
Reference in New Issue
Block a user