Skip to content

chore: bump

chore: bump #92

Workflow file for this run

# CI for pushes and pull requests.
#
# All native artifacts (Android AARs + iOS/visionOS xcframeworks for canvas,
# canvas-svg and audio-context) are built by the reusable build-native.yml
# workflow. On pushes to master (and manual dispatch) the npm job then packages
# everything with those freshly built artifacts and publishes a `pr`-tagged
# prerelease of each package.
name: Canvas Native
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
jobs:
build-native:
name: Build Native
uses: ./.github/workflows/build-native.yml
npm:
name: Npm Build
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-22.04
needs: [build-native]
env:
NPM_TAG: pr
# Space separated; must match the packages/<name> directories.
NPM_PACKAGES: audio-context canvas canvas-babylon canvas-chartjs canvas-media canvas-phaser canvas-phaser-ce canvas-pixi canvas-polyfill canvas-svg canvas-three
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Download native artifacts
uses: actions/download-artifact@v4
with:
path: native-artifacts
- name: Place native artifacts
run: |
set -e
cp native-artifacts/canvas-android/canvas-release.aar packages/canvas/platforms/android/
cp native-artifacts/canvas-svg-android/canvassvg-release.aar packages/canvas-svg/platforms/android/
cp native-artifacts/audio-context-android/audiocontext-release.aar packages/audio-context/platforms/android/
# xcframeworks are tarred to preserve file permissions; replace the
# committed ones so stale slices can't linger
rm -rf packages/canvas/platforms/ios/CanvasNative.xcframework
tar -xzf native-artifacts/canvas-ios/canvas-ios.tar.gz -C packages/canvas/platforms/ios
rm -rf packages/canvas-svg/platforms/ios/CanvasSVG.xcframework
tar -xzf native-artifacts/canvas-svg-ios/canvas-svg-ios.tar.gz -C packages/canvas-svg/platforms/ios
rm -rf packages/audio-context/platforms/ios/AudioContextNative.xcframework
tar -xzf native-artifacts/audio-context-ios/audio-context-ios.tar.gz -C packages/audio-context/platforms/ios
- name: Install dependencies
run: npm install
- name: Generate version
run: |
echo NPM_VERSION=$(node -p "require('./packages/canvas/package.json').version")-$NPM_TAG-$(date +"%m-%d-%Y")-$GITHUB_RUN_ID >> $GITHUB_ENV
- name: Bump versions
run: |
set -e
for pkg in $NPM_PACKAGES; do
(cd "packages/$pkg" && npm version "$NPM_VERSION" --no-git-tag-version --allow-same-version)
done
- name: Build all packages
run: npx nx run-many --target=build.all --projects="$(echo "$NPM_PACKAGES" | tr ' ' ',')"
- name: 'Publish packages (tag: pr)'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: |
set -euo pipefail
for pkg in $NPM_PACKAGES; do
dir="dist/packages/$pkg"
if [ ! -f "$dir/package.json" ]; then
echo "error: $dir/package.json not found (build missing?)" >&2
exit 1
fi
name="$(node -p "require('./$dir/package.json').name")"
ver="$(node -p "require('./$dir/package.json').version")"
echo "==> publishing $name@$ver (tag: $NPM_TAG)"
(cd "$dir" && npm publish --access public --tag "$NPM_TAG")
done
pr-notice:
name: PR Publish Notice
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
needs: [build-native]
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Post PR comment about publishing
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:information_source: Note: npm publishing is disabled for pull requests.
Publishing is performed only from tag pushes via the `npm Release` workflow.
If you need a test publish, merge to master — pushes publish `pr`-tagged prereleases.