Skip to content

Commit bf4c1a3

Browse files
committed
feat: Refactor file copy and fixed BINARY_FILE_NAME
1 parent d3a1f1b commit bf4c1a3

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

‎.github/workflows/publish_jsr.yml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ jobs:
4848

4949
- name: 'Prepare files for JSR'
5050
run: |
51-
mkdir -p ./jsr/bin
52-
53-
cp ./artifacts/libcpp_bindings_linux.so ./jsr/bin/x86_64.so
51+
./jsr/scripts/copy_binary.sh \
52+
./artifacts/libcpp_bindings_linux.so \
53+
./jsr/bin/x86_64.so
5454
55-
./jsr/scripts/set_version.sh jsr/jsr.json "${{ inputs.version }}"
55+
./jsr/scripts/set_version.sh \
56+
jsr/jsr.json \
57+
"${{ inputs.version }}"
5658
5759
./jsr/scripts/binary_to_json.sh \
5860
./artifacts/libcpp_bindings_linux.so \

‎jsr/scripts/binary_to_json.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ if [ ! -f "$BINARY_FILE_PATH" ]; then
1515
exit 1
1616
fi
1717

18-
FILENAME=$(basename "$BINARY_FILE_PATH")
18+
BINARY_FILE_NAME=$(basename "$BINARY_FILE_PATH")
1919

20-
mkdir -p $(basename "$JSON_FILE_PATH")
20+
mkdir -p $(dirname "$JSON_FILE_PATH")
2121

2222
BASE64_DATA=$(base64 "$BINARY_FILE_PATH" | tr -d '\n')
2323

2424
jq -n \
2525
--arg target "$TARGET" \
26-
--arg filename "$FILENAME" \
26+
--arg filename "$BINARY_FILE_NAME" \
2727
--arg data "$BASE64_DATA" \
2828
'{
2929
target: $target,

‎jsr/scripts/copy_binary.sh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
if [ "$#" -ne 2 ]; then
5+
echo "Usage: $0 <binaryFilePath> <destinationFilePath>" >&2
6+
exit 1
7+
fi
8+
9+
BINARY_FILE_PATH=$1
10+
DESTINATION_FILE_PATH=$2
11+
12+
if [ ! -f "$BINARY_FILE_PATH" ]; then
13+
echo "Error: Binary path is not a file: $BINARY_FILE_PATH" >&2
14+
exit 1
15+
fi
16+
17+
mkdir -p $(dirname "$DESTINATION_FILE_PATH")
18+
19+
cp "$BINARY_FILE_PATH" "$DESTINATION_FILE_PATH"

0 commit comments

Comments
 (0)