pcsx2/.github/workflows/scripts/common/name-artifacts.sh

58 lines
1.4 KiB
Bash
Raw Normal View History

2022-05-14 17:07:57 +00:00
#!/bin/bash
# Artifact Naming Scheme:
# PCSX2-<OS>-[ARCH]-[SIMD]-[pr\[PR_NUM\]]-[title|sha\[SHA|PR_TITLE\]
2022-05-14 17:07:57 +00:00
# -- limited to 200 chars
# Outputs:
# - artifact-name
# Inputs as env-vars
# OS
# BUILD_SYSTEM
# ARCH
# SIMD
# EVENT_NAME
# PR_TITLE
# PR_NUM
# PR_SHA
NAME=""
if [ "${OS}" == "macos" ]; then
# MacOS has combined binaries for x64 and ARM64.
NAME="PCSX2-${OS}"
elif [[ ("${OS}" == "windows" && "$BUILD_SYSTEM" != "cmake") ]]; then
NAME="PCSX2-${OS}-${ARCH}-${SIMD}"
else
NAME="PCSX2-${OS}-${ARCH}"
fi
# Add cmake if used to differentate it from msbuild builds
# Else the two artifacts will have the same name and the files will be merged
if [[ ! -z "${BUILD_SYSTEM}" ]]; then
2023-06-05 13:44:12 +00:00
if [[ "${BUILD_SYSTEM}" == "cmake" ]] || [[ "${BUILD_SYSTEM}" == "flatpak" ]]; then
NAME="${NAME}-${BUILD_SYSTEM}"
fi
fi
# Add PR / Commit Metadata
2022-05-14 17:07:57 +00:00
if [ "$EVENT_NAME" == "pull_request" ]; then
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}"
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}"
echo "artifact-name=${NAME}" >> "$GITHUB_OUTPUT"