-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (84 loc) · 2.82 KB
/
Copy pathpublish_jsr.yml
File metadata and controls
100 lines (84 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: 'Publish JSR'
description: |
This workflow serializes the build binary to Base64 and generates a JSON file with meta data about the file.
The file then gets published to JSR (@serial/cpp-bindings-linux).
on:
workflow_call:
inputs:
publish:
description: 'Whether to actually publish'
required: true
type: boolean
version:
description: 'Package version'
required: true
type: string
matrix:
description: 'JSON matrix (same shape as setup-matrix output) describing each target/arch'
required: true
type: string
artifact-name-prefix:
description: 'Common prefix of the per-target binary artifact names (artifact is "<prefix>-<target>")'
required: true
type: string
ffi-artifact-name:
description: 'Name of the combined FFI metadata artifact'
required: true
type: string
permissions:
contents: read
id-token: write
jobs:
publish-jsr:
name: 'Publish JSR'
runs-on: ubuntu-latest
steps:
- name: 'Checkout repository'
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: 'Setup Deno'
uses: denoland/setup-deno@v2
with:
deno-version: '2.x'
- name: 'Download binaries'
uses: actions/download-artifact@v8
with:
pattern: '${{ inputs.artifact-name-prefix }}-*'
path: artifacts/binaries
- name: 'Download FFI metadata'
uses: actions/download-artifact@v8
with:
name: ${{ inputs.ffi-artifact-name }}
path: artifacts/ffi
- name: 'Prepare files for JSR'
env:
MATRIX_JSON: ${{ inputs.matrix }}
PREFIX: ${{ inputs.artifact-name-prefix }}
run: |
echo "${MATRIX_JSON}" | jq -c '.include[]' | while read -r entry; do
target=$(jq -r '.target' <<< "${entry}")
arch=$(jq -r '.arch' <<< "${entry}")
mkdir -p "./jsr/bin/${arch}"
cp "./artifacts/binaries/${PREFIX}-${target}/libcpp_bindings_linux.so" \
"./jsr/bin/${arch}/library.so"
cp "./artifacts/ffi/${arch}.ffi.json" \
"./jsr/bin/${arch}/ffi.json"
./jsr/scripts/binary_to_json.sh \
"./jsr/bin/${arch}/library.so" \
"./jsr/bin/${arch}/library.json" \
"${target}"
done
./jsr/scripts/set_version.sh \
jsr/jsr.json \
"${{ inputs.version }}"
- name: 'Publish package to JSR (normal)'
if: inputs.publish
working-directory: jsr
run: |
deno publish --allow-dirty
- name: 'Publish package to JSR (dry-run)'
if: ${{ !inputs.publish }}
working-directory: jsr
run: |
deno publish --allow-dirty --dry-run