2022-05-14 17:07:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-05-14 05:56:57 +00:00
|
|
|
# Artifact Naming Scheme:
|
2024-01-06 20:44:44 +00:00
|
|
|
# PCSX2-<OS>-Qt-[BUILD_SYSTEM]-[ARCH]-[SIMD]-[pr\[PR_NUM\]]-[title|sha\[SHA|PR_TITLE\]
|
2022-05-14 17:07:57 +00:00
|
|
|
# -- limited to 200 chars
|
2022-05-14 05:56:57 +00:00
|
|
|
# Outputs:
|
|
|
|
# - artifact-name
|
|
|
|
|
2024-01-06 20:44:44 +00:00
|
|
|
# Example - PCSX2-linux-Qt-x64-flatpak-sse4-sha[e880a2749]
|
|
|
|
|
2022-05-14 05:56:57 +00:00
|
|
|
# Inputs as env-vars
|
2024-01-06 20:44:44 +00:00
|
|
|
# PREFIX
|
2022-05-14 05:56:57 +00:00
|
|
|
# EVENT_NAME
|
|
|
|
# PR_TITLE
|
|
|
|
# PR_NUM
|
|
|
|
# PR_SHA
|
|
|
|
|
2024-01-06 20:44:44 +00:00
|
|
|
if [[ -z "${PREFIX}" ]]; then
|
|
|
|
echo "PREFIX is not set, can't name artifact without it!"
|
|
|
|
exit 1
|
2022-05-14 05:56:57 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-06 20:44:44 +00:00
|
|
|
NAME="${PREFIX}"
|
2022-05-23 03:33:32 +00:00
|
|
|
|
2022-05-14 05:56:57 +00:00
|
|
|
# Add PR / Commit Metadata
|
2022-05-14 17:07:57 +00:00
|
|
|
if [ "$EVENT_NAME" == "pull_request" ]; then
|
2022-05-14 05:56:57 +00:00
|
|
|
PR_SHA=$(git rev-parse --short "${PR_SHA}")
|
|
|
|
if [ ! -z "${PR_NUM}" ]; then
|
|
|
|
NAME="${NAME}-pr[${PR_NUM}]"
|
|
|
|
fi
|
|
|
|
NAME="${NAME}-sha[${PR_SHA}]"
|
|
|
|
if [ ! -z "${PR_TITLE}" ]; then
|
|
|
|
PR_TITLE=$(echo "${PR_TITLE}" | tr -cd '[a-zA-Z0-9[:space:]]_-')
|
2022-05-14 17:07:57 +00:00
|
|
|
NAME="${NAME}-title[${PR_TITLE}"
|
2022-05-14 05:56:57 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
SHA=$(git rev-parse --short "$GITHUB_SHA")
|
|
|
|
NAME="${NAME}-sha[${SHA}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Trim the Name
|
|
|
|
NAME=$(printf "%.199s]" "$NAME")
|
2022-05-14 17:07:57 +00:00
|
|
|
echo "${NAME}"
|
2022-10-19 21:49:51 +00:00
|
|
|
echo "artifact-name=${NAME}" >> "$GITHUB_OUTPUT"
|