Skip to content

Commit 0853d37

Browse files
authored
Merge pull request #66 from SasSwart/feature/auto-versioning
Add automatic version tagging to the can binary
2 parents 0f6a89c + 9d17333 commit 0853d37

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Show go version
2121
run: go version
2222
- name: Generate build files
23-
run: make all
23+
run: make VERSION='$GITHUB_REF' all
2424
- name: Release
2525
uses: softprops/action-gh-release@v1
2626
with:

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
APP_GO_FILES := $(shell find . -name '*.go')
1+
VERSION := v0.0.0
22

33
all: linux_amd64.zip
44

@@ -7,8 +7,9 @@ linux_amd64.zip: build/linux_amd64 LICENSE
77

88
build/linux_amd64: build/linux_amd64/can build/linux_amd64/templates
99

10-
build/linux_amd64/can: $(APP_GO_FILES)
11-
go build -o ./build/linux_amd64/ ./cmd/...
10+
build/linux_amd64/can:
11+
echo '${VERSION}' > ./config/version.txt
12+
go build -o ./build/linux_amd64/ ./...
1213

1314
build/linux_amd64/templates:
1415
cp -r templates build/linux_amd64/templates

config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package config
22

33
import (
4+
_ "embed"
45
"flag"
56
"fmt"
67
"github.com/spf13/viper"
78
"os"
89
"path/filepath"
910
)
1011

11-
// SemVer should be updated on any new release!!
12-
const SemVer = "0.0.13"
12+
//go:embed version.txt
13+
var SemVer string
1314

1415
var (
1516
Debug bool

config/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.0.0

0 commit comments

Comments
 (0)