Change versioning to use git commits counts instead of semver
- less work for me - more frequent releases
This commit is contained in:
16
.github/workflows/release.yml
vendored
16
.github/workflows/release.yml
vendored
@@ -2,8 +2,8 @@ name: goreleaser
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches:
|
||||||
- '*'
|
- main
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -20,14 +20,18 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
|
|
||||||
|
- name: Get commit count
|
||||||
|
id: get_commit_count
|
||||||
|
run: echo "COMMIT_COUNT=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v6
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
# either 'goreleaser' (default) or 'goreleaser-pro'
|
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
# 'latest', 'nightly', or a semver
|
version: latest
|
||||||
version: '~> v2'
|
args: release --clean --snapshot
|
||||||
args: release --clean
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GORELEASER_CURRENT_TAG: v${{ steps.get_commit_count.outputs.COMMIT_COUNT }}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
|
release:
|
||||||
|
name_template: "v{{.Env.GORELEASER_CURRENT_TAG}}"
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- env:
|
- env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
|||||||
14
Makefile
14
Makefile
@@ -2,6 +2,16 @@
|
|||||||
APP_NAME = llama-swap
|
APP_NAME = llama-swap
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build
|
||||||
|
|
||||||
|
# Get the current Git hash
|
||||||
|
GIT_HASH := $(shell git rev-parse --short HEAD)
|
||||||
|
ifneq ($(shell git status --porcelain),)
|
||||||
|
# There are untracked changes
|
||||||
|
GIT_HASH := $(GIT_HASH)+
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Get the build number from the commit count on the main branch
|
||||||
|
COMMIT_COUNT := $(shell git rev-list --count HEAD)
|
||||||
|
|
||||||
# Default target: Builds binaries for both OSX and Linux
|
# Default target: Builds binaries for both OSX and Linux
|
||||||
all: mac linux simple-responder
|
all: mac linux simple-responder
|
||||||
|
|
||||||
@@ -18,12 +28,12 @@ test-all:
|
|||||||
# Build OSX binary
|
# Build OSX binary
|
||||||
mac:
|
mac:
|
||||||
@echo "Building Mac binary..."
|
@echo "Building Mac binary..."
|
||||||
GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(APP_NAME)-darwin-arm64
|
GOOS=darwin GOARCH=arm64 go build -ldflags="-X main.GIT_HASH=${GIT_HASH} -X main.COMMIT_COUNT=${COMMIT_COUNT}" -o $(BUILD_DIR)/$(APP_NAME)-darwin-arm64
|
||||||
|
|
||||||
# Build Linux binary
|
# Build Linux binary
|
||||||
linux:
|
linux:
|
||||||
@echo "Building Linux binary..."
|
@echo "Building Linux binary..."
|
||||||
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(APP_NAME)-linux-amd64
|
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.GIT_HASH=${GIT_HASH} -X main.COMMIT_COUNT=${COMMIT_COUNT}" -o $(BUILD_DIR)/$(APP_NAME)-linux-amd64
|
||||||
|
|
||||||
# for testing proxy.Process
|
# for testing proxy.Process
|
||||||
simple-responder:
|
simple-responder:
|
||||||
|
|||||||
@@ -9,13 +9,23 @@ import (
|
|||||||
"github.com/mostlygeek/llama-swap/proxy"
|
"github.com/mostlygeek/llama-swap/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// see Makefile which injects new values at build time
|
||||||
|
var GIT_HASH string = "abcd1234"
|
||||||
|
var COMMIT_COUNT string = "0-dev"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Define a command-line flag for the port
|
// Define a command-line flag for the port
|
||||||
configPath := flag.String("config", "config.yaml", "config file name")
|
configPath := flag.String("config", "config.yaml", "config file name")
|
||||||
listenStr := flag.String("listen", ":8080", "listen ip/port")
|
listenStr := flag.String("listen", ":8080", "listen ip/port")
|
||||||
|
showVersion := flag.Bool("version", false, "show version of build")
|
||||||
|
|
||||||
flag.Parse() // Parse the command-line flags
|
flag.Parse() // Parse the command-line flags
|
||||||
|
|
||||||
|
if *showVersion {
|
||||||
|
fmt.Printf("version: v%s (%s)\n", COMMIT_COUNT, GIT_HASH)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
config, err := proxy.LoadConfig(*configPath)
|
config, err := proxy.LoadConfig(*configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error loading config: %v\n", err)
|
fmt.Printf("Error loading config: %v\n", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user