2023-06-27 02:42:00 +02:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
2023-10-09 08:56:01 +02:00
|
|
|
# Determine the full revision name.
|
2023-06-27 02:42:00 +02:00
|
|
|
GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"
|
|
|
|
GITREV="`git show -s --format='%h'`"
|
2024-04-02 16:15:33 +02:00
|
|
|
REV_NAME="lime3ds-$OS-$TARGET-$GITDATE-$GITREV"
|
2023-06-27 02:42:00 +02:00
|
|
|
|
2023-10-09 08:56:01 +02:00
|
|
|
# Determine the name of the release being built.
|
2024-04-02 14:30:15 +02:00
|
|
|
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
|
2024-04-02 16:15:33 +02:00
|
|
|
RELEASE_NAME=lime3ds-$GITHUB_REF_NAME
|
|
|
|
REV_NAME="lime3ds-$GITHUB_REF_NAME-$OS-$TARGET"
|
2023-06-27 02:42:00 +02:00
|
|
|
else
|
2024-04-02 16:15:33 +02:00
|
|
|
RELEASE_NAME=lime3ds-head
|
2023-06-27 02:42:00 +02:00
|
|
|
fi
|
|
|
|
|
2023-10-09 08:56:01 +02:00
|
|
|
# Archive and upload the artifacts.
|
|
|
|
mkdir artifacts
|
2023-06-27 02:42:00 +02:00
|
|
|
|
2023-10-09 08:56:01 +02:00
|
|
|
function pack_artifacts() {
|
|
|
|
ARTIFACTS_PATH="$1"
|
|
|
|
|
|
|
|
# Set up root directory for archive.
|
2023-06-27 02:42:00 +02:00
|
|
|
mkdir "$REV_NAME"
|
2023-10-09 08:56:01 +02:00
|
|
|
if [ -f "$ARTIFACTS_PATH" ]; then
|
|
|
|
mv "$ARTIFACTS_PATH" "$REV_NAME"
|
|
|
|
|
|
|
|
# Use file extension to differentiate archives.
|
|
|
|
FILENAME=$(basename "$ARTIFACT")
|
|
|
|
EXTENSION="${FILENAME##*.}"
|
|
|
|
ARCHIVE_NAME="$REV_NAME.$EXTENSION"
|
|
|
|
else
|
|
|
|
mv "$ARTIFACTS_PATH"/* "$REV_NAME"
|
|
|
|
|
|
|
|
ARCHIVE_NAME="$REV_NAME"
|
|
|
|
fi
|
2023-06-27 02:42:00 +02:00
|
|
|
|
2023-10-09 08:56:01 +02:00
|
|
|
# Create .zip/.tar.gz
|
2023-06-27 02:42:00 +02:00
|
|
|
if [ "$OS" = "windows" ]; then
|
2023-10-09 08:56:01 +02:00
|
|
|
ARCHIVE_FULL_NAME="$ARCHIVE_NAME.zip"
|
|
|
|
powershell Compress-Archive "$REV_NAME" "$ARCHIVE_FULL_NAME"
|
2024-09-03 18:12:24 +02:00
|
|
|
elif [ "$OS" = "android" ] || [ "$OS" = "macos" ]; then
|
2023-10-09 08:56:01 +02:00
|
|
|
ARCHIVE_FULL_NAME="$ARCHIVE_NAME.zip"
|
|
|
|
zip -r "$ARCHIVE_FULL_NAME" "$REV_NAME"
|
2023-06-27 02:42:00 +02:00
|
|
|
else
|
2023-10-09 08:56:01 +02:00
|
|
|
ARCHIVE_FULL_NAME="$ARCHIVE_NAME.tar.gz"
|
|
|
|
tar czvf "$ARCHIVE_FULL_NAME" "$REV_NAME"
|
2023-06-27 02:42:00 +02:00
|
|
|
fi
|
2023-10-09 08:56:01 +02:00
|
|
|
mv "$ARCHIVE_FULL_NAME" artifacts/
|
2024-04-13 01:10:43 +02:00
|
|
|
# Clean up created rev artifacts directory.
|
|
|
|
rm -rf "$REV_NAME"
|
2023-10-09 08:56:01 +02:00
|
|
|
}
|
2023-06-27 02:42:00 +02:00
|
|
|
|
2023-12-20 03:51:47 +01:00
|
|
|
if [ -n "$UNPACKED" ]; then
|
|
|
|
# Copy the artifacts to be uploaded unpacked.
|
|
|
|
for ARTIFACT in build/bundle/*; do
|
|
|
|
FILENAME=$(basename "$ARTIFACT")
|
|
|
|
EXTENSION="${FILENAME##*.}"
|
|
|
|
|
|
|
|
mv "$ARTIFACT" "artifacts/$REV_NAME.$EXTENSION"
|
|
|
|
done
|
|
|
|
elif [ -n "$PACK_INDIVIDUALLY" ]; then
|
2023-10-09 08:56:01 +02:00
|
|
|
# Pack and upload the artifacts one-by-one.
|
2023-06-27 02:42:00 +02:00
|
|
|
for ARTIFACT in build/bundle/*; do
|
2023-10-09 08:56:01 +02:00
|
|
|
pack_artifacts "$ARTIFACT"
|
2023-06-27 02:42:00 +02:00
|
|
|
done
|
2023-12-20 03:51:47 +01:00
|
|
|
else
|
|
|
|
# Pack all of the artifacts into a single archive.
|
|
|
|
pack_artifacts build/bundle
|
2023-06-27 02:42:00 +02:00
|
|
|
fi
|