-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Giovanni Toraldo <giovanni.toraldo@hyland.com>
- Loading branch information
Showing
4 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
if [ -n "$REPO_DIR" ]; then | ||
cd "$REPO_DIR" | ||
fi | ||
git fetch --tags | ||
TAG=$(git tag --list "$PATTERN" --sort=-creatordate | head -n 1) | ||
TAG_LONG_SHA=$(git rev-list -n 1 $TAG) | ||
echo "Tag for the pattern $PATTERN is $TAG ($TAG_LONG_SHA)" | ||
echo "tag=$TAG" >> "$GITHUB_OUTPUT" | ||
echo "tag_long_sha=$TAG_LONG_SHA" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
setup() { | ||
git fetch --tags | ||
|
||
# Runs everywhere | ||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" | ||
PATH="$DIR/..:$PATH" | ||
|
||
# Mock GitHub Actions default variables | ||
export GITHUB_ENV=/dev/null | ||
export GITHUB_HEAD_REF="AAE-11760-get-latest-tag-sha" | ||
|
||
# Mock git-latest-tag defaults | ||
export PATTERN="*" | ||
export REPO_DIR="$PWD" | ||
} | ||
|
||
@test "latest_tag" { | ||
regex="v[0-9]+\.[0-9]+\.[0-9]+" | ||
run git-latest-tag.sh | ||
[ "$status" -eq 0 ] | ||
if [[ ! $output =~ $regex ]]; then | ||
echo "Output does not match regex: $regex" | ||
exit 1 | ||
fi | ||
} | ||
|
||
@test "tag_v1.0.0" { | ||
export PATTERN="v1.0.0" | ||
tag="v1.0.0" | ||
tag_sha="93891a5cfd55868bdfbd145ed8016ea8c63e37be" | ||
run git-latest-tag.sh | ||
|
||
[ "$status" -eq 0 ] | ||
[ "$output" = "Tag for the pattern $PATTERN is $tag ($tag_sha)" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters