Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .build_counter +1 -1
- 1.deploy.sh +13 -18
.build_counter
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
13
|
1.deploy.sh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
|
| 3 |
# --- CONFIGURATION ---
|
| 4 |
-
WORKFLOW_ID="221629785" #
|
| 5 |
ARTIFACT_NAME="tldraw-bundled-hf-debug.apk"
|
| 6 |
TARGET_DIR="/storage/emulated/0/Download/MY-T-APP"
|
| 7 |
COUNTER_FILE=".build_counter"
|
|
@@ -22,9 +22,7 @@ echo "π Starting Hugging Face Upload..."
|
|
| 22 |
--exclude "*.log"
|
| 23 |
|
| 24 |
# 2. GIT INCREMENTAL COMMIT
|
| 25 |
-
# Check/Create counter file
|
| 26 |
if [ ! -f "$COUNTER_FILE" ]; then echo 0 > "$COUNTER_FILE"; fi
|
| 27 |
-
# Read, Increment, Save
|
| 28 |
CURRENT_COUNT=$(cat "$COUNTER_FILE")
|
| 29 |
NEXT_COUNT=$((CURRENT_COUNT + 1))
|
| 30 |
echo "$NEXT_COUNT" > "$COUNTER_FILE"
|
|
@@ -37,18 +35,13 @@ git commit -m "$COMMIT_MSG"
|
|
| 37 |
git push
|
| 38 |
|
| 39 |
# 3. TRIGGER GITHUB ACTION
|
| 40 |
-
echo "π¬ Triggering GitHub Action
|
| 41 |
gh workflow run "$WORKFLOW_ID"
|
| 42 |
-
|
| 43 |
-
# Give GitHub a moment to register the run
|
| 44 |
echo "β³ Waiting for run to start..."
|
| 45 |
sleep 5
|
| 46 |
-
|
| 47 |
-
# Get the ID of the run we just triggered (the most recent one)
|
| 48 |
RUN_ID=$(gh run list --workflow "$WORKFLOW_ID" --limit 1 --json databaseId -q '.[0].databaseId')
|
| 49 |
echo "π Watching Run ID: $RUN_ID"
|
| 50 |
|
| 51 |
-
# Watch the run until it finishes. If it fails, exit script.
|
| 52 |
gh run watch "$RUN_ID" --exit-status
|
| 53 |
if [ $? -ne 0 ]; then
|
| 54 |
echo "β Build Failed on GitHub! Check logs."
|
|
@@ -57,20 +50,22 @@ fi
|
|
| 57 |
|
| 58 |
# 4. DOWNLOAD AND MOVE ARTIFACT
|
| 59 |
echo "π₯ Downloading artifact..."
|
| 60 |
-
# Create target directory if it doesn't exist
|
| 61 |
mkdir -p "$TARGET_DIR"
|
| 62 |
-
|
| 63 |
-
# Download to a temporary folder
|
| 64 |
mkdir -p temp_artifact
|
|
|
|
|
|
|
| 65 |
gh run download "$RUN_ID" -n "$ARTIFACT_NAME" --dir temp_artifact
|
| 66 |
|
| 67 |
-
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
unzip -o temp_artifact/*.zip -d temp_artifact/
|
| 71 |
-
find temp_artifact -name "*.apk" -exec mv {} "$TARGET_DIR/" \;
|
| 72 |
|
| 73 |
# Cleanup
|
| 74 |
rm -rf temp_artifact
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
|
| 3 |
# --- CONFIGURATION ---
|
| 4 |
+
WORKFLOW_ID="221629785" # Build Android (Bundled HuggingFace)
|
| 5 |
ARTIFACT_NAME="tldraw-bundled-hf-debug.apk"
|
| 6 |
TARGET_DIR="/storage/emulated/0/Download/MY-T-APP"
|
| 7 |
COUNTER_FILE=".build_counter"
|
|
|
|
| 22 |
--exclude "*.log"
|
| 23 |
|
| 24 |
# 2. GIT INCREMENTAL COMMIT
|
|
|
|
| 25 |
if [ ! -f "$COUNTER_FILE" ]; then echo 0 > "$COUNTER_FILE"; fi
|
|
|
|
| 26 |
CURRENT_COUNT=$(cat "$COUNTER_FILE")
|
| 27 |
NEXT_COUNT=$((CURRENT_COUNT + 1))
|
| 28 |
echo "$NEXT_COUNT" > "$COUNTER_FILE"
|
|
|
|
| 35 |
git push
|
| 36 |
|
| 37 |
# 3. TRIGGER GITHUB ACTION
|
| 38 |
+
echo "π¬ Triggering GitHub Action..."
|
| 39 |
gh workflow run "$WORKFLOW_ID"
|
|
|
|
|
|
|
| 40 |
echo "β³ Waiting for run to start..."
|
| 41 |
sleep 5
|
|
|
|
|
|
|
| 42 |
RUN_ID=$(gh run list --workflow "$WORKFLOW_ID" --limit 1 --json databaseId -q '.[0].databaseId')
|
| 43 |
echo "π Watching Run ID: $RUN_ID"
|
| 44 |
|
|
|
|
| 45 |
gh run watch "$RUN_ID" --exit-status
|
| 46 |
if [ $? -ne 0 ]; then
|
| 47 |
echo "β Build Failed on GitHub! Check logs."
|
|
|
|
| 50 |
|
| 51 |
# 4. DOWNLOAD AND MOVE ARTIFACT
|
| 52 |
echo "π₯ Downloading artifact..."
|
|
|
|
| 53 |
mkdir -p "$TARGET_DIR"
|
|
|
|
|
|
|
| 54 |
mkdir -p temp_artifact
|
| 55 |
+
|
| 56 |
+
# gh run download AUTOMATICALLY unzips the file into the directory
|
| 57 |
gh run download "$RUN_ID" -n "$ARTIFACT_NAME" --dir temp_artifact
|
| 58 |
|
| 59 |
+
echo "π Moving APK to Android storage..."
|
| 60 |
+
# Find the apk (wherever it is inside the artifact) and move it
|
| 61 |
+
FOUND_COUNT=$(find temp_artifact -name "*.apk" -exec mv {} "$TARGET_DIR/" \; -print | wc -l)
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# Cleanup
|
| 64 |
rm -rf temp_artifact
|
| 65 |
|
| 66 |
+
if [ "$FOUND_COUNT" -eq "0" ]; then
|
| 67 |
+
echo "β ERROR: No APK file was found in the downloaded artifact."
|
| 68 |
+
exit 1
|
| 69 |
+
else
|
| 70 |
+
echo "β
SUCCESS! $FOUND_COUNT APK(s) moved to: $TARGET_DIR"
|
| 71 |
+
fi
|