Skip to content

Commit cb3d1f2

Browse files
committed
allow specifying extract location
1 parent a8959ce commit cb3d1f2

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

etc/bin/extract-build-artifact.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,36 @@
2020
set -e
2121

2222
ARTIFACT_NAME=$1
23-
2423
if [ -z "${ARTIFACT_NAME}" ]; then
25-
echo "Usage: $0 <artifact-name>"
24+
echo "Usage: $0 <artifact-name> <optional location>"
2625
exit 1
2726
fi
2827

2928
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
29+
EXTRACT_LOCATION="${2:-${SCRIPT_DIR}/results}"
30+
31+
echo "Looking for build artifact ${ARTIFACT_NAME} in ${EXTRACT_LOCATION}"
3032

31-
if [ -z "${SCRIPT_DIR}/results/first/${ARTIFACT_NAME}" ]; then
32-
echo "First Artifact Not found: $ARTIFACT_NAME could not be found under ${SCRIPT_DIR}/results/first/${ARTIFACT_NAME}"
33+
if [ -z "${EXTRACT_LOCATION}/first/${ARTIFACT_NAME}" ]; then
34+
echo "First Artifact Not found: ${ARTIFACT_NAME} could not be found under ${EXTRACT_LOCATION}/first/${ARTIFACT_NAME}"
3335
exit 1;
3436
else
35-
echo "First Artifact Found @ ${SCRIPT_DIR}/results/first/${ARTIFACT_NAME}"
37+
echo "First Artifact Found @ ${EXTRACT_LOCATION}/first/${ARTIFACT_NAME}"
3638
fi
37-
if [ -z "${SCRIPT_DIR}/results/second/${ARTIFACT_NAME}" ]; then
38-
echo "Second Artifact Not found: $ARTIFACT_NAME could not be found under ${SCRIPT_DIR}/results/second/${ARTIFACT_NAME}"
39+
if [ -z "${EXTRACT_LOCATION}/second/${ARTIFACT_NAME}" ]; then
40+
echo "Second Artifact Not found: ${ARTIFACT_NAME} could not be found under ${EXTRACT_LOCATION}/second/${ARTIFACT_NAME}"
3941
exit 1;
4042
else
41-
echo "Second Artifact Found @ ${SCRIPT_DIR}/results/first/${ARTIFACT_NAME}"
43+
echo "Second Artifact Found @ ${EXTRACT_LOCATION}/first/${ARTIFACT_NAME}"
4244
fi
4345

44-
rm -rf "${SCRIPT_DIR}/results/firstArtifact" || true
45-
rm -rf "${SCRIPT_DIR}/results/secondArtifact" || true
46+
rm -rf "${EXTRACT_LOCATION}/firstArtifact" || true
47+
rm -rf "${EXTRACT_LOCATION}/secondArtifact" || true
48+
49+
echo " Extracting ${ARTIFACT_NAME} from first to ${EXTRACT_LOCATION}/firstArtifact"
50+
unzip -q "${EXTRACT_LOCATION}/first/${ARTIFACT_NAME}" -d "${EXTRACT_LOCATION}/firstArtifact"
51+
echo " ✅ First Artifact Extracted"
4652

47-
unzip "${SCRIPT_DIR}/results/first/${ARTIFACT_NAME}" -d "${SCRIPT_DIR}/results/firstArtifact"
48-
unzip "${SCRIPT_DIR}/results/second/${ARTIFACT_NAME}" -d "${SCRIPT_DIR}/results/secondArtifact"
53+
echo " Extracting ${ARTIFACT_NAME} from second to ${EXTRACT_LOCATION}/secondArtifact"
54+
unzip -q "${EXTRACT_LOCATION}/second/${ARTIFACT_NAME}" -d "${EXTRACT_LOCATION}/secondArtifact"
55+
echo " ✅ Second Artifact Extracted"

0 commit comments

Comments
 (0)