Skip to content

Commit

Permalink
Export sodium packaging to a script
Browse files Browse the repository at this point in the history
  • Loading branch information
OoLunar committed May 24, 2024
1 parent 804ac8d commit 35f6781
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 19 deletions.
38 changes: 38 additions & 0 deletions .github/scripts/package-sodium.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Do NOT exit on error
set +e

# Create Sodium dir
mkdir -p "$WORKSPACE/libs/sodium"
cd "$WORKSPACE/libs/sodium"

# Clone the repository
git clone https://github.com/jedisct1/libsodium.git .
git fetch --tags

# Export the latest tag
SODIUM_VERSION="$(git describe --tags $(git rev-list --tags --max-count=1))"
echo "SODIUM_VERSION=$SODIUM_VERSION" >> $GITHUB_ENV

# Checkout the latest tag
git checkout "$SODIUM_VERSION"

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

# 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

# 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 "$(( '${{ strategy.job-index }}' * 2 ))"
26 changes: 7 additions & 19 deletions .github/workflows/sodium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,15 @@ jobs:
- name: Setup Android SDK
if: contains(matrix.config.rid, 'android')
uses: android-actions/setup-android@v3
- name: Build on ${{ matrix.config.name }}
- name: "Build ${{ matrix.config.file }}"
shell: bash
continue-on-error: true
run: |
git clone https://github.com/jedisct1/libsodium.git libs/sodium
cd libs/sodium
git fetch --tags
SODIUM_VERSION="$(git describe --tags $(git rev-list --tags --max-count=1))"
echo "SODIUM_VERSION=$SODIUM_VERSION" >> $GITHUB_ENV
git checkout "$SODIUM_VERSION"
${{ matrix.config.command }}
cmp --silent '${{ matrix.config.output-file }}' '${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }}'
if [ $? -eq 0 ]; then
echo 'No changes detected'
exit 0
fi
mkdir -p '${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native'
rm -f '${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }}'
mv '${{ matrix.config.output-file }}' '${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }}'
sleep "$(( '${{ strategy.job-index }}' * 2 ))"
export WORKSPACE='${{ github.workspace }}'
export COMMAND='${{ matrix.config.command }}'
export OUTPUT_FILE='${{ matrix.config.output-file }}'
export FILE='${{ matrix.config.file }}'
export RID='${{ matrix.config.rid }}'
bash .github/scripts/package-sodium.sh
- name: "Update ${{ matrix.config.rid }}"
uses: EndBug/add-and-commit@v9
with:
Expand Down

0 comments on commit 35f6781

Please sign in to comment.