Skip to content

Commit

Permalink
Merge pull request #174 from akamai/release/v1.2.2
Browse files Browse the repository at this point in the history
Release/v1.2.2
  • Loading branch information
wzagrajcz authored Dec 7, 2022
2 parents a99e772 + bf58746 commit eddfd0c
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- "*"
pull_request:
branches:
- master
- v1
jobs:
test:
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# EDGEGRID GOLANG RELEASE NOTES

## 1.2.2 (Dec 07, 2022)

#### FEATURES/ENHANCEMENTS:
* Updated dependencies

## 1.2.1 (Jul 14, 2022)

#### BUG FIXES:
Expand Down
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# Akamai OPEN EdgeGrid for GoLang v1

[![Build Status](https://travis-ci.org/akamai/AkamaiOPEN-edgegrid-golang.svg?branch=master)](https://travis-ci.org/akamai/AkamaiOPEN-edgegrid-golang)
[![Build Status](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/actions/workflows/checks.yml/badge.svg?branch=v1)](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/actions/workflows/checks.yml?query=branch%3Av1)
[![GoDoc](https://godoc.org/github.com/akamai/AkamaiOPEN-edgegrid-golang?status.svg)](https://godoc.org/github.com/akamai/AkamaiOPEN-edgegrid-golang)
[![Go Report Card](https://goreportcard.com/badge/github.com/akamai/AkamaiOPEN-edgegrid-golang)](https://goreportcard.com/report/github.com/akamai/AkamaiOPEN-edgegrid-golang)
[![License](http://img.shields.io/:license-apache-blue.svg)](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/master/LICENSE)
[![License](http://img.shields.io/:license-apache-blue.svg)](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/v1/LICENSE)

This library implements an Authentication handler for [net/http](https://golang.org/pkg/net/http/)
that provides the [Akamai OPEN Edgegrid Authentication](https://developer.akamai.com/introduction/Client_Auth.html)
scheme. For more information visit the [Akamai OPEN Developer Community](https://developer.akamai.com). This library
has been released as a v1 library though future development will be on the v2 branch
that provides the [Akamai OPEN Edgegrid Authentication](https://developer.akamai.com/introduction/Client_Auth.html) scheme.
For more information visit the [Akamai OPEN Developer Community](https://developer.akamai.com).
This library has been released as a v1 library though future development will be on the **develop** branch for version v3.

## Announcing Akamai OPEN EdgeGrid for GoLang v2 (release v2.0.0)
## Announcing Akamai OPEN EdgeGrid for GoLang v3 (release v3.0.0)

The v2 branch of this module is under active development and provides a subset of Akamai APIs for use in the
Akamai Terraform Provider. The v2 branch **does not yet** implement the full set of Akamai endpoints supported by the
0.x and 1.x releases.
The v3 version of this module is under active development and provides a subset of Akamai APIs for use in the
Akamai Terraform Provider.

New users are encouraged to adopt v2 branch it is a simpler API wrapper with little to no business logic.
New users are encouraged to adopt v3 version it is a simpler API wrapper with little to no business logic.

Current direct users of this v0.9 library are recommended to continue to use the the v1 version as initialization
and package structure has significantly changed in v2 and will require substantial work to migrate existing
Current direct users of this v1.x.x library are recommended to continue to use the v1 version as initialization
and package structure has significantly changed in v3 and will require substantial work to migrate existing
applications. Non-backwards compatible changes were made to improve the code quality and make the project more
maintainable.

Expand Down Expand Up @@ -180,7 +179,7 @@ Alternatively, your program can read it from config struct.

## Contribute

1. Fork [the repository](https://github.com/akamai/AkamaiOPEN-edgegrid-golang) to start making your changes to the **master** branch
1. Fork [the repository](https://github.com/akamai/AkamaiOPEN-edgegrid-golang) to start making your changes to the **v1** branch
2. Send a pull request.

## Author
Expand Down
181 changes: 143 additions & 38 deletions scripts/semtag
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env bash
# this file has semantic versioning script from https://github.com/pnikosis/semtag

PROG=semtag
PROG_VERSION="v0.1.0"
PROG_VERSION="v0.1.2"

SEMVER_REGEX="^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"
IDENTIFIER_REGEX="^\-([0-9A-Za-z-]+)\.([0-9A-Za-z-]+)*$"
IDENTIFIER_REGEX="^\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*$"
NUMERIC_REGEX='^[0-9]+$'

# Length limit for the branch name in build metadata.
MAX_BRANCH_LENGTH=50

# Global variables
FIRST_VERSION="v0.0.0"
Expand All @@ -15,6 +18,7 @@ hasversiontag="false"
scope="patch"
displayonly="false"
forcetag="false"
prefix="v"
forcedversion=
versionname=
identifier=
Expand Down Expand Up @@ -42,6 +46,7 @@ Options:
in the format X.Y.Z where X, Y and Z are positive integers.
-o Output the version only, shows the bumped version, but doesn't tag.
-f Forces to tag, even if there are unstaged or uncommited changes.
-p Use a plain version, ie. do not prefix with 'v'.
Commands:
--help Print this help message.
--version Prints the program's version.
Expand All @@ -51,7 +56,7 @@ Commands:
getcurrent Returns the current version, based on the latest one, if there are uncommited or
unstaged changes, they will be reflected in the version, adding the number of
pending commits, current branch and commit hash.
final Tags the current build as a final version, this only can be done on the master branch.
final Tags the current build as a final version, this only can be done on the default branch.
candidate Tags the current build as a release candidate, the tag will contain all
the commits from the last final version.
alpha Tags the current build as an alpha version, the tag will contain all
Expand All @@ -65,7 +70,7 @@ ACTION="$1"
shift

# We get the parameters
while getopts "v:s:of" opt; do
while getopts "v:s:ofp" opt; do
case $opt in
v)
forcedversion="$OPTARG"
Expand All @@ -79,6 +84,9 @@ while getopts "v:s:of" opt; do
f)
forcetag="true"
;;
p)
prefix=""
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
Expand All @@ -90,6 +98,25 @@ while getopts "v:s:of" opt; do
esac
done

# Try to programmatically fetch the default branch. Go by the first remote HEAD found, otherwise default to `master`.
# $1 The variable to store the result
function get_default_branch {
local __result=$1

local __remotes=$(git remote)
if [[ -n $__remotes ]]; then
for __remote in $__remotes; do
local __default_branch_ref=$(git symbolic-ref --quiet --short HEAD || true)
local __default_branch=${__default_branch_ref#refs/heads/}
if [[ -n ${__default_branch} ]]; then
break
fi
done
fi

eval "${__result}=${__default_branch:-master}"
}

# Gets a string with the version and returns an array of maximum size of 5 with all the parts of the sematinc version
# $1 The string containing the version in semantic format
# $2 The variable to store the result array:
Expand Down Expand Up @@ -145,23 +172,45 @@ function compare_versions {
# Identifiers should compare with the ASCII order.
local __identifierfirst=${__first[3]}
local __identifiersecond=${__second[3]}
if [[ -n "$__identifierfirst" ]] && [[ -n "$__identifiersecond" ]]; then
if [[ "$__identifierfirst" > "$__identifiersecond" ]]; then
eval "$lv=1"
return 0
elif [[ "$__identifierfirst" < "$__identifiersecond" ]]; then
eval "$lv=-1"
return 0
fi
elif [[ -z "$__identifierfirst" ]] && [[ -n "$__identifiersecond" ]]; then
eval "$lv=1"
return 0
elif [[ -n "$__identifierfirst" ]] && [[ -z "$__identifiersecond" ]]; then
eval "$lv=-1"
return 0
compare_identifiers "${__first[3]}" "${__second[3]}" compareresult
eval "$lv=$compareresult"
}


# Returns the number comparison
# $1 The first number to compare
# $2 The second number to compare
# $3 The variable where to store the result
function compare_numeric {
local __first=$1
local __second=$2
local __result=$3

if (( "$__first" < "$__second" )) ; then
eval "$__result=-1"
elif (( "$__first" > "$__second" )) ; then
eval "$__result=1"
else
eval "$__result=0"
fi
}

# Returns the alpanumeric comparison
# $1 The first alpanumeric to compare
# $2 The second alpanumeric to compare
# $3 The variable where to store the result
function compare_alphanumeric {
local __first=$1
local __second=$2
local __result=$3

eval "$lv=0"
if [[ "$__first" < "$__second" ]] ; then
eval "$__result=-1"
elif [[ "$__first" > "$__second" ]] ; then
eval "$__result=1"
else
eval "$__result=0"
fi
}

# Returns the last version of two
Expand All @@ -173,6 +222,7 @@ function get_latest_of_two {
local __second=$2
local __result
local __latest=$3

compare_versions $__first $__second __result
case $__result in
0)
Expand All @@ -187,19 +237,78 @@ function get_latest_of_two {
esac
}

# Returns comparison of two identifier parts
# $1 The first part to compare
# $2 The second part to compare
# $3 The variable where to store the compare result
function compare_identifier_part {
local __first=$1
local __second=$2
local __result=$3
local compareresult

if [[ "$__first" =~ $NUMERIC_REGEX ]] && [[ "$__second" =~ $NUMERIC_REGEX ]] ; then
compare_numeric "$__first" "$__second" compareresult
eval "$__result=$compareresult"
return 0
fi


compare_alphanumeric "$__first" "$__second" compareresult
eval "$__result=$compareresult"
}

# Returns comparison of two identifiers
# $1 The first identifier to compare
# $2 The second identifier to compare
# $3 The variable where to store the compare result
function compare_identifiers {
local __first=$1
local __second=$2
local __result=$3
local partresult
local arraylengths
if [[ -n "$__first" ]] && [[ -n "$__second" ]]; then
explode_identifier "${__first}" explodedidentifierfirst
explode_identifier "${__second}" explodedidentifiersecond

firstsize=${#explodedidentifierfirst[@]}
secondsize=${#explodedidentifiersecond[@]}
minlength=$(( $firstsize<$secondsize ? $firstsize : $secondsize ))
for (( i = 0 ; i < $minlength ; i++ )); do
compare_identifier_part "${explodedidentifierfirst[$i]}" "${explodedidentifiersecond[$i]}" partresult
case $partresult in
0)
;;
*)
eval "$__result=$partresult"
return 0
;;
esac
done
compare_numeric $firstsize $secondsize arraylengths
eval "$__result=$arraylengths"
return 0
elif [[ -z "$__first" ]] && [[ -n "$__second" ]]; then
eval "$__result=1"
return 0
elif [[ -n "$__first" ]] && [[ -z "$__second" ]]; then
eval "$__result=-1"
return 0
fi

eval "$__result=0"
}

# Assigns a 2 size array with the identifier, having the identifier at pos 0, and the number in pos 1
# $1 The identifier in the format -id.#
# $2 The vferiable where to store the 2 size array
function explode_identifier {
local __identifier=$1
local __result=$2
if [[ $__identifier =~ $IDENTIFIER_REGEX ]] ; then
local __id=${BASH_REMATCH[1]}
local __number=${BASH_REMATCH[2]}
if [[ -z "$__number" ]]; then
__number=1
fi
eval "$__result=(\"$__id\" \"$__number\")"
IFS='-.' read -ra identifierparts <<< $__identifier
eval "$__result=( ${identifierparts[@]} )"
else
eval "$__result="
fi
Expand Down Expand Up @@ -282,7 +391,7 @@ function get_next_version {
;;
esac

eval "$__result=v${__exploded[0]}.${__exploded[1]}.${__exploded[2]}"
eval "$__result=${prefix}${__exploded[0]}.${__exploded[1]}.${__exploded[2]}"
}

function bump_version {
Expand All @@ -300,7 +409,7 @@ function bump_version {
explode_identifier ${__explodedlast[3]} __idlast

# We get the last, given the desired id based on the scope
__candidatefromlast="v${__explodedlast[0]}.${__explodedlast[1]}.${__explodedlast[2]}"
__candidatefromlast="${prefix}${__explodedlast[0]}.${__explodedlast[1]}.${__explodedlast[2]}"
if [[ -n "$identifier" ]]; then
local __nextid="$identifier.1"
if [ "$identifier" == "${__idlast[0]}" ]; then
Expand Down Expand Up @@ -533,7 +642,8 @@ function get_current {
eval "$1=$lastversion"
else
local __buildinfo="$(git rev-parse --short HEAD)"
local __currentbranch="$(git rev-parse --abbrev-ref HEAD)"
local __currentbranch="$(git rev-parse --abbrev-ref HEAD | cut -c1-$MAX_BRANCH_LENGTH)"
get_default_branch default_branch
if [ "$__currentbranch" != "master" ]; then
__buildinfo="$__currentbranch.$__buildinfo"
fi
Expand Down Expand Up @@ -566,8 +676,7 @@ function get_current {
}

function init {
git fetch > /dev/null
TAGS="$(git tag)"
TAGS="$(git tag --merged)"
IFS=$'\n' read -rd '' -a TAG_ARRAY <<<"$TAGS"

get_latest ${TAG_ARRAY[@]}
Expand All @@ -583,15 +692,11 @@ case $ACTION in
;;
final)
init
diff=$(git diff master | cat)
diff_dev=$(git diff develop | cat)
diff_v2=$(git diff v2 | cat)
get_default_branch default_branch
diff=$(git diff $default_branch | cat)
if [ "$forcetag" == "false" ]; then
if [ -n "$diff_dev" ] && [ -n "$diff" ] && [ -n "$diff_v2" ]; then
echo "ERROR: Branch must be updated with develop, master, or v2 for final versions"
fi
if [ -n "$diff" ]; then
echo "ERROR: Branch must be updated with master for final versions"
echo "ERROR: Branch must be updated with $default_branch for final versions"
exit 1
fi
fi
Expand Down

0 comments on commit eddfd0c

Please sign in to comment.