Skip to content

Commit d48b272

Browse files
triniwizNathanWalkerherefishyfishgithub-advanced-security[bot]
authored
chore: v2 final
* chore: updates * chore: nx migrate @nativescript/plugin-tools * chore: updates * fix(canvas): support local paths * feat: GPUCompilationInfo * fix(canvas): clean up context * chore: rc12 * chore: disable forceGL * fix: polyfills and media (#135) * fix(canvas): filter out touch events by identifier (#136) * chore: bump * fix: webgl creation * chore: bump * chore: clean up * chore: improve userAgent * chore: bump * fix: expose CustomEvent * chore: bump * fix: webgl video rendering * chore: bump * fix: flipY * chore: bump * fix(ios): video gl video rendering * feat: update wgpu & skia to the latest * chore: fixes & performance updates * fix: image leaks * chore(polyfil): polish * feat: support video elements in drawImage, texImage2D, texSubImage2D, texImage3D & texSubImage3D * chore: 2.0 * Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * chore: bump * chore: bump libs * chore: v2 --------- Co-authored-by: Nathan Walker <walkerrunpdx@gmail.com> Co-authored-by: Dylan Llewellyn <46717769+herefishyfish@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent cc02858 commit d48b272

File tree

430 files changed

+43052
-23015
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

430 files changed

+43052
-23015
lines changed

.github/workflows/publish.yml

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
name: Publish Packages
2+
3+
permissions:
4+
contents: read
5+
packages: read
6+
7+
on:
8+
push:
9+
tags:
10+
- 'v*'
11+
workflow_dispatch:
12+
inputs:
13+
npm_tag:
14+
description: 'NPM tag to publish as (overrides default)'
15+
required: false
16+
default: 'latest'
17+
dry_run:
18+
description: 'Set to "true" to skip publishing and release upload (dry run)'
19+
required: false
20+
default: 'false'
21+
22+
permissions:
23+
contents: read
24+
env:
25+
NPM_TAG: "latest"
26+
NPM_PACKAGES: canvas,canvas-babylon,canvas-media,canvas-phaser,canvas-phaser-ce,canvas-pixi,canvas-polyfill,canvas-three,canvas-svg
27+
28+
jobs:
29+
build-linux:
30+
name: Build Linux native artifacts
31+
runs-on: ubuntu-22.04
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Setup Node
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 22
38+
39+
- name: Cache node modules
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
~/.npm
44+
~/.cache
45+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/package.json') }}
46+
restore-keys: |
47+
${{ runner.os }}-node-
48+
49+
- name: Install Rust
50+
run: |
51+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
52+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
53+
54+
- name: Use Rust nightly
55+
run: rustup default nightly
56+
- name: Install deps (root)
57+
run: npm ci
58+
59+
- name: Cache cargo
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
~/.cargo/registry
64+
~/.cargo/git
65+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-cargo-
68+
69+
- name: Build Android (make android)
70+
run: |
71+
set -e
72+
make android
73+
74+
- name: Copy AAR into package
75+
run: |
76+
set -e
77+
./tools/scripts/copy-android.sh
78+
79+
- name: Upload Android platforms
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: android-platforms
83+
path: packages/canvas/platforms/android
84+
85+
build-macos:
86+
name: Build macOS native artifacts
87+
runs-on: macos-14
88+
steps:
89+
- uses: actions/checkout@v4
90+
- name: Setup Node
91+
uses: actions/setup-node@v4
92+
with:
93+
node-version: 22
94+
95+
- name: Cache node modules
96+
uses: actions/cache@v4
97+
with:
98+
path: |
99+
~/.npm
100+
~/.cache
101+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/package.json') }}
102+
restore-keys: |
103+
${{ runner.os }}-node-
104+
105+
- name: Install Rust
106+
run: |
107+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
108+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
109+
110+
- name: Use Rust nightly
111+
run: rustup default nightly
112+
- name: Install root deps
113+
run: npm ci
114+
115+
- name: Cache cargo
116+
uses: actions/cache@v4
117+
with:
118+
path: |
119+
~/.cargo/registry
120+
~/.cargo/git
121+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
122+
restore-keys: |
123+
${{ runner.os }}-cargo-
124+
125+
- name: Build iOS (make ios)
126+
run: |
127+
set -e
128+
make ios
129+
130+
- name: Build and copy iOS XCFramework
131+
run: |
132+
set -e
133+
./tools/scripts/canvas-build.sh
134+
135+
- name: Upload iOS platforms
136+
uses: actions/upload-artifact@v4
137+
with:
138+
name: ios-platforms
139+
path: packages/canvas/platforms/ios
140+
141+
publish:
142+
name: Publish to npm
143+
runs-on: ubuntu-22.04
144+
needs: [ build-linux, build-macos ]
145+
steps:
146+
- uses: actions/checkout@v4
147+
148+
- name: Download linux artifacts
149+
uses: actions/download-artifact@v4
150+
with:
151+
name: napi-linux-artifacts
152+
path: ./artifacts/linux
153+
154+
- name: Cache cargo
155+
uses: actions/cache@v4
156+
with:
157+
path: |
158+
~/.cargo/registry
159+
~/.cargo/git
160+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
161+
restore-keys: |
162+
${{ runner.os }}-cargo-
163+
164+
- name: Download mac artifacts
165+
uses: actions/download-artifact@v4
166+
with:
167+
name: napi-macos-artifacts
168+
path: ./artifacts/macos
169+
170+
- name: Setup Node
171+
uses: actions/setup-node@v4
172+
with:
173+
node-version: 22
174+
175+
- name: Install root deps
176+
run: npm ci
177+
178+
- name: Compute NPM_VERSION
179+
run: |
180+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
181+
TAG=${GITHUB_REF#refs/tags/}
182+
echo "Detected tag $TAG"
183+
echo "NPM_VERSION=$TAG" >> $GITHUB_ENV
184+
# set NPM_TAG to prefix of tag (e.g. rc/, beta) or the tag itself
185+
echo "NPM_TAG=${TAG%%-*}" >> $GITHUB_ENV
186+
else
187+
if [ -n "${{ github.event.inputs.npm_tag }}" ]; then
188+
NT="${{ github.event.inputs.npm_tag }}"
189+
else
190+
NT="$NPM_TAG"
191+
fi
192+
echo "NPM_TAG=$NT" >> $GITHUB_ENV
193+
echo "NPM_VERSION=$(node -e \"console.log(require('./packages/canvas/package.json').version)\")-$NT-$(date +\"%Y%m%d\")-$GITHUB_RUN_ID" >> $GITHUB_ENV
194+
fi
195+
196+
- name: Bump packages (no git tags)
197+
run: |
198+
for pkg in packages/canvas packages/canvas-babylon packages/canvas-media packages/canvas-phaser packages/canvas-phaser-ce packages/canvas-pixi packages/canvas-polyfill packages/canvas-three packages/canvas-svg; do
199+
if [ -f "$pkg/package.json" ]; then
200+
(cd "$pkg" && npm --no-git-tag-version version "$NPM_VERSION")
201+
fi
202+
done
203+
204+
- name: Create project .npmrc (in-repo)
205+
if: ${{ secrets.NPM_PUBLISH_TOKEN != '' }}
206+
run: |
207+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_TOKEN }}" > .npmrc
208+
209+
- name: Build all packages
210+
run: |
211+
npx nx run canvas:build.all
212+
213+
- name: Publish packages
214+
if: ${{ github.event.inputs.dry_run != 'true' }}
215+
env:
216+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
217+
run: |
218+
if [ -z "$NPM_TOKEN" ]; then
219+
echo "NPM token missing. Set secrets.NPM_PUBLISH_TOKEN to proceed." && exit 1
220+
fi
221+
echo "Publishing packages with version $NPM_VERSION and tag $NPM_TAG"
222+
npm run publish-packages --name "$NPM_PACKAGES" --verify true --version "$NPM_VERSION" --tag "$NPM_TAG"
223+
224+
- name: Clean up .npmrc
225+
if: always()
226+
run: rm -f .npmrc || true
227+
228+
- name: Create release tarball
229+
if: startsWith(github.ref, 'refs/tags/') && github.event.inputs.dry_run != 'true'
230+
run: |
231+
set -e
232+
TAR_NAME=release-${NPM_VERSION}.tar.gz
233+
tar -czf ${TAR_NAME} dist packages/canvas/platforms || true
234+
echo "Created ${TAR_NAME}"
235+
236+
- name: Create GitHub release and upload assets
237+
if: startsWith(github.ref, 'refs/tags/') && github.event.inputs.dry_run != 'true'
238+
uses: softprops/action-gh-release@v1
239+
with:
240+
files: release-${NPM_VERSION}.tar.gz
241+
env:
242+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pull-request.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
NPM_TAG: "pr"
1111
EMULATOR_NAME: "runtime-emu"
12-
NDK_VERSION: r23c
12+
NDK_VERSION: r27d
1313
ANDROID_API: 29
1414
ANDROID_ABI: x86_64
1515
NDK_ARCH: linux
@@ -24,6 +24,24 @@ jobs:
2424
runs-on: ubuntu-22.04
2525
steps:
2626
- uses: actions/checkout@v4
27+
- name: Cache node modules
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.npm
32+
~/.cache
33+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/package.json') }}
34+
restore-keys: |
35+
${{ runner.os }}-node-
36+
- name: Cache cargo
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.cargo/registry
41+
~/.cargo/git
42+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-cargo-
2745
- name: Install Rust
2846
run: |
2947
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
@@ -137,6 +155,24 @@ jobs:
137155
runs-on: macos-14
138156
steps:
139157
- uses: actions/checkout@v4
158+
- name: Cache node modules
159+
uses: actions/cache@v4
160+
with:
161+
path: |
162+
~/.npm
163+
~/.cache
164+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/package.json') }}
165+
restore-keys: |
166+
${{ runner.os }}-node-
167+
- name: Cache cargo
168+
uses: actions/cache@v4
169+
with:
170+
path: |
171+
~/.cargo/registry
172+
~/.cargo/git
173+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
174+
restore-keys: |
175+
${{ runner.os }}-cargo-
140176
- name: Install Rust
141177
run: |
142178
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
@@ -190,6 +226,7 @@ jobs:
190226
npm run build.canvas.ios.framework.release
191227
npm:
192228
name: Npm Build
229+
if: ${{ github.event_name != 'pull_request' }}
193230
runs-on: ubuntu-22.04
194231
needs: [android, ios]
195232
outputs:
@@ -251,4 +288,20 @@ jobs:
251288
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ../../.npmrc
252289
echo "Publishing @nativescript/canvas@$NPM_VERSION to NPM with tag $NPM_TAG..."
253290
npm run publish-packages --name $NPM_PACKAGES --verify true --version $NPM_VERSION
291+
pr-notice:
292+
name: PR Publish Notice
293+
if: ${{ github.event_name == 'pull_request' }}
294+
runs-on: ubuntu-latest
295+
needs: [ android, ios ]
296+
steps:
297+
- uses: actions/checkout@v4
298+
- name: Post PR comment about publishing
299+
uses: peter-evans/create-or-update-comment@v4
300+
with:
301+
token: ${{ secrets.GITHUB_TOKEN }}
302+
issue-number: ${{ github.event.pull_request.number }}
303+
body: |
304+
:information_source: Note: npm publishing is disabled for pull requests.
305+
Publishing is performed only from tag pushes via the `Publish Packages` workflow.
306+
If you need a test publish, create a tag `v0.0.0-rc.test` and push it to trigger a release run.
254307

0 commit comments

Comments
 (0)