From 3add5f73274d03af737bfd2ba322dbb6c4827839 Mon Sep 17 00:00:00 2001 From: oak <1722157266@QQ.com> Date: Tue, 21 Jul 2026 22:24:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BA=A7=E7=89=A9=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E4=B8=8E=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/bat.yml | 68 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/bat.yml b/.gitea/workflows/bat.yml index 2197cc2..d250168 100644 --- a/.gitea/workflows/bat.yml +++ b/.gitea/workflows/bat.yml @@ -70,7 +70,7 @@ jobs: - name: Build workspace shell: bash - run: source /var/lib/act_runner/env.sh && cargo build --workspace --locked + run: source /var/lib/act_runner/env.sh && cargo build --workspace --release --locked - name: Run clippy shell: bash @@ -79,3 +79,69 @@ jobs: - name: Run tests shell: bash run: source /var/lib/act_runner/env.sh && cargo test --workspace --locked + + - name: Package binary + shell: bash + run: | + set -euo pipefail + mkdir -p artifact + cp target/release/bat artifact/ + tar -czf bat-linux-x86_64.tar.gz -C artifact bat + sha256sum bat-linux-x86_64.tar.gz > bat-linux-x86_64.sha256 + + - name: Upload artifact + shell: bash + env: + ARTIFACT_NAME: bat-linux-x86_64 + ARTIFACT_PATH: | + bat-linux-x86_64.tar.gz + bat-linux-x86_64.sha256 + run: | + set -euo pipefail + + : "${ACTIONS_RUNTIME_URL:?missing ACTIONS_RUNTIME_URL}" + : "${ACTIONS_RUNTIME_TOKEN:?missing ACTIONS_RUNTIME_TOKEN}" + + ARTIFACT_ID=$(curl \ + -sS \ + -X POST \ + "${ACTIONS_RUNTIME_URL}/_apis/artifactcache/artifacts" \ + -H "Authorization: Bearer ${ACTIONS_RUNTIME_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{ + \"type\": \"actions_storage\", + \"name\": \"${ARTIFACT_NAME}\" + }" \ + | python3 -c ' +import sys,json +print(json.load(sys.stdin)["artifactId"]) +') + + echo "Artifact ID: ${ARTIFACT_ID}" + + ZIP_FILE="${ARTIFACT_NAME}.zip" + + zip -q "${ZIP_FILE}" ${ARTIFACT_PATH} + + SIZE=$(stat -c%s "${ZIP_FILE}") + + curl \ + -sS \ + -X PATCH \ + "${ACTIONS_RUNTIME_URL}/_apis/artifactcache/artifacts/${ARTIFACT_ID}" \ + -H "Authorization: Bearer ${ACTIONS_RUNTIME_TOKEN}" \ + -H "Content-Type: application/json" \ + --data-binary "@${ZIP_FILE}" + + + curl \ + -sS \ + -X POST \ + "${ACTIONS_RUNTIME_URL}/_apis/artifactcache/artifacts/${ARTIFACT_ID}" \ + -H "Authorization: Bearer ${ACTIONS_RUNTIME_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{ + \"size\": ${SIZE} + }" + + echo "Artifact uploaded: ${ARTIFACT_NAME}"