diff options
Diffstat (limited to 'lib/cbor/tinycbor/scripts')
| -rw-r--r-- | lib/cbor/tinycbor/scripts/maketag.pl | 91 | ||||
| -rwxr-xr-x | lib/cbor/tinycbor/scripts/update-docs.sh | 52 |
2 files changed, 143 insertions, 0 deletions
diff --git a/lib/cbor/tinycbor/scripts/maketag.pl b/lib/cbor/tinycbor/scripts/maketag.pl new file mode 100644 index 00000000..5b1a8b79 --- /dev/null +++ b/lib/cbor/tinycbor/scripts/maketag.pl @@ -0,0 +1,91 @@ +#!perl +use strict; +sub run(@) { + open PROC, "-|", @_ or die("Cannot run $_[0]: $!"); + my @out; + while (<PROC>) { + chomp; + push @out, $_; + } + close PROC; + return @out; +} + +my @tags = run("git", "tag"); +my @v = run("git", "show", "HEAD:VERSION"); +my $v = $v[0]; + +my $tagfile = ".git/TAG_EDITMSG"; +open TAGFILE, ">", $tagfile + or die("Cannot create file for editing tag message: $!"); +select TAGFILE; +print "TinyCBOR release $v\n"; +print "\n"; +print "# Write something nice about this release here\n"; + +# Do we have a commit template? +my @result = run("git", "config", "--get", "commit.template"); +if (scalar @result) { + open TEMPLATE, "<", $result[0]; + map { print $_; } <TEMPLATE>; + close TEMPLATE; +} + +print "\n"; +print "# Commit log\n"; +open LOG, "-|", "git", "shortlog", "-e", "--no-merges", "--not", @tags; +map { print "# $_"; } <LOG>; +close LOG; + +print "# Header diff:\n"; +open DIFF, "-|", "git", "diff", "HEAD", "--not", @tags, "--", 'src/*.h', ':!*_p.h'; +map { print "# $_"; } <DIFF>; +close DIFF; + +select STDOUT; +close TAGFILE; + +# Run the editor. +# We use system so that stdin, stdout and stderr are forwarded. +@result = run("git", "var", "GIT_EDITOR"); +@result = ($result[0], $tagfile); +system @result; +exit ($? >> 8) if $?; + +# Create the tag +# Also using system so that hte user can see the output. +system("git", "tag", "-a", "-F", $tagfile, split(' ', $ENV{GITTAGFLAGS}), "v$v"); +exit ($? >> 8) if $?; + +# Update the version files for the next patch release +@v = split(/\./, $v); +if (scalar @v < 3) { + push @v, '1'; +} else { + ++$v[-1]; +} +$v = join('.', @v); +open VERSION, ">", "VERSION" or die("Cannot open VERSION file: $!"); +print VERSION "$v\n"; +close VERSION; + +open VERSION, ">", "src/tinycbor-version.h" or die("Cannot open src/tinycbor-version.h: $!"); +print VERSION "#define TINYCBOR_VERSION_MAJOR ", $v[0], "\n"; +print VERSION "#define TINYCBOR_VERSION_MINOR ", $v[1], "\n"; +print VERSION "#define TINYCBOR_VERSION_PATCH ", $v[2], "\n"; +close VERSION; + +if (open APPVEYORYML, "<", ".appveyor.yml") { + my @contents = map { + s/^version:.*/version: $v[0].$v[1].$v[2]-build-{build}/; + $_; + } <APPVEYORYML>; + close APPVEYORYML; + open APPVEYORYML, ">", ".appveyor.yml"; + print APPVEYORYML join('', @contents); + close APPVEYORYML; +} + +# Print summary +print "Tag created and next versions updated.\n"; +print "Don't forget to create the docs.\n" if $v[2] == 1; diff --git a/lib/cbor/tinycbor/scripts/update-docs.sh b/lib/cbor/tinycbor/scripts/update-docs.sh new file mode 100755 index 00000000..19acfaea --- /dev/null +++ b/lib/cbor/tinycbor/scripts/update-docs.sh @@ -0,0 +1,52 @@ +#!/bin/sh -ex +tuple="$TRAVIS_BRANCH${TRAVIS_TAG:+tag:$TRAVIS_TAG},$TRAVIS_PULL_REQUEST" +case "$tuple" in + dev,false|main,false|tag:*) + ;; + *) + exit 0 + ;; +esac +V=`cut -f1-2 -d. <VERSION` +git fetch origin gh-pages + +# Fail if the library sizes file isn't present +test -r sizes + +# Run doxygen (maybe) +if [ -n "${TRAVIS_TAG-$FORCE_DOCS}" ] && make -s docs 2>/dev/null; then + git checkout -b gh-pages FETCH_HEAD + if [ -d "$V" ]; then + mv "$V" "old-$V" + fi + mv doc/html "$V" + git add -A "$V" +else + git checkout -b gh-pages FETCH_HEAD + mkdir -p "$V" +fi + +# Update the symlink for the branch name +rm -f "./$TRAVIS_BRANCH" +ln -s "$V" "$TRAVIS_BRANCH" +git add "./$TRAVIS_BRANCH" + +# Update the library sizes file +# (will fail if the release build failed) +mkdir -p "library_sizes/$TRAVIS_BRANCH" +mv sizes "library_sizes/$TRAVIS_BRANCH/$QMAKESPEC" +(cd "library_sizes/$TRAVIS_BRANCH/"; + for f in *; do echo "$f:"; cat "$f" ; done) > "$V/library_sizes.txt" +git add "library_sizes/$TRAVIS_BRANCH" "$V/library_sizes.txt" +git diff --cached -U0 "$V/library_sizes.txt" + +# Commit everything +if git commit -m "Update docs for $V (Travis build $TRAVIS_BUILD_NUMBER) + +Matching commit $TRAVIS_COMMIT: +$TRAVIS_COMMIT_MESSAGE"; then + # We've made a commit, push it + set +x + url=`git config --get remote.origin.url | sed -e s,://github,://$GITHUB_AUTH@github,` + git push "$url" @:gh-pages +fi |
