samuong / alpaca

A local HTTP proxy for command-line tools. Supports PAC scripts and NTLM authentication.
Apache License 2.0
184 stars 31 forks source link

FEATURE: Add Version Support #78

Closed rtfmoz2 closed 2 years ago

rtfmoz2 commented 2 years ago

This PR addresses issue #11 - Versioning

Use the following bash script at build time (tested on ubuntu) with the commits provided. This pulls the version number from the git tag on the current repository and injects this into compilation using ldflags.

rtfmoz2 commented 2 years ago

Testing output

rtfmoz@DESKTOP-H138G2U:/mnt/c/Users/Kevin/Projects/alpaca$ sh -x build.sh
+ git describe --tags
+ grep ^v
+ head -1
+ tag=v1.2.0-4-geb0c143
+ semver=1.2.0-4-geb0c143
+ version=1.2.0
+ date
+ go build -ldflags=-X 'main.BuildTime=Sun Apr  3 15:14:32 AEST 2022' -X 'main.BuildVersion=1.2.0'
rtfmoz@DESKTOP-H138G2U:/mnt/c/Users/Kevin/Projects/alpaca$ ./alpaca -v
Alpaca 1.2.0 built at Sun Apr  3 15:14:32 AEST 2022
rtfmoz@DESKTOP-H138G2U:/mnt/c/Users/Kevin/Projects/alpaca$