Skip to content

Commit

Permalink
fix: Date versions on UTC commit time, not build time
Browse files Browse the repository at this point in the history
This is important so that package versions only advance when the sources
have changed, i.e. we only produce "new" packages if there is in fact
new content, which in turn prevents update churn when versions only go
up when there's something new.
  • Loading branch information
jinnatar committed Oct 12, 2024
1 parent 2da3f33 commit 62862e6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/build_debs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ git config --global --add safe.directory "$PWD"
GIT_HEAD="$(git rev-parse HEAD)"

KANIDM_VERSION="$(grep -ioE 'version.*' Cargo.toml | head -n1 | awk '{print $NF}' | tr -d '"' | sed -e 's/-/~/')"
DATESTR="$(date +%Y%m%d%H%M)"
# We read the commit date of the reference rev, feed it to date, format a bit and print in UTC.
# Ergo, the version date field is a unix time representation of when the commit was submitted.
# Unlike commit hashes, this is a sort compatible ever increasing version, but still marginally human readable.
DATESTR="$(date -ud @$(git show --no-patch --format=%ct HEAD) +%Y%m%d%H%M)"
GIT_COMMIT="${GIT_HEAD:0:7}"
DEBIAN_REV="${DATESTR}+${GIT_COMMIT}"
PACKAGE_VERSION="${KANIDM_VERSION}-${DEBIAN_REV}"
Expand Down

0 comments on commit 62862e6

Please sign in to comment.