diff --git a/Makefile b/Makefile index c11e06f..7b7cdf2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PROG = govpp-snmp-agentx -.PHONY: build test clean pkg-deb +.PHONY: build test clean pkg-deb sync-version # Build the binary build: @@ -17,6 +17,13 @@ clean: rm -rf debian/.debhelper debian/.gocache debian/go debian/$(PROG) debian/files debian/*.substvars debian/debhelper-build-stamp rm -f ../$(PROG)_*.deb ../$(PROG)_*.changes ../$(PROG)_*.buildinfo +# Sync version from debian/changelog to main.go +sync-version: + @echo "Syncing version from debian/changelog to main.go..." + @VERSION=$$(head -1 debian/changelog | sed -n 's/.*(\([^)]*\)).*/\1/p'); \ + sed -i 's/^const Version = ".*"/const Version = "'"$$VERSION"'"/' src/main.go; \ + echo "Updated Version const to: $$VERSION" + # Build Debian package -pkg-deb: +pkg-deb: sync-version fakeroot dpkg-buildpackage -us -uc -b diff --git a/debian/changelog b/debian/changelog index 1797883..6a0ea11 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +govpp-snmp-agentx (1.1.2-1) bookworm; urgency=medium + + * Add startup version logging to INFO log level + * Implement automatic version synchronization between debian/changelog and main.go + * Add make sync-version target for manual version syncing + * Ensure version consistency across package and application code + + -- Pim van Pelt Sun, 23 Jun 2025 00:20:00 +0000 + govpp-snmp-agentx (1.1.1-1) bookworm; urgency=medium * Add IF-MIB::ifHighSpeed field (OID 1.3.6.1.2.1.31.1.1.1.15) diff --git a/docs/DETAILS.md b/docs/DETAILS.md index 73aee9b..e62f1d6 100644 --- a/docs/DETAILS.md +++ b/docs/DETAILS.md @@ -244,6 +244,62 @@ snmpwalk -v2c -c public localhost 1.3.6.1.2.1.1 snmpwalk -v2c -c public localhost 1.3.6.1.2.1.31.1.1.1 ``` +## Building and Releasing + +### Build Targets + +The project uses a Makefile with the following targets: + +```bash +# Build the binary +make build + +# Run tests +make test + +# Clean build artifacts +make clean + +# Sync version from debian/changelog to main.go +make sync-version + +# Build Debian package (includes automatic version sync) +make pkg-deb +``` + +### Release Process + +To cut a new release, follow these steps in order: + +1. **Update debian/changelog** with the new version and changelog entries: + ```bash + # Edit debian/changelog manually + vim debian/changelog + ``` + +2. **Sync version to main.go**: + ```bash + make sync-version + ``` + +3. **Build the package**: + ```bash + make pkg-deb + ``` + +4. **Commit all changes together**: + ```bash + git add debian/changelog src/main.go + git commit -m "Cut release X.Y.Z-A" + git tag vX.Y.Z-A + ``` + +### Version Synchronization + +The build system automatically ensures that the version in `debian/changelog` matches the version constant in `src/main.go`. The `make pkg-deb` target automatically calls `make sync-version` before building to maintain consistency. + +**Important**: Always update `debian/changelog` first, as this is the authoritative source for the version number. The `make sync-version` target extracts the version from the first line of the changelog and updates the `Version` constant in `src/main.go`. + ## License This project uses the LGPL 3.0 licensed go-agentx library. It has been modified due to a bug, diff --git a/src/main.go b/src/main.go index 75e977d..c40dd7b 100644 --- a/src/main.go +++ b/src/main.go @@ -16,6 +16,8 @@ import ( "govpp-snmp-agentx/vpp" ) +const Version = "1.1.2-1" + func main() { debug := flag.Bool("debug", false, "Enable debug logging") vppcfg := flag.String("vppcfg", "", "VPP configuration YAML file to read interface descriptions from") @@ -24,6 +26,9 @@ func main() { // Set global debug flag config.Debug = *debug + // Log startup message with version + logger.Printf("Starting govpp-snmp-agentx version %s", Version) + // Create the interface MIB interfaceMIB := ifmib.NewInterfaceMIB()