]> jfr.im git - irc/weechat/weechat-relay.git/blame - version.sh
Remove tests on macOS 11
[irc/weechat/weechat-relay.git] / version.sh
CommitLineData
8ab2319d
SH
1#!/bin/sh
2#
0def0350 3# Copyright (C) 2019-2024 Sébastien Helleu <flashcode@flashtux.org>
8ab2319d
SH
4#
5# This file is part of WeeChat Relay.
6#
7# WeeChat Relay is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# WeeChat Relay is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with WeeChat Relay. If not, see <https://www.gnu.org/licenses/>.
19#
20
21#
22# Returns current stable or devel version of WeeChat Relay.
23#
24# Syntax:
00be8902 25# version.sh <name>
8ab2319d 26#
00be8902 27# name is one of:
8ab2319d 28#
00be8902
SH
29# stable the stable version (e.g. "1.2.3")
30# stable-major the major version of stable ("1" for "1.2.3")
31# stable-minor the minor version of stable ("2" for "1.2.3")
32# stable-patch the patch version of stable ("3" for "1.2.3")
33# stable-number the stable version as hex number ("0x010203" for "1.2.3")
34# devel the devel with only digits/dots (e.g. "1.3.0")
35# devel-full the full devel (e.g. "1.3.0-dev")
36# devel-major the major version of devel ("1" for "1.3.0-dev")
37# devel-minor the minor version of devel ("3" for "1.3.0-dev")
38# devel-patch the patch version of devel ("0-dev" for "1.3.0-dev")
39# devel-number the devel version as hex number ("0x010300" for "1.3.0-dev")
8ab2319d
SH
40#
41
032b1890
SH
42weechat_relay_stable="0.0.0"
43weechat_relay_devel="1.0.0-dev"
8ab2319d 44
032b1890
SH
45stable_major=$(echo "${weechat_relay_stable}" | cut -d"." -f1)
46stable_minor=$(echo "${weechat_relay_stable}" | cut -d"." -f2)
47stable_patch=$(echo "${weechat_relay_stable}" | cut -d"." -f3-)
48stable_patch_digits=$(echo "${weechat_relay_stable}" | cut -d"." -f3- | cut -d"-" -f1)
00be8902 49
032b1890
SH
50devel_major=$(echo "${weechat_relay_devel}" | cut -d"." -f1)
51devel_minor=$(echo "${weechat_relay_devel}" | cut -d"." -f2)
52devel_patch=$(echo "${weechat_relay_devel}" | cut -d"." -f3-)
53devel_patch_digits=$(echo "${weechat_relay_devel}" | cut -d"." -f3- | cut -d"-" -f1)
8ab2319d
SH
54
55if [ $# -lt 1 ]; then
00be8902
SH
56 echo >&2 "Syntax: $0 <name>"
57 echo >&2 "name: stable, stable-major, stable-minor, stable-patch, stable-number,"
58 echo >&2 " devel, devel-full, devel-major, devel-minor, devel-patch, devel-number"
8ab2319d
SH
59 exit 1
60fi
61
62case $1 in
00be8902 63 # stable
032b1890
SH
64 stable ) echo "${weechat_relay_stable}" ;;
65 stable-major ) echo "${stable_major}" ;;
66 stable-minor ) echo "${stable_minor}" ;;
67 stable-patch ) echo "${stable_patch}" ;;
68 stable-number ) printf "0x%02d%02d%02d\n" "${stable_major}" "${stable_minor}" "${stable_patch_digits}" ;;
00be8902 69 # devel
032b1890
SH
70 devel ) echo "${weechat_relay_devel}" | cut -d"-" -f1 ;;
71 devel-full ) echo "${weechat_relay_devel}" ;;
72 devel-major ) echo "${devel_major}" ;;
73 devel-minor ) echo "${devel_minor}" ;;
74 devel-patch ) echo "${devel_patch}" ;;
75 devel-number ) printf "0x%02d%02d%02d\n" "${devel_major}" "${devel_minor}" "${devel_patch_digits}" ;;
00be8902 76 # error
8ab2319d
SH
77 * ) echo >&2 "ERROR: unknown version."
78 exit 1 ;;
79esac