Skip to content

Commit

Permalink
generate version using git describe
Browse files Browse the repository at this point in the history
- remove SWISH_VERSION from configure and swish.h
- use `git describe` to determine the semver-compatible version.

This helps to ensure that we can easily distinguish the version shown
for a released build from versions shown for other builds beyond a
release tag. The earlier practice of bumping the version in a separate
commit after each release was not strong enough. This also allows for
greater flexibility in branching, even when the final release
type (minor or patch) is unknown.
  • Loading branch information
payneca authored and owaddell-ib committed Dec 11, 2024
1 parent cab8a76 commit 8777b4f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ jobs:
run: git config --global core.autocrlf false
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# the checkout action wipes the workarea, so do the checkout
# *before* we restore and build Chez Scheme from cache
- name: Restore Chez Scheme .git / boot file cache
Expand Down Expand Up @@ -207,6 +209,7 @@ jobs:
if: ${{ matrix.config.chez != 'main' && !startsWith(matrix.config.machine, 't') }}
# install only the binaries and replace absolute symlinks with relative symlinks
run: |
git fetch --tags
make -C src/swish install-bin INSTALLROOT="${PWD}/build/swish"
for f in $(find build/swish -type l); do
target="$(realpath "$f")"
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ is not thread safe and should be used from the main thread only.
Swish follows the [semantic versioning](http://semver.org/)
scheme, starting with 2.0.0 to avoid confusion with internal projects.

Odd minor-version numbers are used for development. As such,
we are extremely unlikely to use a patch number other than 0 during
development.

Even minor-version numbers are used for official tagged
releases.

The first commit after an official tagged release should increment
either the minor-version or patch-version number so that the version
number for an official tagged release corresponds to a unique commit
hash.

# Notes

1. install the prerequisites (see Build System Requirements)
Expand Down
3 changes: 0 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,6 @@ elif [ "${Windows}" = "no" ]; then
err "Missing Chez Scheme kernel.o or libkernel.a"
fi

SWISH_VERSION=$(sed -n 's/^#define SWISH_VERSION \([0-9a-z."]*\)/\1/p' src/swish/swish.h)

escape_backslash() { printf "%s" "$1" | sed 's_\\_\\\\_g' ; }
ADD_TO=
add() {
Expand Down Expand Up @@ -429,7 +427,6 @@ else
fi
add "SWISH_INCLUDE:=${SWISH_INCLUDE}"
add "SWISH_LIBPATH:=${SWISH_LIBPATH}"
add "SWISH_VERSION:=${SWISH_VERSION}"
add "LIBUV_INCLUDE:=${LIBUV_INCLUDE}"
add "LIBUV_LIBPATH:=${LIBUV_LIBPATH}"
add "SQLITE_SRCPATH:=${SQLITE_SRCPATH}"
Expand Down
1 change: 1 addition & 0 deletions src/swish/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/sqlite3.obj
/swish-revision.include
/swish-version.include
/swish-version.mk
/swish_kernel.o
/test-request.dll
/test-request.dylib
Expand Down
25 changes: 17 additions & 8 deletions src/swish/Mf-base
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ chezscheme-revision.include-changed:
swish-revision.tmp-include:
@git describe --always --match none --abbrev=40 --dirty > "$@"

swish-version.tmp-include: swish.h
@sed -n 's/^#define SWISH_VERSION "\([0-9a-z."]*\)"/\1/p' swish.h > "$@"
swish-version.tmp-include:
@git describe --tags --dirty | sed -E 's/^v//; s/-g[0-9a-f]+//' > "$@"

chezscheme-revision.tmp-include:
@if [ ! -f "${SCHEME_REVISION_PATH}/revision" ]; then \
Expand Down Expand Up @@ -123,23 +123,32 @@ clean: platform-clean
rm -f scheme_aux.h
rm -f chezscheme-revision.include
rm -f swish-revision.include
rm -f swish-version.include
rm -f swish-version.include swish-version.mk
rm -f io-constants.ss io-constants${EXESUFFIX}
rm -f ../*.ss.html ../mat-report.html ../server-profile.html
rm -f *.mo *.ms.html *.ss.html

.PHONY: install install-batteries install-bin install-check install-doc
INSTLIBDIR := ${INSTALLROOT}/lib/swish${SWISH_VERSION}/${ARCH_DEST}
INSTWEBDIR := ${INSTALLROOT}/lib/swish${SWISH_VERSION}/web
INSTDOCDIR := ${INSTALLROOT}/share/doc/swish${SWISH_VERSION}

install: ready install-doc install-bin
swish-version.mk: swish-version.include
sed 's/^/SWISH_VERSION:=/' < $< > $@

-include swish-version.mk

install-check:
install-check: swish-version.mk
ifeq (,${SWISH_VERSION})
$(error SWISH_VERSION is not set)
endif
ifeq (,${INSTALLROOT})
$(error INSTALLROOT is not set)
endif

INSTLIBDIR := ${INSTALLROOT}/lib/swish${SWISH_VERSION}/${ARCH_DEST}
INSTWEBDIR := ${INSTALLROOT}/lib/swish${SWISH_VERSION}/web
INSTDOCDIR := ${INSTALLROOT}/share/doc/swish${SWISH_VERSION}

install: ready install-doc install-bin

install-doc: install-check
${GNU_INSTALL} --directory "${INSTDOCDIR}"
${GNU_INSTALL} --mode=444 ../../LICENSE "${INSTDOCDIR}"
Expand Down
6 changes: 6 additions & 0 deletions src/swish/app.ms
Original file line number Diff line number Diff line change
Expand Up @@ -742,3 +742,9 @@
[(,@expected ,@expected ,@prompt)
(script-test script '() "(exit)" '())])
'ok))

(mat semver ()
;; from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
(define pat (re "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"))
;; check that we're building at or after a sensible tag
(assert (pregexp-match pat (software-version))))
2 changes: 1 addition & 1 deletion src/swish/swish-build.ms
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

(isolate-mat version ()
(swish-build-test '("--version")
'("swish-build Version (?:\\d+\\.){2}\\d+ \\([[:xdigit:]dirty-]+\\)")))
'("swish-build Version (?:\\d+\\.){2}\\d+(?:-\\d+)?(?:-dirty)? \\([[:xdigit:]dirty-]+\\)")))

(isolate-mat info ()
(swish-build-test '("--info")
Expand Down
2 changes: 1 addition & 1 deletion src/swish/swish-test.ms
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

(isolate-mat version ()
(zero-exit (swish-test "--version")
'("swish-test Version (?:\\d+\\.){2}\\d+ \\([[:xdigit:]dirty-]+\\)")))
'("swish-test Version (?:\\d+\\.){2}\\d+(?:-\\d+)?(?:-dirty)? \\([[:xdigit:]dirty-]+\\)")))

(isolate-mat check-options ()
(nonzero-exit (swish-test "--progress pilgrim")
Expand Down
2 changes: 0 additions & 2 deletions src/swish/swish.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#define SWISH_VERSION "2.8.1"

#ifdef _WIN32
#define WINVER 0x0601 // Windows 7
#define _WIN32_WINNT WINVER
Expand Down

0 comments on commit 8777b4f

Please sign in to comment.