mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 05:16:44 +08:00
fix(ci): 产物构建与上传
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user