move bundle upload to its own script

This commit is contained in:
David Holdeman 2024-01-29 07:04:48 -06:00 committed by rusefillc
parent 71716f3c4e
commit c0c8b69f96
3 changed files with 34 additions and 40 deletions

View File

@ -602,6 +602,11 @@ jobs:
if: ${{ env.full == 'true' }} if: ${{ env.full == 'true' }}
run: bash misc/jenkins/compile_other_versions/prepare_bundle.sh ${{matrix.build-target}} "firmware/tunerstudio/generated/rusefi_${{matrix.short-board-name}}.ini" ${{ github.ref_name }} ${{ toJSON(inputs.lts) }} run: bash misc/jenkins/compile_other_versions/prepare_bundle.sh ${{matrix.build-target}} "firmware/tunerstudio/generated/rusefi_${{matrix.short-board-name}}.ini" ${{ github.ref_name }} ${{ toJSON(inputs.lts) }}
- name: Upload Bundle
if: ${{ env.full == 'true' }}
working-directory: ./artifacts
run: bash ../firmware/bin/upload_bundle.sh ${{matrix.build-target}}
- name: Add Bundles to Release - name: Add Bundles to Release
if: ${{ env.full == 'true' && env.upload == 'release' }} if: ${{ env.full == 'true' && env.upload == 'release' }}
uses: ncipollo/release-action@v1.14.0 uses: ncipollo/release-action@v1.14.0

27
firmware/bin/upload_bundle.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
SCRIPT_NAME=$(basename "$0")
FULL_BUNDLE_FILE="rusefi_bundle_$1.zip"
UPDATE_BUNDLE_FILE="rusefi_bundle_$1_autoupdate.zip"
if [ -n "$RUSEFI_SSH_USER" ]; then
echo "$SCRIPT_NAME: Uploading full bundle"
RET=0
if [ "${LTS}" = "true" ]; then
tar -czf - $FULL_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p build_server/lts/$1; tar -xzf - -C build_server/lts/$1"
RET=$((RET+$?))
tar -czf - $UPDATE_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p build_server/lts/$1/autoupdate; tar -xzf - -C build_server/lts/$1/autoupdate"
RET=$((RET+$?))
else
tar -czf - $FULL_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "tar -xzf - -C build_server"
RET=$((RET+$?))
tar -czf - $UPDATE_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p build_server/autoupdate; tar -xzf - -C build_server/autoupdate"
RET=$((RET+$?))
fi
if [ $RET -ne 0 ]; then
echo "$SCRIPT_NAME: Bundle upload failed"
exit 1
fi
else
echo "$SCRIPT_NAME: Upload not configured"
fi

View File

@ -154,52 +154,14 @@ pwd
zip -r ../$FULL_BUNDLE_FILE * zip -r ../$FULL_BUNDLE_FILE *
[ $? -eq 0 ] || (echo "$SCRIPT_NAME: ERROR INVOKING zip"; exit 1) [ $? -eq 0 ] || (echo "$SCRIPT_NAME: ERROR INVOKING zip"; exit 1)
echo "$SCRIPT_FILE: Bundle $FULL_BUNDLE_FILE ready" echo "$SCRIPT_NAME: Bundle $FULL_BUNDLE_FILE ready"
cd .. cd ..
ls -l $FULL_BUNDLE_FILE ls -l $FULL_BUNDLE_FILE
[ -e $FULL_BUNDLE_FILE ] || { echo "$SCRIPT_NAME: ERROR not found $FULL_BUNDLE_FILE"; exit 1; } [ -e $FULL_BUNDLE_FILE ] || { echo "$SCRIPT_NAME: ERROR not found $FULL_BUNDLE_FILE"; exit 1; }
ls -l $UPDATE_BUNDLE_FILE ls -l $UPDATE_BUNDLE_FILE
cd artifacts echo "$SCRIPT_NAME: We are back in root directory"
if [ -n "$RUSEFI_SSH_USER" ]; then
echo "$SCRIPT_NAME: Uploading full bundle"
retVal=0
if [ "${LTS}" = "true" ]; then
REMOTE_DESTINATION=${LTS_FOLDER}
else
REMOTE_DESTINATION=build_server
fi
tar -czf - $FULL_BUNDLE_SHORT_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p ${REMOTE_DESTINATION}; tar -xzf - -C ${REMOTE_DESTINATION}"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "full bundle upload failed"
exit 1
fi
else
echo "Upload not configured"
fi
if [ -n "$RUSEFI_SSH_USER" ]; then
retVal=0
if [ "${LTS}" = "true" ]; then
REMOTE_DESTINATION=${LTS_FOLDER}/autoupdate
else
REMOTE_DESTINATION=build_server/autoupdate
fi
tar -czf - $UPDATE_BUNDLE_SHORT_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p ${REMOTE_DESTINATION}; tar -xzf - -C ${REMOTE_DESTINATION}"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "autoupdate upload failed"
exit 1
fi
else
echo "Upload not configured"
fi
cd ..
pwd pwd
ls -l artifacts ls -l artifacts