2017-01-05 01:42:58 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2018-04-13 04:02:28 +08:00
|
|
|
# Copyright © 2017-2018 The qTox Project Contributors
|
2017-01-05 01:42:58 +08:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-10-01 05:08:22 +08:00
|
|
|
# Create `lzip` and `gzip` archives and make detached GPG signatures for them.
|
2017-01-05 01:42:58 +08:00
|
|
|
#
|
2018-10-01 05:08:22 +08:00
|
|
|
# When tag name is supplied, it's used to create archives. If there is no tag
|
2017-01-05 01:42:58 +08:00
|
|
|
# name supplied, latest tag is used.
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# * GPG
|
|
|
|
# * git
|
2018-08-28 10:11:31 +08:00
|
|
|
# * gzip
|
2018-10-01 05:08:22 +08:00
|
|
|
# * lzip
|
2017-01-05 01:42:58 +08:00
|
|
|
|
|
|
|
# usage:
|
|
|
|
# ./$script [$tag_name]
|
|
|
|
|
|
|
|
|
|
|
|
# Fail as soon as error appears
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
|
2018-10-01 05:08:22 +08:00
|
|
|
archive() {
|
|
|
|
git archive --format=tar "${@%%.tar.*}" \
|
|
|
|
| "${@##*.tar.}"ip --best \
|
|
|
|
> "$@"
|
|
|
|
echo "$@ archive has been created."
|
2017-01-05 01:42:58 +08:00
|
|
|
}
|
|
|
|
|
2018-10-01 05:08:22 +08:00
|
|
|
sign_archive() {
|
2018-08-28 10:11:31 +08:00
|
|
|
gpg \
|
|
|
|
--armor \
|
|
|
|
--detach-sign \
|
2018-10-01 05:08:22 +08:00
|
|
|
"$@"
|
|
|
|
echo "$@.asc signature has been created."
|
2017-01-05 01:42:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
create_and_sign() {
|
2018-10-01 05:08:22 +08:00
|
|
|
local archives=("$@".tar.{l,g}z)
|
|
|
|
for a in "${archives[@]}"
|
|
|
|
do
|
|
|
|
archive "$a"
|
|
|
|
sign_archive "$a"
|
|
|
|
done
|
2017-01-05 01:42:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
get_tag() {
|
|
|
|
local tname="$@"
|
|
|
|
if [[ -n "$tname" ]]
|
|
|
|
then
|
|
|
|
echo "$tname"
|
|
|
|
else
|
|
|
|
git describe --abbrev=0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
create_and_sign "$(get_tag $@)"
|
|
|
|
}
|
|
|
|
main "$@"
|