Skip to content

Commit f659901

Browse files
committed
Add proper release for pdf-runtime packages
1 parent bac6d70 commit f659901

7 files changed

Lines changed: 263 additions & 15 deletions

File tree

.changeset/config.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@
4141
"@embedpdf/snippet",
4242
"@embedpdf/react-pdf-viewer",
4343
"@embedpdf/vue-pdf-viewer",
44-
"@embedpdf/svelte-pdf-viewer"
44+
"@embedpdf/svelte-pdf-viewer",
45+
"@embedpdf/pdf-runtime",
46+
"@embedpdf/pdf-runtime-wasm32",
47+
"@embedpdf/pdf-runtime-darwin-arm64",
48+
"@embedpdf/pdf-runtime-darwin-x64",
49+
"@embedpdf/pdf-runtime-linux-x64",
50+
"@embedpdf/pdf-runtime-linux-arm64",
51+
"@embedpdf/pdf-runtime-linuxmusl-x64",
52+
"@embedpdf/pdf-runtime-linuxmusl-arm64",
53+
"@embedpdf/pdf-runtime-win32-x64",
54+
"@embedpdf/pdf-runtime-win32-arm64"
4555
]
4656
],
4757
"linked": [],

.github/workflows/build-pdf-runtime.yml

Lines changed: 164 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build PDF Runtime
22

33
on:
44
workflow_dispatch:
5+
workflow_call:
56
pull_request:
67
paths:
78
- 'packages/pdf-runtime/**'
@@ -40,34 +41,78 @@ jobs:
4041
with:
4142
node-version: 22
4243
cache: pnpm
43-
- if: ${{ !contains(matrix.target, 'linuxmusl') }}
44+
- name: Cache runtime payload
45+
id: payload-cache
46+
uses: actions/cache@v4
47+
with:
48+
path: packages/pdf-runtime/.cache/payloads/${{ matrix.target }}
49+
key: pdf-runtime-payload-${{ matrix.target }}-${{ hashFiles(
50+
'packages/pdf-runtime/pdf-runtime-build.json',
51+
'packages/pdf-runtime/scripts/build-target.sh',
52+
'packages/pdf-runtime/scripts/fetch-libpdfium.sh',
53+
'packages/pdf-runtime/build/generate-functions.mjs',
54+
'packages/pdf-runtime/build/generate-runtime-methods.mjs',
55+
'packages/pdf-runtime/build/generate-napi-binding.mjs',
56+
'packages/pdf-runtime/build/CMakeLists.txt',
57+
'packages/pdf-runtime/build/compile.sh',
58+
'packages/pdf-runtime/build/compile.esm.sh'
59+
) }}
60+
- if: steps.payload-cache.outputs.cache-hit == 'true'
61+
name: Restore payload from cache
62+
shell: bash
63+
run: |
64+
mkdir -p "packages/pdf-runtime/npm/${{ matrix.target }}"
65+
cp -R "packages/pdf-runtime/.cache/payloads/${{ matrix.target }}/." \
66+
"packages/pdf-runtime/npm/${{ matrix.target }}/"
67+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && !contains(matrix.target, 'linuxmusl') }}
4468
run: pnpm install --frozen-lockfile
45-
- if: ${{ !contains(matrix.target, 'linuxmusl') }}
69+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && !contains(matrix.target, 'linuxmusl') }}
4670
name: Install build tools
4771
run: sudo apt-get update && sudo apt-get install -y cmake clang lld
48-
- if: matrix.target == 'wasm32'
72+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && matrix.target == 'wasm32' }}
4973
name: Install Emscripten
5074
run: |
5175
git clone https://github.com/emscripten-core/emsdk.git "$RUNNER_TEMP/emsdk"
5276
"$RUNNER_TEMP/emsdk/emsdk" install "$EMSDK_VERSION"
5377
"$RUNNER_TEMP/emsdk/emsdk" activate "$EMSDK_VERSION"
5478
echo "$RUNNER_TEMP/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
5579
echo "$RUNNER_TEMP/emsdk/upstream/bin" >> "$GITHUB_PATH"
56-
- if: ${{ !contains(matrix.target, 'linuxmusl') }}
80+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && !contains(matrix.target, 'linuxmusl') }}
5781
name: Build target
5882
env:
5983
CC: clang
6084
CXX: clang++
6185
LDFLAGS: -fuse-ld=lld
6286
run: pnpm --filter @embedpdf/pdf-runtime build:target ${{ matrix.target }}
63-
- if: ${{ contains(matrix.target, 'linuxmusl') }}
87+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && contains(matrix.target, 'linuxmusl') }}
6488
name: Build musl target in Alpine
6589
run: |
6690
docker run --rm \
6791
-v "$GITHUB_WORKSPACE:/workspace" \
6892
-w /workspace \
6993
node:22-alpine \
7094
sh -lc "apk add --no-cache bash cmake clang g++ make python3 curl tar git && corepack enable && pnpm install --frozen-lockfile && pnpm --filter @embedpdf/pdf-runtime build:target ${{ matrix.target }}"
95+
- if: steps.payload-cache.outputs.cache-hit != 'true'
96+
name: Stage payload to cache path
97+
shell: bash
98+
run: |
99+
src="packages/pdf-runtime/npm/${{ matrix.target }}"
100+
dst="packages/pdf-runtime/.cache/payloads/${{ matrix.target }}"
101+
mkdir -p "$dst"
102+
case "${{ matrix.target }}" in
103+
wasm32)
104+
cp "$src/pdfium.js" "$src/pdfium.cjs" "$src/pdfium.wasm" "$dst/"
105+
;;
106+
win32-*)
107+
cp "$src/pdf-runtime.node" "$src/pdfium.dll" "$dst/"
108+
;;
109+
*)
110+
cp "$src/pdf-runtime.node" "$dst/"
111+
;;
112+
esac
113+
- name: Verify payload
114+
shell: bash
115+
run: bash packages/pdf-runtime/scripts/verify-packages.sh ${{ matrix.target }}
71116
- uses: actions/upload-artifact@v6
72117
with:
73118
name: pdf-runtime-${{ matrix.target }}
@@ -91,26 +136,60 @@ jobs:
91136
with:
92137
node-version: 22
93138
cache: pnpm
94-
- if: ${{ !contains(matrix.target, 'linuxmusl') }}
139+
- name: Cache runtime payload
140+
id: payload-cache
141+
uses: actions/cache@v4
142+
with:
143+
path: packages/pdf-runtime/.cache/payloads/${{ matrix.target }}
144+
key: pdf-runtime-payload-${{ matrix.target }}-${{ hashFiles(
145+
'packages/pdf-runtime/pdf-runtime-build.json',
146+
'packages/pdf-runtime/scripts/build-target.sh',
147+
'packages/pdf-runtime/scripts/fetch-libpdfium.sh',
148+
'packages/pdf-runtime/build/generate-functions.mjs',
149+
'packages/pdf-runtime/build/generate-runtime-methods.mjs',
150+
'packages/pdf-runtime/build/generate-napi-binding.mjs',
151+
'packages/pdf-runtime/build/CMakeLists.txt',
152+
'packages/pdf-runtime/build/compile.sh',
153+
'packages/pdf-runtime/build/compile.esm.sh'
154+
) }}
155+
- if: steps.payload-cache.outputs.cache-hit == 'true'
156+
name: Restore payload from cache
157+
shell: bash
158+
run: |
159+
mkdir -p "packages/pdf-runtime/npm/${{ matrix.target }}"
160+
cp -R "packages/pdf-runtime/.cache/payloads/${{ matrix.target }}/." \
161+
"packages/pdf-runtime/npm/${{ matrix.target }}/"
162+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && !contains(matrix.target, 'linuxmusl') }}
95163
run: pnpm install --frozen-lockfile
96-
- if: ${{ !contains(matrix.target, 'linuxmusl') }}
164+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && !contains(matrix.target, 'linuxmusl') }}
97165
name: Install build tools
98166
run: sudo apt-get update && sudo apt-get install -y cmake clang lld
99-
- if: ${{ !contains(matrix.target, 'linuxmusl') }}
167+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && !contains(matrix.target, 'linuxmusl') }}
100168
name: Build target
101169
env:
102170
CC: clang
103171
CXX: clang++
104172
LDFLAGS: -fuse-ld=lld
105173
run: pnpm --filter @embedpdf/pdf-runtime build:target ${{ matrix.target }}
106-
- if: ${{ contains(matrix.target, 'linuxmusl') }}
174+
- if: ${{ steps.payload-cache.outputs.cache-hit != 'true' && contains(matrix.target, 'linuxmusl') }}
107175
name: Build musl target in Alpine
108176
run: |
109177
docker run --rm \
110178
-v "$GITHUB_WORKSPACE:/workspace" \
111179
-w /workspace \
112180
node:22-alpine \
113181
sh -lc "apk add --no-cache bash cmake clang g++ make python3 curl tar git && corepack enable && pnpm install --frozen-lockfile && pnpm --filter @embedpdf/pdf-runtime build:target ${{ matrix.target }}"
182+
- if: steps.payload-cache.outputs.cache-hit != 'true'
183+
name: Stage payload to cache path
184+
shell: bash
185+
run: |
186+
src="packages/pdf-runtime/npm/${{ matrix.target }}"
187+
dst="packages/pdf-runtime/.cache/payloads/${{ matrix.target }}"
188+
mkdir -p "$dst"
189+
cp "$src/pdf-runtime.node" "$dst/"
190+
- name: Verify payload
191+
shell: bash
192+
run: bash packages/pdf-runtime/scripts/verify-packages.sh ${{ matrix.target }}
114193
- uses: actions/upload-artifact@v6
115194
with:
116195
name: pdf-runtime-${{ matrix.target }}
@@ -132,9 +211,45 @@ jobs:
132211
with:
133212
node-version: 22
134213
cache: pnpm
135-
- run: pnpm install --frozen-lockfile
136-
- name: Build target
214+
- name: Cache runtime payload
215+
id: payload-cache
216+
uses: actions/cache@v4
217+
with:
218+
path: packages/pdf-runtime/.cache/payloads/${{ matrix.target }}
219+
key: pdf-runtime-payload-${{ matrix.target }}-${{ hashFiles(
220+
'packages/pdf-runtime/pdf-runtime-build.json',
221+
'packages/pdf-runtime/scripts/build-target.sh',
222+
'packages/pdf-runtime/scripts/fetch-libpdfium.sh',
223+
'packages/pdf-runtime/build/generate-functions.mjs',
224+
'packages/pdf-runtime/build/generate-runtime-methods.mjs',
225+
'packages/pdf-runtime/build/generate-napi-binding.mjs',
226+
'packages/pdf-runtime/build/CMakeLists.txt',
227+
'packages/pdf-runtime/build/compile.sh',
228+
'packages/pdf-runtime/build/compile.esm.sh'
229+
) }}
230+
- if: steps.payload-cache.outputs.cache-hit == 'true'
231+
name: Restore payload from cache
232+
shell: bash
233+
run: |
234+
mkdir -p "packages/pdf-runtime/npm/${{ matrix.target }}"
235+
cp -R "packages/pdf-runtime/.cache/payloads/${{ matrix.target }}/." \
236+
"packages/pdf-runtime/npm/${{ matrix.target }}/"
237+
- if: steps.payload-cache.outputs.cache-hit != 'true'
238+
run: pnpm install --frozen-lockfile
239+
- if: steps.payload-cache.outputs.cache-hit != 'true'
240+
name: Build target
137241
run: pnpm --filter @embedpdf/pdf-runtime build:target ${{ matrix.target }}
242+
- if: steps.payload-cache.outputs.cache-hit != 'true'
243+
name: Stage payload to cache path
244+
shell: bash
245+
run: |
246+
src="packages/pdf-runtime/npm/${{ matrix.target }}"
247+
dst="packages/pdf-runtime/.cache/payloads/${{ matrix.target }}"
248+
mkdir -p "$dst"
249+
cp "$src/pdf-runtime.node" "$dst/"
250+
- name: Verify payload
251+
shell: bash
252+
run: bash packages/pdf-runtime/scripts/verify-packages.sh ${{ matrix.target }}
138253
- uses: actions/upload-artifact@v6
139254
with:
140255
name: pdf-runtime-${{ matrix.target }}
@@ -156,10 +271,46 @@ jobs:
156271
with:
157272
node-version: 22
158273
cache: pnpm
159-
- run: pnpm install --frozen-lockfile
160-
- name: Build target
274+
- name: Cache runtime payload
275+
id: payload-cache
276+
uses: actions/cache@v4
277+
with:
278+
path: packages/pdf-runtime/.cache/payloads/${{ matrix.target }}
279+
key: pdf-runtime-payload-${{ matrix.target }}-${{ hashFiles(
280+
'packages/pdf-runtime/pdf-runtime-build.json',
281+
'packages/pdf-runtime/scripts/build-target.sh',
282+
'packages/pdf-runtime/scripts/fetch-libpdfium.sh',
283+
'packages/pdf-runtime/build/generate-functions.mjs',
284+
'packages/pdf-runtime/build/generate-runtime-methods.mjs',
285+
'packages/pdf-runtime/build/generate-napi-binding.mjs',
286+
'packages/pdf-runtime/build/CMakeLists.txt',
287+
'packages/pdf-runtime/build/compile.sh',
288+
'packages/pdf-runtime/build/compile.esm.sh'
289+
) }}
290+
- if: steps.payload-cache.outputs.cache-hit == 'true'
291+
name: Restore payload from cache
292+
shell: bash
293+
run: |
294+
mkdir -p "packages/pdf-runtime/npm/${{ matrix.target }}"
295+
cp -R "packages/pdf-runtime/.cache/payloads/${{ matrix.target }}/." \
296+
"packages/pdf-runtime/npm/${{ matrix.target }}/"
297+
- if: steps.payload-cache.outputs.cache-hit != 'true'
298+
run: pnpm install --frozen-lockfile
299+
- if: steps.payload-cache.outputs.cache-hit != 'true'
300+
name: Build target
161301
shell: bash
162302
run: pnpm --filter @embedpdf/pdf-runtime build:target ${{ matrix.target }}
303+
- if: steps.payload-cache.outputs.cache-hit != 'true'
304+
name: Stage payload to cache path
305+
shell: bash
306+
run: |
307+
src="packages/pdf-runtime/npm/${{ matrix.target }}"
308+
dst="packages/pdf-runtime/.cache/payloads/${{ matrix.target }}"
309+
mkdir -p "$dst"
310+
cp "$src/pdf-runtime.node" "$src/pdfium.dll" "$dst/"
311+
- name: Verify payload
312+
shell: bash
313+
run: bash packages/pdf-runtime/scripts/verify-packages.sh ${{ matrix.target }}
163314
- uses: actions/upload-artifact@v6
164315
with:
165316
name: pdf-runtime-${{ matrix.target }}

.github/workflows/release-next.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ env:
2323
CI: true
2424

2525
jobs:
26+
build-runtime:
27+
uses: ./.github/workflows/build-pdf-runtime.yml
28+
secrets: inherit
29+
2630
release:
31+
needs: build-runtime
2732
runs-on: ubuntu-latest
2833
env:
2934
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -51,6 +56,25 @@ jobs:
5156
- name: Install deps
5257
run: pnpm install --frozen-lockfile
5358

59+
- name: Download pdf-runtime artifacts
60+
uses: actions/download-artifact@v7
61+
with:
62+
pattern: pdf-runtime-*
63+
path: packages/pdf-runtime/_artifacts
64+
65+
- name: Stage runtime payloads
66+
run: |
67+
shopt -s nullglob
68+
for dir in packages/pdf-runtime/_artifacts/pdf-runtime-*; do
69+
target="${dir##*/pdf-runtime-}"
70+
mkdir -p "packages/pdf-runtime/npm/$target"
71+
cp -R "$dir/." "packages/pdf-runtime/npm/$target/"
72+
done
73+
rm -rf packages/pdf-runtime/_artifacts
74+
75+
- name: Verify pdf-runtime packages
76+
run: pnpm run verify:pdf-runtime-packages
77+
5478
- name: Build packages
5579
run: pnpm run build:viewers
5680

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ env:
2323
CI: true
2424

2525
jobs:
26+
build-runtime:
27+
uses: ./.github/workflows/build-pdf-runtime.yml
28+
secrets: inherit
29+
2630
release:
31+
needs: build-runtime
2732
runs-on: ubuntu-latest
2833
env:
2934
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -51,6 +56,25 @@ jobs:
5156
- name: Install deps
5257
run: pnpm install --frozen-lockfile
5358

59+
- name: Download pdf-runtime artifacts
60+
uses: actions/download-artifact@v7
61+
with:
62+
pattern: pdf-runtime-*
63+
path: packages/pdf-runtime/_artifacts
64+
65+
- name: Stage runtime payloads
66+
run: |
67+
shopt -s nullglob
68+
for dir in packages/pdf-runtime/_artifacts/pdf-runtime-*; do
69+
target="${dir##*/pdf-runtime-}"
70+
mkdir -p "packages/pdf-runtime/npm/$target"
71+
cp -R "$dir/." "packages/pdf-runtime/npm/$target/"
72+
done
73+
rm -rf packages/pdf-runtime/_artifacts
74+
75+
- name: Verify pdf-runtime packages
76+
run: pnpm run verify:pdf-runtime-packages
77+
5478
- name: Build packages
5579
run: pnpm run build:viewers
5680

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"format:check": "prettier --check \"**/*.{ts,tsx,js,mjs,jsx,json,css,md}\"",
2424
"changeset": "changeset",
2525
"ci:publish": "pnpm publish -r --access public --report-summary $GITHUB_WORKSPACE/publish-summary.json",
26-
"ci:publish:next": "pnpm publish -r --access public --tag next --publish-branch next --report-summary $GITHUB_WORKSPACE/publish-summary.json"
26+
"ci:publish:next": "pnpm publish -r --access public --tag next --publish-branch next --report-summary $GITHUB_WORKSPACE/publish-summary.json",
27+
"verify:pdf-runtime-packages": "pnpm --filter @embedpdf/pdf-runtime run verify:packages"
2728
},
2829
"devDependencies": {
2930
"@changesets/cli": "^2.29.6",

packages/pdf-runtime/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"runtime:sync": "bash ./scripts/runtime-sync.sh",
5757
"runtime:use-local": "bash ./scripts/runtime-use-local.sh",
5858
"test:parity": "node --test ./test/*.test.mjs",
59+
"verify:packages": "bash ./scripts/verify-packages.sh",
5960
"wasm:dev": "bash ./scripts/wasm-dev.sh"
6061
},
6162
"files": [

0 commit comments

Comments
 (0)