]> git.codecow.com Git - Monocypher.git/commitdiff
Include version in released source files
authorLoup Vaillant <loup@loup-vaillant.fr>
Sat, 19 Oct 2019 12:44:28 +0000 (14:44 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sat, 19 Oct 2019 12:44:28 +0000 (14:44 +0200)
I realised that determining which Monocypher version was used in a
project was not trivial. We could look at Monocypher's code and deduce
the release, but that's tedious and error prone. So I've made those
versions more explicit:

- Source and header files begin by a comment describing the version.
- The pkg-config file created by `make install` include that version.
- The version number of unreleased code (under git) is "__git__"
- The version number of released code is whatever `git describe --tags`
  tells us.
- the "tarball" target in the makefile was changed to the more standard
  "dist".

To release a new version, we just add a tag, then call `makefile dist`.
The version of the released source file will appear at a glance, right
there on the first line.

Note: the release process blindly replaces all instances of "__git__" by
the suitable version number.  This could be used to version things other
than comments, like string constants.

.gitignore
README.md
VERSION.md [deleted file]
makefile
release.sh [new file with mode: 0755]
src/monocypher.c
src/monocypher.h
src/optional/sha512.c
src/optional/sha512.h
tarball_ignore

index b4b330ab9ba0a2d5d5a3086f0b141f8226dd13e7..8ee886e463ca4caf43528654091e1dc74779a64f 100644 (file)
@@ -9,10 +9,18 @@
 *.sav
 *.profraw
 *.profdata
+*.creator
+*.creator.*
+*.config
+*.cflags
+*.cxxflags
+*.files
+*.includes
+*.su
+*.su.*
 tests/formal-analysis/*
 tests/formal-analysis
 *.tar.gz
 monocypher-*
-monocypher.*
 doc/html/*.html
 tests/vectors.h
index 3d41396e63477d91cbc4fd031359aaee7c692ae1..ce2e603726702119a0065d907ed9f04c2ccbaebf 100644 (file)
--- a/README.md
+++ b/README.md
@@ -182,6 +182,6 @@ that ship with the tarball releases:
 - The html version of the manual, generated by the `doc/man2html.sh`
   script.  You will need mandoc.
 
-To generate a tarball, simply type `make tarball`. It will make a
-tarball with a name that matches the current version (as written in
-VERSION.md), in the current directory.
+To generate a tarball, simply type `make dist`. It will make a tarball
+with a name that matches the current version (using `git describe`), in
+the current directory.
diff --git a/VERSION.md b/VERSION.md
deleted file mode 100644 (file)
index e010258..0000000
+++ /dev/null
@@ -1 +0,0 @@
-2.0.5
index 24d74a6c673ee4feb66832fc72abdfd914034ddd..344f3e23522b37b58e5d29daf0c0252cfd3d6d84 100644 (file)
--- a/makefile
+++ b/makefile
@@ -5,8 +5,7 @@ PREFIX=usr/local
 PKGCONFIG=$(DESTDIR)/$(PREFIX)/lib/pkgconfig
 MAN_DIR=$(DESTDIR)/$(PREFIX)/share/man/man3
 
-TARBALL_VERSION=`cat VERSION.md`
-TARBALL_DIR=.
+VERSION=__git__
 
 ifeq ($(findstring -DED25519_SHA512, $(CFLAGS)),)
 LINK_SHA512=
@@ -34,7 +33,7 @@ install: library src/monocypher.h install-doc
        @echo 'includedir=$${prefix}/include'   >> $(PKGCONFIG)/monocypher.pc
        @echo ''                                >> $(PKGCONFIG)/monocypher.pc
        @echo 'Name: monocypher'                >> $(PKGCONFIG)/monocypher.pc
-       @echo 'Version:' `cat VERSION.md`       >> $(PKGCONFIG)/monocypher.pc
+       @echo 'Version: ' $(VERSION)            >> $(PKGCONFIG)/monocypher.pc
        @echo 'Description: Easy to use, easy to deploy crypto library' \
                                                 >> $(PKGCONFIG)/monocypher.pc
        @echo ''                                >> $(PKGCONFIG)/monocypher.pc
@@ -131,9 +130,5 @@ tests/vectors.h:
        @echo ""
        return 1
 
-tarball: tests/vectors.h
-       doc/man2html.sh
-       touch     $(TARBALL_DIR)/monocypher-$(TARBALL_VERSION).tar.gz
-       tar -czvf $(TARBALL_DIR)/monocypher-$(TARBALL_VERSION).tar.gz \
-            -X tarball_ignore                                         \
-            --transform='flags=r;s|^.|monocypher-'$(TARBALL_VERSION)'|' .
+dist: tests/vectors.h
+       ./release.sh
diff --git a/release.sh b/release.sh
new file mode 100755 (executable)
index 0000000..bbaa145
--- /dev/null
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+set -e
+
+VERSION=`git describe --tags`
+
+doc/man2html.sh
+rsync -avd --exclude-from=tarball_ignore ./ monocypher-$VERSION
+for file in `find monocypher-$VERSION -type f `
+do
+    sed -i "s/__git__/$VERSION/" $file
+done
+tar -czf monocypher-$VERSION.tar.gz monocypher-$VERSION
+rm -rf monocypher-$VERSION
index 7241ec55c6bc4cd8208d6a8747577c23670c0b10..6a4b10fb776ae386ede7c18a94f81107b6d12fef 100644 (file)
@@ -1,3 +1,5 @@
+// Monocypher version __git__
+
 #include "monocypher.h"
 
 /////////////////
index 97d485405a15e3953067be2ec87152a5c620bc47..c99561def611a2c213a89c5120b52758243addc4 100644 (file)
@@ -1,3 +1,5 @@
+// Monocypher version __git__
+
 #ifndef MONOCYPHER_H
 #define MONOCYPHER_H
 
index a83d1886fc899203835d8356a5dbee966283f844..9afaeb962f44408b7c96b3a1e5666b2dbbce6e7d 100644 (file)
@@ -1,3 +1,5 @@
+// Monocypher version __git__
+
 #include "sha512.h"
 
 #define FOR(i, min, max)     for (size_t i = min; i < max; i++)
index 13540792fa8760d4fbf7889801ce8513e2f9dfa3..78f850f7f7da9ee03de291b3cc619b6f094af436 100644 (file)
@@ -1,3 +1,5 @@
+// Monocypher version __git__
+
 #ifndef SHA512_H
 #define SHA512_H
 
index 047b6a76e8deca6703555488604f855b4c6e24d9..361426ec05e70664dea785b3630b2284ecf940e4 100644 (file)
@@ -9,10 +9,18 @@
 *.sav
 *.profraw
 *.profdata
+*.creator
+*.creator.*
+*.config
+*.cflags
+*.cxxflags
+*.files
+*.includes
+*.su
+*.su.*
 tests/formal-analysis/*
 tests/formal-analysis
 *.tar.gz
 monocypher-*
-monocypher.*
 lib*
 .git*