Pull request: all: imp scripts
Merge in DNS/adguard-home from imp-sh to master Squashed commit of the following: commit 477832e11eca2ef7ac0071b5da938dacb2ed617d Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed May 19 20:24:34 2021 +0300 scripts: rm dbg commit dbb4b8c783f607781b980dcd57d78085c9022e72 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed May 19 20:21:20 2021 +0300 all: imp code, compat, docs commit e6e4375d67ad1c213efb04411e3ba0bc6293f936 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed May 19 19:33:48 2021 +0300 all: imp scripts
This commit is contained in:
@@ -2,28 +2,29 @@
|
||||
|
||||
# AdGuard Home Version Generation Script
|
||||
#
|
||||
# This script generates versions based on the current git tree state.
|
||||
# The valid output formats are:
|
||||
# This script generates versions based on the current git tree state. The valid
|
||||
# output formats are:
|
||||
#
|
||||
# * For release versions, "v0.123.4". This version should be the one
|
||||
# in the current tag, and the script merely checks, that the current
|
||||
# * For release versions, "v0.123.4". This version should be the one in the
|
||||
# current tag, and the script merely checks, that the current commit is
|
||||
# properly tagged.
|
||||
#
|
||||
# * For prerelease beta versions, "v0.123.4-b.5". This version should be the
|
||||
# one in the current tag, and the script merely checks, that the current
|
||||
# commit is properly tagged.
|
||||
#
|
||||
# * For prerelease beta versions, "v0.123.4-b.5". This version should
|
||||
# be the one in the current tag, and the script merely checks, that
|
||||
# the current commit is properly tagged.
|
||||
# * For prerelease alpha versions (aka snapshots), "v0.123.4-a.6+a1b2c3d4".
|
||||
#
|
||||
# * For prerelease alpha versions (aka snapshots),
|
||||
# "v0.123.4-a.6+a1b2c3d4".
|
||||
# BUG(a.garipov): The script currently can't differentiate between beta tags and
|
||||
# release tags if they are on the same commit, so the beta tag **must** be
|
||||
# pushed and built **before** the release tag is pushed.
|
||||
#
|
||||
# BUG(a.garipov): The script currently can't differentiate between beta
|
||||
# tags and release tags if they are on the same commit, so the beta tag
|
||||
# **must** be pushed and built **before** the release tag is pushed.
|
||||
#
|
||||
# TODO(a.garipov): The script currently doesn't handle release branches,
|
||||
# so it must be modified once we have those.
|
||||
# TODO(a.garipov): The script currently doesn't handle release branches, so it
|
||||
# must be modified once we have those.
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
readonly verbose
|
||||
|
||||
readonly verbose="${VERBOSE:-0}"
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
set -x
|
||||
@@ -31,9 +32,9 @@ fi
|
||||
|
||||
set -e -f -u
|
||||
|
||||
# bump_minor is an awk program that reads a minor release version,
|
||||
# increments the minor part of it, and prints the next version.
|
||||
readonly bump_minor='/^v[0-9]+\.[0-9]+\.0$/ {
|
||||
# bump_minor is an awk program that reads a minor release version, increments
|
||||
# the minor part of it, and prints the next version.
|
||||
bump_minor='/^v[0-9]+\.[0-9]+\.0$/ {
|
||||
print($1 "." $2 + 1 ".0");
|
||||
|
||||
next;
|
||||
@@ -44,21 +45,19 @@ readonly bump_minor='/^v[0-9]+\.[0-9]+\.0$/ {
|
||||
|
||||
exit 1;
|
||||
}'
|
||||
readonly bump_minor
|
||||
|
||||
# get_last_minor_zero returns the last new minor release.
|
||||
get_last_minor_zero() {
|
||||
# List all tags. Then, select those that fit the pattern of
|
||||
# a new minor release: a semver version with the patch part set
|
||||
# to zero.
|
||||
# List all tags. Then, select those that fit the pattern of a new minor
|
||||
# release: a semver version with the patch part set to zero.
|
||||
#
|
||||
# Then, sort them first by the first field ("1"), starting with
|
||||
# the second character to skip the "v" prefix (".2"), and only
|
||||
# spanning the first field (",1"). The sort is numeric and
|
||||
# reverse ("nr").
|
||||
# Then, sort them first by the first field ("1"), starting with the
|
||||
# second character to skip the "v" prefix (".2"), and only spanning the
|
||||
# first field (",1"). The sort is numeric and reverse ("nr").
|
||||
#
|
||||
# Then, sort them by the second field ("2"), and only spanning
|
||||
# the second field (",2"). The sort is also numeric and reverse
|
||||
# ("nr").
|
||||
# Then, sort them by the second field ("2"), and only spanning the
|
||||
# second field (",2"). The sort is also numeric and reverse ("nr").
|
||||
#
|
||||
# Finally, get the top (that is, most recent) version.
|
||||
git tag\
|
||||
@@ -67,7 +66,8 @@ get_last_minor_zero() {
|
||||
| head -n 1
|
||||
}
|
||||
|
||||
readonly channel="$CHANNEL"
|
||||
channel="$CHANNEL"
|
||||
readonly channel
|
||||
|
||||
case "$channel"
|
||||
in
|
||||
@@ -77,32 +77,36 @@ in
|
||||
;;
|
||||
('edge')
|
||||
# last_minor_zero is the last new minor release.
|
||||
readonly last_minor_zero="$(get_last_minor_zero)"
|
||||
last_minor_zero="$( get_last_minor_zero )"
|
||||
readonly last_minor_zero
|
||||
|
||||
# num_commits_since_minor is the number of commits since the
|
||||
# last new minor release. If the current commit is the new
|
||||
# minor release, num_commits_since_minor is zero.
|
||||
readonly num_commits_since_minor="$(git rev-list "${last_minor_zero}..HEAD" | wc -l)"
|
||||
# num_commits_since_minor is the number of commits since the last new
|
||||
# minor release. If the current commit is the new minor release,
|
||||
# num_commits_since_minor is zero.
|
||||
num_commits_since_minor="$( git rev-list "${last_minor_zero}..HEAD" | wc -l )"
|
||||
readonly num_commits_since_minor
|
||||
|
||||
# next_minor is the next minor release version.
|
||||
readonly next_minor="$(echo "$last_minor_zero" | awk -F '.' "$bump_minor")"
|
||||
next_minor="$( echo "$last_minor_zero" | awk -F '.' "$bump_minor" )"
|
||||
readonly next_minor
|
||||
|
||||
# Make this commit a prerelease version for the next minor
|
||||
# release. For example, if the last minor release was v0.123.0,
|
||||
# and the current commit is the fifth since then, the version
|
||||
# will look something like:
|
||||
# Make this commit a prerelease version for the next minor release. For
|
||||
# example, if the last minor release was v0.123.0, and the current
|
||||
# commit is the fifth since then, the version will look something like:
|
||||
#
|
||||
# v0.124.0-a.5+a1b2c3d4
|
||||
#
|
||||
version="${next_minor}-a.${num_commits_since_minor}+$(git rev-parse --short HEAD)"
|
||||
version="${next_minor}-a.${num_commits_since_minor}+$( git rev-parse --short HEAD )"
|
||||
;;
|
||||
('beta'|'release')
|
||||
# current_desc is the description of the current git commit. If
|
||||
# the current commit is tagged, git describe will show the tag.
|
||||
readonly current_desc="$(git describe)"
|
||||
# current_desc is the description of the current git commit. If the
|
||||
# current commit is tagged, git describe will show the tag.
|
||||
current_desc="$( git describe )"
|
||||
readonly current_desc
|
||||
|
||||
# last_tag is the most recent git tag.
|
||||
readonly last_tag="$(git describe --abbrev=0)"
|
||||
last_tag="$( git describe --abbrev=0 )"
|
||||
readonly last_tag
|
||||
|
||||
# Require an actual tag for the beta and final releases.
|
||||
if [ "$current_desc" != "$last_tag" ]
|
||||
|
||||
Reference in New Issue
Block a user