diff --git a/.github/workflows/runner.yml b/.github/workflows/runner.yml index bbce3fb..6fcbc01 100644 --- a/.github/workflows/runner.yml +++ b/.github/workflows/runner.yml @@ -32,6 +32,10 @@ jobs: echo "Modification with sed failed." exit 1 fi + - name: Prepare cloud-init + run: | + sed -i "s/\$GITHUB_TOKEN/${{ secrets.PAT }}/" workflow-artifacts/cloud-init.txt + - name: Login via Az module uses: azure/login@v1 diff --git a/workflow-artifacts/cloud-init.txt b/workflow-artifacts/cloud-init.txt index 1c4f984..2a43cff 100644 --- a/workflow-artifacts/cloud-init.txt +++ b/workflow-artifacts/cloud-init.txt @@ -18,5 +18,19 @@ export PATH="$HOME/.cargo/bin:$PATH" git clone https://github.com/huggingface/candle.git /root/candle cd /root/candle -cargo build --example whisper --release +if cargo build --example whisper --release; then + FILE="/root/candle/target/release/examples/whisper" + MIME_TYPE=$(file -b --mime-type "$FILE") + TAG="v$(date +%Y%m%d%H%M%S)" + RELEASE_NAME="CPU Whisper Binary Release" + GITHUB_TOKEN="$GITHUB_TOKEN" # Token passed from GitHub Actions + + CREATE_RELEASE_RESPONSE=$(curl -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/json" -d "{\"tag_name\": \"$TAG\", \"name\": \"$RELEASE_NAME\"}" "https://api.github.com/repos/nogibjj/candle_scott_Azure_vm/releases") + UPLOAD_URL=$(echo $CREATE_RELEASE_RESPONSE | jq -r .upload_url | sed "s/{?name,label}//") + + curl -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: $MIME_TYPE" --data-binary @"$FILE" "$UPLOAD_URL?name=$(basename "$FILE")" +else + echo "Cargo build failed." +fi +