Skip to content

Commit

Permalink
Check the git message before attempting to build; Add some more delay…
Browse files Browse the repository at this point in the history
… to prevent race conditions; Fix iOS
  • Loading branch information
OoLunar committed May 24, 2024
1 parent b621abc commit 535af6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
25 changes: 11 additions & 14 deletions .github/scripts/package-opus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ git fetch --tags
OPUS_VERSION="$(git describe --tags $(git rev-list --tags --max-count=1))"
echo "OPUS_VERSION=$OPUS_VERSION" >> $GITHUB_ENV

# Check if the output file exists and if we've already built it for this version
EXPORT_DIR="$WORKSPACE/libs/libopus/$RID/native/"
if [ -f "$EXPORT_DIR/$FILE" ]; then
COMMIT_MESSAGE="$(git log -1 --pretty=%B -- "$EXPORT_DIR/$FILE")"
if [[ "$COMMIT_MESSAGE" == *"$OPUS_VERSION"* ]]; then
echo "Already built $FILE for $OPUS_VERSION"
exit 0
fi
fi

# Checkout the latest tag
git checkout "$OPUS_VERSION"

Expand All @@ -21,23 +31,10 @@ cmake --build build --config Release

EXPORT_DIR="$WORKSPACE/libs/libopus/$RID/native/"

# Do NOT exit on error
set +e

# Check if the output file has changed, since sometimes Git struggles on Windows
cmp --silent build/$FIND_FILE "$EXPORT_DIR/$FILE"
if [ $? -eq 0 ]; then
echo 'No changes detected'
exit 0
fi

# Exit on error
set -e

# Move the output file to the correct location
mkdir -p "$EXPORT_DIR"
rm -f "$EXPORT_DIR/$FILE"
mv build/$FIND_FILE "$EXPORT_DIR/$FILE"

# Delay committing to prevent race conditions
sleep "$(( $JOB_INDEX * 2 ))"
sleep "$(( $JOB_INDEX * 5 ))"
26 changes: 11 additions & 15 deletions .github/scripts/package-sodium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,26 @@ git fetch --tags
SODIUM_VERSION="$(git describe --tags $(git rev-list --tags --max-count=1))"
echo "SODIUM_VERSION=$SODIUM_VERSION" >> $GITHUB_ENV

# Check if the output file exists and if we've already built it for this version
EXPORT_DIR="$WORKSPACE/libs/libsodium/$RID/native/"
if [ -f "$EXPORT_DIR/$FILE" ]; then
COMMIT_MESSAGE="$(git log -1 --pretty=%B -- "$EXPORT_DIR/$FILE")"
if [[ "$COMMIT_MESSAGE" == *"$SODIUM_VERSION"* ]]; then
echo "Already built $FILE for $SODIUM_VERSION"
exit 0
fi
fi

# Checkout the latest tag
git checkout "$SODIUM_VERSION"

# Build the library
$COMMAND
EXPORT_DIR="$WORKSPACE/libs/libsodium/$RID/native/"

# Do NOT exit on error
set +e

# Check if the output file has changed, since sometimes Git struggles on Windows
cmp --silent "$OUTPUT_FILE" "$EXPORT_DIR/$FILE"
if [ $? -eq 0 ]; then
echo 'No changes detected'
exit 0
fi

# Exit on error
set -e

# Move the output file to the correct location
mkdir -p "$EXPORT_DIR"
rm -f "$EXPORT_DIR/$FILE"
mv "$OUTPUT_FILE" "$EXPORT_DIR/$FILE"

# Delay committing to prevent race conditions
sleep "$(( $JOB_INDEX * 2 ))"
sleep "$(( $JOB_INDEX * 5 ))"

0 comments on commit 535af6c

Please sign in to comment.