Skip to content

Commit

Permalink
Packaging: New version string on the form: '7.1.0-1+11+g2b25294`
Browse files Browse the repository at this point in the history
Deb packages as artifacts in github actions
  • Loading branch information
olofhagsand committed Oct 18, 2024
1 parent 1270bfe commit 3b5b1b4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Expected: October 2024

### Features

* Packaging
* New version string on the form: '7.1.0-1+11+g2b25294`
* Deb packages as artifacts in github actions
* New: [CLI simple alias](https://github.com/clicon/cligen/issues/112)

### Corrected Bugs
Expand Down
9 changes: 2 additions & 7 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ else
all: $(MYSTATIC)
endif

.PHONY: TAGS test
.PHONY: TAGS test write_version
TAGS:
find . -name '*.[chyl]' -print | xargs etags

Expand All @@ -125,12 +125,7 @@ test:
(cd test && SKIPLIST="$(SKIPLIST)" CFLAGS="$(CFLAGS)" LINKAGE="$(LINKAGE)" ./all.sh)

write_version:
$(eval CI_VERSION_FULL=$(shell git describe --tags $(git rev-list --tags --max-count=1)))
$(eval CI_VERSION_MAJOR=$(shell echo $(CI_VERSION_FULL) | cut -d . -f1))
$(eval CI_VERSION_MINOR=$(shell echo $(CI_VERSION_FULL) | cut -d . -f2))
$(eval CI_VERSION_FIX=$(shell echo $(CI_VERSION_FULL) | cut -d . -f3 | cut -d '_' -f1))
@echo version: ${CI_VERSION_MAJOR}.${CI_VERSION_MINOR}.${CI_VERSION_FIX}
@echo "${CI_VERSION_MAJOR}.${CI_VERSION_MINOR}.${CI_VERSION_FIX}" > version
@echo $(shell PREFIX=cligen ./version.sh)

distclean: clean
rm -f Makefile config.log config.status config.h TAGS .depend
Expand Down
9 changes: 5 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2506,10 +2506,11 @@ ac_config_headers="$ac_config_headers cligen_config.h"


# Use GIT version (what if no git?)
CLIGEN_VERSION="$(git log --pretty="format:%(describe) %ci" -n1)"
CLIXON_VERSION_MAJOR="7"
CLIXON_VERSION_MINOR="1"
CLIXON_VERSION_PATCH="0"
CLIGEN_VERSION="$(./version.sh)"
CLIGEN_VERSION2=$(echo ${CLIGEN_VERSION} | awk -F- '{print $1}')
CLIGEN_VERSION_MAJOR=$(echo ${CLIGEN_VERSION2} | awk -F. '{print $1}')
CLIGEN_VERSION_MINOR=$(echo ${CLIGEN_VERSION2} | awk -F. '{print $2}')
CLIGEN_VERSION_PATCH=$(echo ${CLIGEN_VERSION2} | awk -F. '{print $3}')

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: CLIGEN version is $CLIGEN_VERSION" >&5
printf "%s\n" "CLIGEN version is $CLIGEN_VERSION" >&6; }
Expand Down
9 changes: 5 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ AC_SUBST(CLIGEN_VERSION_MINOR)
AC_SUBST(CLIGEN_VERSION_PATCH)

# Use GIT version (what if no git?)
CLIGEN_VERSION="$(git log --pretty="format:%(describe) %ci" -n1)"
CLIXON_VERSION_MAJOR="7"
CLIXON_VERSION_MINOR="1"
CLIXON_VERSION_PATCH="0"
CLIGEN_VERSION="$(./version.sh)"
CLIGEN_VERSION2=$(echo ${CLIGEN_VERSION} | awk -F- '{print $1}')
CLIGEN_VERSION_MAJOR=$(echo ${CLIGEN_VERSION2} | awk -F. '{print $1}')
CLIGEN_VERSION_MINOR=$(echo ${CLIGEN_VERSION2} | awk -F. '{print $2}')
CLIGEN_VERSION_PATCH=$(echo ${CLIGEN_VERSION2} | awk -F. '{print $3}')

AC_MSG_RESULT(CLIGEN version is $CLIGEN_VERSION)

Expand Down
41 changes: 41 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Version script
# Usage:
# ./version.sh
# with optional fields:
# PREFIX= INDEX=1 ARCH= SUFFIX=
# Example:
# PREFIX=cligen INDEX=1 ARCH=amd64 SUFFIX=deb ./version.sh
set -eu
: ${PREFIX:=}
: ${INDEX=1}
: ${ARCH=}
: ${SUFFIX=}
# Get version string from default git describe: <tag>-<nr>-g<hash>
if [ -f .version ]; then
v1=$(cat .version)
else
v1=$(git describe)
fi
if [ -z $v1 ]; then
echo "No base version"
exit 1
fi
TAG=$(echo $v1 | awk -F- '{print $1}')
NR=$(echo $v1 | awk -F- '{print $2}')
HASH=$(echo $v1 | awk -F- '{print $3}')
V=""
if [ -n "$PREFIX" ]; then
V="${V}${PREFIX}_"
fi
V="${V}${TAG}"
V="${V}-${INDEX}"
V="${V}+${NR}"
V="${V}+${HASH}"
if [ -n "$ARCH" ]; then
V="${V}_${ARCH}"
fi
if [ -n "$SUFFIX" ]; then
V="${V}.${SUFFIX}"
fi
echo "${V}"

0 comments on commit 3b5b1b4

Please sign in to comment.