From db4701d8b54fa1bb980bd24cfe2d1fe446278c6b Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 18 Sep 2021 19:32:12 -0700 Subject: [PATCH] Add a `setgitversion` script to update the version string with git --- .github/workflows/build.yml | 3 +++ setgitversion | 11 +++++++++++ src/ShellCheck/Data.hs | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 setgitversion diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0acece2..e28a43f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,9 +16,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Package Source run: | + ./setgitversion mkdir source cabal sdist mv dist-newstyle/sdist/*.tar.gz source/source.tar.gz diff --git a/setgitversion b/setgitversion new file mode 100755 index 0000000..3afad61 --- /dev/null +++ b/setgitversion @@ -0,0 +1,11 @@ +#!/bin/sh -xe +# This script hardcodes the `git describe` version as ShellCheck's version number. +# This is done to allow shellcheck --version to differ from the cabal version when +# building git snapshots. + +file="src/ShellCheck/Data.hs" +test -e "$file" +tmp=$(mktemp) +version=$(git describe) +sed -e "s/=.*VERSIONSTRING.*/= \"$version\" -- VERSIONSTRING, DO NOT SUBMIT/" "$file" > "$tmp" +mv "$tmp" "$file" diff --git a/src/ShellCheck/Data.hs b/src/ShellCheck/Data.hs index fb4a1e4..793a4de 100644 --- a/src/ShellCheck/Data.hs +++ b/src/ShellCheck/Data.hs @@ -4,7 +4,7 @@ import ShellCheck.Interface import Data.Version (showVersion) import Paths_ShellCheck (version) -shellcheckVersion = showVersion version +shellcheckVersion = showVersion version -- VERSIONSTRING internalVariables = [ -- Generic