aboutsummaryrefslogtreecommitdiff
path: root/scripts/release.sh
blob: e60890c3aff200d44e2359454fe2bc35110856f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash
# Copyright (C) 2016 Robin Krahl <robin.krahl@wikipedia.de>
#
# This script bundles LrMediaWiki and uploads the bundled plugin to GitHub.
# You have to pass the version number (e. g. 1.0). The script will upload the
# bundled plugin to the release with the tag v<VERSION>, e. g. v1.0. This
# script requires that the environment variable GITHUB_TOKEN is set to a valid
# token for the repository to release a version for.
#
# Dependencies:
#  - github-release: https://github.com/aktau/github-release

if [[ "$#" -ne 1 ]]
then
  echo "USAGE: ./release.sh <version>"
  echo "  version: the semantic version name, e. g. 1.0"

  if [[ "$#" -gt 1 ]]
  then
    echo "1 argument required, $# given" >&2
    exit 1
  else
    exit 0
  fi
fi

# user input
VERSION="$1"
# github-release settings
GITHUB_USER="robinkrahl"
GITHUB_REPO="LrMediaWiki"
# paths and file names
TMPDIR=`mktemp -d`
LRDEVPLUGIN="mediawiki.lrdevplugin"
LRPLUGIN="mediawiki.lrplugin"
TAG="v$1"
ARCHIVE_BASE_NAME="lrmediawiki-$VERSION"
ARCHIVE_NAME_ZIP="$ARCHIVE_BASE_NAME.zip"
ARCHIVE_NAME_TAR_GZ="$ARCHIVE_BASE_NAME.tar.gz"
CHECKSUM_NAME="checksums.md5"

# copy required files to the temporary direction
cp -r "$LRDEVPLUGIN" "$TMPDIR/$LRPLUGIN"
cp *.md *.txt "$TMPDIR/$LRPLUGIN"

cd $TMPDIR

# create archives
zip -r "$ARCHIVE_NAME_ZIP" "$LRPLUGIN"
tar -czf "$ARCHIVE_NAME_TAR_GZ" "$LRPLUGIN"
# create checksums
md5sum "$ARCHIVE_NAME_ZIP" "$ARCHIVE_NAME_TAR_GZ" > "$CHECKSUM_NAME"

# upload
for FILE in "$ARCHIVE_NAME_ZIP" "$ARCHIVE_NAME_TAR_GZ" "$CHECKSUM_NAME"
do
  github-release upload --tag "$TAG" --name "$FILE" --file "$FILE" --user "$GITHUB_USER" --repo "$GITHUB_REPO"
done

rm -r "$TMPDIR"
echo "DONE"