Skip to content

Commit 435631f

Browse files
authored
Merge pull request #81 from raboof/determineVersionFromLastTaggedCommit
Determine version based on git tag (or pwd)
2 parents 744d698 + a0266d3 commit 435631f

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
## Notion Makefile
33
##
44

5+
export NOTION_RELEASE = $(shell ./version.sh)
6+
57
# Include system-specific configuration: auto-generated and optionally local
68
include build/system-inc.mk
79

@@ -49,16 +51,8 @@ snapshot:
4951
git checkout version.h
5052

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

6357
.PHONY: test
6458

build/libs.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ LIBMAINLOOP_DIR = $(TOPDIR)/libmainloop
44
LIBMAINLOOP_INCLUDES = -I$(TOPDIR)
55
LIBMAINLOOP_LIBS = -L$(LIBMAINLOOP_DIR) -lmainloop
66

7+
CFLAGS += -DNOTION_RELEASE='"$(NOTION_RELEASE)"'
8+
79
ifeq ($(wildcard $(TOPDIR)/libtu/obj.h),)
810

911
#External libtu, feel free to edit

version.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define NOTION_RELEASE "snapshot"
21
#define NOTION_VERSION NOTION_RELEASE
32
#define NOTION_API_VERSION NOTION_RELEASE
43

version.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Determines the currently checked-out version of Notion.
4+
5+
# Notion is distributed in source form through Git. Official releases are
6+
# identified by signed tags. This script will use the git command-line tool
7+
# to determine the version based on the latest tag and commit history.
8+
9+
# If the working directory is not a tag, the last tag is prepended to
10+
# the number of commits since the last tag plus the git hash.
11+
12+
# If the working directory is dirty, a timestamp is appended.
13+
14+
# If you absolutely require a source tarball, you can use the 'Download ZIP'
15+
# functionality. That zip will contain a directory called `notion-[xxx]`,
16+
# where `[xxx]` denotes the tag or branch from which the tarball was derived.
17+
18+
# Returns 0 and prints the version on stdout on success, without newline.
19+
# Returns a non-0 value on failure
20+
21+
set -e
22+
23+
if [ -e ".git" ]; then
24+
# Git:
25+
echo -n `git describe`
26+
if [[ -n $(git status -s) ]]; then
27+
echo -n `date +"+%Y%m%d-%H%M"`
28+
fi
29+
else
30+
# Not git, derive name from current directory as per github naming conventions:
31+
basename `pwd` | sed '/^notion-/!{q1}; {s/^notion-//}' | tr -d '\\n'
32+
fi

0 commit comments

Comments
 (0)