Use git tag as version

This commit is contained in:
Emmm Monster 2021-05-16 12:30:48 +08:00
parent c1c43d2a41
commit 9cf42af251
No known key found for this signature in database
GPG Key ID: C98279C83FB50DB9
2 changed files with 10 additions and 6 deletions

View File

@ -22,11 +22,11 @@ jobs:
os: [ windows-latest, ubuntu-latest, macos-latest ]
include:
- os: ubuntu-latest
BIN_SUFFIX:
BIN_SUFFIX: ""
- os: macos-latest
BIN_SUFFIX:
BIN_SUFFIX: ""
- os: windows-latest
BIN_SUFFIX: .exe
BIN_SUFFIX: ".exe"
steps:
- name: Checkout codebase
uses: actions/checkout@v2
@ -38,12 +38,14 @@ jobs:
- name: Setup vars
id: vars
run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
run: |
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
echo "::set-output name=git_tag::$(git describe --tags)"
- name: Build
env:
CGO_ENABLED: 0
run: go build -trimpath -ldflags="-w -s" -v -o um-${{ runner.os }}${{ matrix.BIN_SUFFIX }} ./cmd/um
run: go build -trimpath -ldflags="-w -s -X main.AppVersion=${{ steps.vars.outputs.git_tag }}" -v -o um-${{ runner.os }}${{ matrix.BIN_SUFFIX }} ./cmd/um
- name: Publish artifact
uses: actions/upload-artifact@v2

View File

@ -18,12 +18,14 @@ import (
"strings"
)
var AppVersion = "0.0.3"
func main() {
app := cli.App{
Name: "Unlock Music CLI",
HelpName: "um",
Usage: "Unlock your encrypted music file https://github.com/unlock-music/cli",
Version: "v0.0.1",
Version: AppVersion,
Flags: []cli.Flag{
&cli.StringFlag{Name: "input", Aliases: []string{"i"}, Usage: "path to input file or dir", Required: true},
&cli.StringFlag{Name: "output", Aliases: []string{"o"}, Usage: "path to output dir", Required: true},