Skip to content

Commit

Permalink
Adding a version command
Browse files Browse the repository at this point in the history
  • Loading branch information
oxodao committed Feb 5, 2022
1 parent 5fa492c commit 4a4af44
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: '^1.17.5'
- run: GOOS=linux GOARCH=amd64 go build -o metaprint-${GITHUB_REF##*/}-linux-x86_64 .
- run: GOOS=linux GOARCH=amd64 go build -ldflags="-X main.VERSION=${GITHUB_REF##*/} -X main.COMMIT=${GITHUB_SHA}" -o metaprint-${GITHUB_REF##*/}-linux-x86_64 .
- uses: ncipollo/release-action@v1
with:
artifacts: "metaprint-*-*-*"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
metaprint-DEV-linux-x86_64
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
go build
go build -ldflags="-X main.VERSION=DEV -X main.COMMIT=$(shell git rev-parse HEAD)" -o "metaprint-DEV-$(shell uname | tr '[:upper:]' '[:lower:]')-$(shell uname -m)" .

install: build
sudo mv metaprint /usr/bin
sudo mv metaprint /usr/bin
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package main
import (
"fmt"
"os"
"strings"

"github.com/oxodao/metaprint/config"
"github.com/oxodao/metaprint/pulse"
)

const (
var (
AUTHOR = "Oxodao"
VERSION = "0.3"
VERSION = "0.5"
COMMIT = "XXXXXXXXX"
SOFTWARE_NAME = "metaprint"
)

var otherCommands = []string{"pulseaudio-infos"}
var otherCommands = []string{"pulseaudio-infos", "version"}

func main() {
cfg := config.Load()
Expand All @@ -29,6 +31,9 @@ func main() {
switch os.Args[1] {
case "pulseaudio-infos":
pulse.PrintInfos()
case "version":
fmt.Printf("%v v%v (Commit %v) by %v\nhttps://github.com/%v/%v\n", SOFTWARE_NAME, VERSION, COMMIT, AUTHOR, strings.ToLower(AUTHOR), strings.ToLower(SOFTWARE_NAME))
os.Exit(1)
default:
printUsage()
os.Exit(1)
Expand Down

0 comments on commit 4a4af44

Please sign in to comment.