Skip to content

Commit

Permalink
New release.
Browse files Browse the repository at this point in the history
- Fixed cross-compiling for releases.
- Made version and basename compile-time injections.
  • Loading branch information
jason-dour committed Aug 17, 2022
1 parent e79a60c commit 037ace1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.tar.gz
.hugo-preproc.yaml
hugo-preproc
hugo-preproc_v*
38 changes: 12 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,36 @@ RM := rm -f

MAKEFILE = $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))

MODULE = $(shell awk '/module/{print $$2}' go.mod)
BASENAME = $(lastword $(subst /, , $(MODULE)))
VERSION = $(shell cat VERSION)
LDFLAGS = "-X $(MODULE)/cmd.version=$(VERSION) -X $(MODULE)/cmd.basename=$(BASENAME)"

all: build

.PHONY: all

build:
@go build

@go build -ldflags $(LDFLAGS)
.PHONY: build

windows:
@GOOS=windows
@GOARCH=386
@go build -o hugo-preproc.exe
@zip -9 hugo-preproc.32bit.windows.zip hugo-preproc.exe
@$(RM) hugo-preproc.exe
@GOARCH=amd64
@go build -o hugo-preproc.exe
@zip -9 hugo-preproc.64bit.windows.zip hugo-preproc.exe
@$(RM) hugo-preproc.exe
@env GOOS=windows GOARCH=386 go build -ldflags $(LDFLAGS) -o $(BASENAME)_v$(VERSION)_win32_x32.exe
@env GOOS=windows GOARCH=amd64 go build -ldflags $(LDFLAGS) -o $(BASENAME)_v$(VERSION)_win32_x64.exe
.PHONY: windows

linux:
@GOOS=linux
@GOARCH=386
@go build -o hugo-preproc
@tar -zcf hugo-preproc.32bit.linux.tar.gz hugo-preproc
@$(RM) hugo-preproc
@GOARCH=amd64
@go build -o hugo-preproc
@tar -zcf hugo-preproc.64bit.linux.tar.gz hugo-preproc
@$(RM) hugo-preproc
@env GOOS=linux GOARCH=386 go build -ldflags $(LDFLAGS) -o $(BASENAME)_v$(VERSION)_x32_linux
@env GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS) -o $(BASENAME)_v$(VERSION)_x64_linux
.PHONY: linux

macos:
@GOOS=darwin
@GOARCH=amd64
@go build -o hugo-preproc
@tar -zcf hugo-preproc.64bit.macos.tar.gz hugo-preproc
@$(RM) hugo-preproc
@env GOOS=darwin GOARCH=amd64 go build -ldflags $(LDFLAGS) -o $(BASENAME)_v$(VERSION)_darwin_x64
.PHONY: macos

release: windows linux macos
.PHONY: release

clean:
@$(RM) *.zip *.tar.gz hugo-preproc
@$(RM) $(BASENAME) $(BASENAME).v*
.PHONY: clean
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2.0
11 changes: 9 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ type Configs struct {
}

var (
// version - the version of the program; injected at compile time.
version string

// basename - the basename of the program; injected at compile time.
basename string

// Variable to process the YAML config into.
configs Configs

Expand All @@ -71,11 +77,12 @@ var (

// Cobra definition.
rootCmd = &cobra.Command{
Use: "hugo-preproc",
Use: basename,
Short: "A preprocessor for Hugo",
Long: `Hugo-preproc is a pre-processor for Hugo that allows for
configured processors to be run on the Hugo datafiles.`,
Run: func(cmd *cobra.Command, args []string) { run() },
Run: func(cmd *cobra.Command, args []string) { run() },
Version: version,
}

// Map in the additional functions for the template.
Expand Down

0 comments on commit 037ace1

Please sign in to comment.