From 35eb7383b1a1e332ddebccb716f1a86d58dec9f6 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 29 Apr 2021 20:23:47 -0700 Subject: [PATCH] ci: simplify version number Previously, we used `git describe --tags` to produce a version number for non-released builds derived from the most recent tag + some info such as the number of commits since that tag and then `g{HASH}`. That always confuses people because the date portion at the front looks old (it is typically the previous release) and the hash at the end has that `g` in it. This commit simplifies both the tag name used when making a release and the computed version number take the date/time from the current commit, and then append the hash. That way the version number always corresponds to a commit. This scheme doesn't help detect situations where the commit is dirty, but I don't think the old one would have helped with that either. --- ci/appimage.sh | 3 +-- ci/deploy.sh | 3 +-- ci/source-archive.sh | 3 +-- ci/tag.sh | 2 +- config/build.rs | 7 ++++++- wezterm-gui/build.rs | 9 +++++++-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ci/appimage.sh b/ci/appimage.sh index 107734882..2cfbf0201 100755 --- a/ci/appimage.sh +++ b/ci/appimage.sh @@ -13,8 +13,7 @@ install -Dm644 assets/wezterm.appdata.xml AppDir/usr/share/metainfo/org.wezfurlo [ -x /tmp/linuxdeploy ] || ( curl -L 'https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage' -o /tmp/linuxdeploy && chmod +x /tmp/linuxdeploy ) -TAG_NAME=${TAG_NAME:-$(git describe --tags --match '20*')} -TAG_NAME=${TAG_NAME:-$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1)} +TAG_NAME=${TAG_NAME:-$(git show -s "--format=%cd-%h" "--date=format:%Y%m%d-%H%M%S")} distro=$(lsb_release -is) distver=$(lsb_release -rs) diff --git a/ci/deploy.sh b/ci/deploy.sh index 2500c019d..2ebb2cca5 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -4,8 +4,7 @@ set -e TARGET_DIR=${1:-target} -TAG_NAME=${TAG_NAME:-$(git describe --tags --match '20*')} -TAG_NAME=${TAG_NAME:-$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1)} +TAG_NAME=${TAG_NAME:-$(git show -s "--format=%cd-%h" "--date=format:%Y%m%d-%H%M%S")} HERE=$(pwd) diff --git a/ci/source-archive.sh b/ci/source-archive.sh index b1c48441d..f35c0700b 100755 --- a/ci/source-archive.sh +++ b/ci/source-archive.sh @@ -3,8 +3,7 @@ set -x -TAG_NAME=${TAG_NAME:-$(git describe --tags --match '20*')} -TAG_NAME=${TAG_NAME:-$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1)} +TAG_NAME=${TAG_NAME:-$(git show -s "--format=%cd-%h" "--date=format:%Y%m%d-%H%M%S")} if [[ "$BUILD_REASON" == "Schedule" ]] ; then TAR_NAME=wezterm-nightly-src.tar diff --git a/ci/tag.sh b/ci/tag.sh index 03a45d2f0..0f7578d21 100755 --- a/ci/tag.sh +++ b/ci/tag.sh @@ -1,4 +1,4 @@ #!/bin/bash -TAGNAME=$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1) +TAGNAME=$(git show -s "--format=%cd-%h" "--date=format:%Y%m%d-%H%M%S") git tag $TAGNAME diff --git a/config/build.rs b/config/build.rs index 35becffbf..ced2b47e2 100644 --- a/config/build.rs +++ b/config/build.rs @@ -61,7 +61,12 @@ fn main() { let head = head.canonicalize().unwrap(); println!("cargo:rerun-if-changed={}", head.display()); if let Ok(output) = std::process::Command::new("git") - .args(&["describe", "--tags", "--match", "20*"]) + .args(&[ + "show", + "-s", + "--format=%cd-%h", + "--date=format:%Y%m%d-%H%M%S", + ]) .output() { let info = String::from_utf8_lossy(&output.stdout); diff --git a/wezterm-gui/build.rs b/wezterm-gui/build.rs index f2c27c196..24d150ad1 100644 --- a/wezterm-gui/build.rs +++ b/wezterm-gui/build.rs @@ -68,12 +68,17 @@ fn main() { if let Ok(tag) = std::fs::read("../.tag") { if let Ok(s) = String::from_utf8(tag) { ci_tag = s.trim().to_string(); - println!("cargo:rerun-if-changed=.tag"); + println!("cargo:rerun-if-changed=../.tag"); } } let version = if ci_tag.is_empty() { let mut cmd = std::process::Command::new("git"); - cmd.args(&["describe", "--tags"]); + cmd.args(&[ + "show", + "-s", + "--format=%cd-%h", + "--date=format:%Y%m%d-%H%M%S", + ]); if let Ok(output) = cmd.output() { if output.status.success() { String::from_utf8_lossy(&output.stdout).trim().to_owned()