Skip to content

Commit

Permalink
Merge pull request #81 from raboof/determineVersionFromLastTaggedCommit
Browse files Browse the repository at this point in the history
Determine version based on git tag (or pwd)
  • Loading branch information
raboof authored May 1, 2019
2 parents 744d698 + a0266d3 commit 435631f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## Notion Makefile
##

export NOTION_RELEASE = $(shell ./version.sh)

# Include system-specific configuration: auto-generated and optionally local
include build/system-inc.mk

Expand Down Expand Up @@ -49,16 +51,8 @@ snapshot:
git checkout version.h

dist:
PWD=`pwd` ;\
DIR=`basename "$$PWD"` ;\
RELEASE=`./nextversion.sh` ;\
perl -p -i -e "s/^#define NOTION_RELEASE.*/#define NOTION_RELEASE \"$$RELEASE\"/" version.h ;\
git add version.h; git commit -m "Releasing version $$RELEASE" ;\
git tag -s -m "Release $$RELEASE" $$RELEASE ; git push --tags ;\
git archive --prefix notion-$$RELEASE/ --format=tar.gz $$RELEASE > ../notion-$$RELEASE-src.tar.gz ;\
git archive --prefix notion-$$RELEASE/ --format=tar $$RELEASE | bzip2 > ../notion-$$RELEASE-src.tar.bz2 ;\
perl -p -i -e "s/^#define NOTION_RELEASE.*/#define NOTION_RELEASE \"snapshot\"/" version.h ;\
git add version.h; git commit -m "Released version $$RELEASE" ; git push
git tag -s -m "Release $$RELEASE" $$RELEASE ; git push --tags

.PHONY: test

Expand Down
2 changes: 2 additions & 0 deletions build/libs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ LIBMAINLOOP_DIR = $(TOPDIR)/libmainloop
LIBMAINLOOP_INCLUDES = -I$(TOPDIR)
LIBMAINLOOP_LIBS = -L$(LIBMAINLOOP_DIR) -lmainloop

CFLAGS += -DNOTION_RELEASE='"$(NOTION_RELEASE)"'

ifeq ($(wildcard $(TOPDIR)/libtu/obj.h),)

#External libtu, feel free to edit
Expand Down
1 change: 0 additions & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define NOTION_RELEASE "snapshot"
#define NOTION_VERSION NOTION_RELEASE
#define NOTION_API_VERSION NOTION_RELEASE

Expand Down
32 changes: 32 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Determines the currently checked-out version of Notion.

# Notion is distributed in source form through Git. Official releases are
# identified by signed tags. This script will use the git command-line tool
# to determine the version based on the latest tag and commit history.

# If the working directory is not a tag, the last tag is prepended to
# the number of commits since the last tag plus the git hash.

# If the working directory is dirty, a timestamp is appended.

# If you absolutely require a source tarball, you can use the 'Download ZIP'
# functionality. That zip will contain a directory called `notion-[xxx]`,
# where `[xxx]` denotes the tag or branch from which the tarball was derived.

# Returns 0 and prints the version on stdout on success, without newline.
# Returns a non-0 value on failure

set -e

if [ -e ".git" ]; then
# Git:
echo -n `git describe`
if [[ -n $(git status -s) ]]; then
echo -n `date +"+%Y%m%d-%H%M"`
fi
else
# Not git, derive name from current directory as per github naming conventions:
basename `pwd` | sed '/^notion-/!{q1}; {s/^notion-//}' | tr -d '\\n'
fi

0 comments on commit 435631f

Please sign in to comment.