Skip to content

Commit af49798

Browse files
authored
Setup Release -> Publish Package workflow (#18)
The main goal of these changes is to introduce a GitHub Actions workflow that publishes the Babylon React Native NPM package when a GitHub Release is created (expects releases to be tagged with a valid version, e.g. v0.1.2-alpha.1, v0.1.2, etc.). For testing purposes, I had this publish the package to this GitHub repos package feed, but later we will switch it to npmjs.com. The changes required for this are: - Introduce publish.yml, a simple GitHub Actions workflow that is triggered by a Release being created. It basically just gets the version number from the release tag and publishes the NPM package. Note that my plan is to just leave the version in the package.json as 0.0.0 which is fine for local builds, and the version will only be set (but not committed back) when publishing a package following the creation of a Release. - In order to publish a package to GitHub, the package name must be scoped (e.g. start with @BabylonJS), so I renamed the package (in package.json) to @babylonjs/react-native. - Given the above, when consuming the package, the path in node_modules must match the package name, so I also moved the react-native-babylon folder to @babylonjs/react-native. NOTE: After syncing this change, you will need to git clean -dxff or the react native playground app won't launch. - Moved the usage section of the root README.md into the @babylonjs/react-native README.md since this is displayed on the package page (GitHub or npmjs.com). - Fixed the repository path in the package.json (it must be correct or GitHub won't allow the package to be published).
1 parent b481f2c commit af49798

37 files changed

+117
-962
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish Package
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout Repo
11+
uses: actions/[email protected]
12+
- name: Checkout Submodules
13+
uses: textbook/[email protected]
14+
- name: Setup Node.js
15+
uses: actions/[email protected]
16+
with:
17+
node-version: '12.x'
18+
registry-url: 'https://npm.pkg.github.com'
19+
scope: '@babylonjs'
20+
- name: Version & Publish Package
21+
run: |
22+
npm version --no-git-tag-version ${GITHUB_REF/refs\/tags\//}
23+
npm publish
24+
working-directory: ./Apps/Playground/node_modules/@babylonjs/react-native
25+
env:
26+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "Core/react-native-babylon/submodules/BabylonNative"]
2-
path = Apps/Playground/node_modules/react-native-babylon/submodules/BabylonNative
2+
path = Apps/Playground/node_modules/@babylonjs/react-native/submodules/BabylonNative
33
url = https://github.com/BabylonJS/BabylonNative.git

Apps/Playground/App.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React, { useState, FunctionComponent, useEffect, useCallback } from 'react';
99
import { SafeAreaView, StatusBar, Button, View, Text, ViewProps } from 'react-native';
1010

11-
import { EngineView, useEngine } from 'react-native-babylon';
11+
import { EngineView, useEngine } from '@babylonjs/react-native';
1212
import { Scene, Vector3, Mesh, ArcRotateCamera, Camera, PBRMetallicRoughnessMaterial, Color3, TargetCamera, WebXRSessionManager } from '@babylonjs/core';
1313
import Slider from '@react-native-community/slider';
1414

@@ -62,7 +62,10 @@ const EngineScreen: FunctionComponent<ViewProps> = (props: ViewProps) => {
6262
const xr = await scene.createDefaultXRExperienceAsync({ disableDefaultUI: true, disableTeleportation: true })
6363
const session = await xr.baseExperience.enterXRAsync("immersive-ar", "unbounded", xr.renderTarget);
6464
setXrSession(session);
65-
box.position = (scene.activeCamera as TargetCamera).getFrontPosition(2);
65+
// TODO: Figure out why getFrontPosition stopped working
66+
//box.position = (scene.activeCamera as TargetCamera).getFrontPosition(2);
67+
const cameraRay = scene.activeCamera!.getForwardRay(1);
68+
box.position = cameraRay.origin.add(cameraRay.direction.scale(cameraRay.length));
6669
box.rotate(Vector3.Up(), 3.14159);
6770
}
6871
}

0 commit comments

Comments
 (0)