Better git versioning

This commit is contained in:
Tony Garnock-Jones 2022-07-25 16:45:41 +02:00
parent 3db9835b85
commit f91214d1b0
16 changed files with 48 additions and 12 deletions

22
packaging/gitversion Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
import subprocess
import sys
import time
def x(cmd):
return subprocess.check_output(cmd, shell=True)
uncommitted = x('git status --porcelain=v1 -- .')
dirty = len(uncommitted) > 0
if dirty:
commithash = x('git --no-pager log -n 1 --pretty=tformat:"%h" -- .').strip()
timestamp = int(time.time())
else:
(commithash, timestamp) = x('git --no-pager log -n 1 --pretty=tformat:"%h %ct" -- .').strip().split()
timestamp = int(timestamp)
commithash = commithash.decode('utf-8')
timestamp = time.strftime("%Y%m%d%H%M%S", time.gmtime(timestamp))
print(f'_git{timestamp}')

View File

@ -1,3 +1,4 @@
GITVERSION
VERSION
buildlog.*
preserves-tool.aarch64

View File

@ -1,8 +1,8 @@
# Contributor: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
pkgname=preserves-tools
pkgver=$(cat VERSION)
pkgrel=$(date '+%Y%m%d%H%M%S')
pkgver=$(cat VERSION)$(cat GITVERSION)
pkgrel=0
pkgdesc="Command-line tools for working with Preserves documents"
url="https://preserves.dev/"
arch="all"

View File

@ -9,6 +9,8 @@ prepare: preserves miniclean
| preserves-tool convert --output-format unquoted \
--select '. "packages" / [. "name" = "preserves-tools"] . "version"' \
> VERSION
rm -f preserves/implementations/rust/rust-toolchain
(cd preserves; ../../../gitversion) > GITVERSION
preserves:
git clone https://gitlab.com/preserves/preserves

View File

@ -1,3 +1,4 @@
GITVERSION
VERSION
buildlog.*
protocols/

View File

@ -1,8 +1,8 @@
# Contributor: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
pkgname=syndicate-server
pkgver=$(cat VERSION)
pkgrel=$(date '+%Y%m%d%H%M%S')
pkgver=$(cat VERSION)$(cat GITVERSION)
pkgrel=0
pkgdesc="Syndicate server"
url="https://syndicate-lang.org/"
arch="all"

View File

@ -8,6 +8,7 @@ prepare: syndicate-rs miniclean
--select '. "packages" / [. "name" = "syndicate-server"] . "version"' \
> VERSION
rsync -a syndicate-rs/syndicate-server/protocols .
(cd syndicate-rs; ../../../gitversion) > GITVERSION
syndicate-rs:
git clone https://git.syndicate-lang.org/syndicate-lang/syndicate-rs

View File

@ -1,2 +1,3 @@
GITVERSION
protocols/
__pycache__/

View File

@ -1,10 +1,8 @@
# Contributor: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
pkgname=synit-config
pkgver=0.0.6
pkgrel=$(date '+%Y%m%d%H%M%S')
# pkgver=0.0.5
# pkgrel=1
pkgver=0.0.6$(cat GITVERSION)
pkgrel=0
pkgdesc="synit system layer configuration"
url="https://synit.org/"
arch="noarch"

View File

@ -2,6 +2,7 @@
prepare:
rsync -a ../../../protocols .
../../gitversion > GITVERSION
clean:
rm -rf protocols

View File

@ -1,3 +1,4 @@
GITVERSION
VERSION
buildlog.*
synit-pid1.aarch64

View File

@ -1,8 +1,8 @@
# Contributor: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
pkgname=synit-pid1
pkgver=$(cat VERSION)
pkgrel=$(date '+%Y%m%d%H%M%S')
pkgver=$(cat VERSION)$(cat GITVERSION)
pkgrel=0
pkgdesc="synit pid 1 program"
url="https://synit.org/"
arch="all"

View File

@ -6,6 +6,7 @@ prepare: miniclean
(cd ../../../synit-pid1 && cargo metadata --format-version 1) | \
preserves-tool convert --output-format unquoted \
--select '. "packages" / [. "name" = "synit-pid1"] . "version"' > VERSION
(cd ../../../synit-pid1; ../packaging/gitversion) > GITVERSION
miniclean:
rm -f synit-pid1.$(ARCH)

View File

@ -0,0 +1 @@
GITVERSION

View File

@ -1,8 +1,8 @@
# Contributor: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
pkgname=synit-splash
pkgver=0.0.1
pkgrel=5
pkgver=0.0.2$(cat GITVERSION)
pkgrel=0
pkgdesc="synit loading splash screen"
url="https://synit.org/"
arch="noarch"

View File

@ -0,0 +1,6 @@
# -*- makefile -*-
prepare:
../../gitversion > GITVERSION
clean: