-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
executable file
·35 lines (27 loc) · 1.01 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
set -euo pipefail
GITHUB_OUTPUT=${GITHUB_OUTPUT:-}
if [[ $GITHUB_REF != "refs/tags/"* ]]; then
echo "::warning::Skipping: This should only run on tags push or on release instead of '$GITHUB_EVENT_NAME'.";
exit 0;
fi
git fetch origin +refs/tags/*:refs/tags/*
NEW_TAG=${4:-"${GITHUB_REF/refs\/tags\//}"}
CURRENT_TAG=${3:-$(git tag -l --sort=-version:refname "*.*" | grep -v "$NEW_TAG" | head -1 || true)}
if [[ -z $CURRENT_TAG ]]; then
echo "::warning::Initial release detected unable to determine any tag diff."
echo "::warning::Setting release_type to $INPUT_INITIAL_RELEASE_TYPE."
cat <<EOF >> "$GITHUB_OUTPUT"
release_type=$INPUT_INITIAL_RELEASE_TYPE
old_version=$NEW_TAG
new_version=$NEW_TAG
EOF
exit 0;
fi
echo "::debug::Calculating diff..."
PART=$(wget -O - https://raw.githubusercontent.com/fsaintjacques/semver-tool/3.4.0/src/semver | bash -s diff "${CURRENT_TAG//v/}" "${NEW_TAG//v/}")
cat <<EOF >> "$GITHUB_OUTPUT"
release_type=$PART
old_version=$CURRENT_TAG
new_version=$NEW_TAG
EOF