-
-
Notifications
You must be signed in to change notification settings - Fork 18
chore: updates #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: updates #137
Changes from 29 commits
72f14ce
2afbc80
157afd3
c39c29c
03854aa
c9feb6f
7dae858
cd36597
cb66829
ebc26d8
19d03cc
eaf11e0
a01b41f
5bd347b
840d0b1
8f94caf
07c7c6f
70e6479
3327cae
bea85dd
df59db7
22ad3e9
8f8ab04
2b3f02e
bd1e40e
08fde0d
18ffa23
1673b5b
dad2172
21e2994
8238e6a
2ecc7ce
1d7e203
ef4fbb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,236 @@ | ||
| name: Publish Packages | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| workflow_dispatch: | ||
| inputs: | ||
| npm_tag: | ||
| description: 'NPM tag to publish as (overrides default)' | ||
| required: false | ||
| default: 'latest' | ||
| dry_run: | ||
| description: 'Set to "true" to skip publishing and release upload (dry run)' | ||
| required: false | ||
| default: 'false' | ||
|
|
||
| env: | ||
| NPM_TAG: "latest" | ||
| NPM_PACKAGES: canvas,canvas-babylon,canvas-media,canvas-phaser,canvas-phaser-ce,canvas-pixi,canvas-polyfill,canvas-three,canvas-svg | ||
|
|
||
| jobs: | ||
| build-linux: | ||
| name: Build Linux native artifacts | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Cache node modules | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.npm | ||
| ~/.cache | ||
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/package.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-node- | ||
|
|
||
| - name: Install Rust | ||
| run: | | ||
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal | ||
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Use Rust nightly | ||
| run: rustup default nightly | ||
| - name: Install deps (root) | ||
| run: npm ci | ||
|
|
||
| - name: Cache cargo | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Build Android (make android) | ||
| run: | | ||
| set -e | ||
| make android | ||
|
|
||
| - name: Copy AAR into package | ||
| run: | | ||
| set -e | ||
| ./tools/scripts/copy-android.sh | ||
|
|
||
| - name: Upload Android platforms | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: android-platforms | ||
| path: packages/canvas/platforms/android | ||
|
|
||
| build-macos: | ||
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
|
||
| name: Build macOS native artifacts | ||
| runs-on: macos-14 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Cache node modules | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.npm | ||
| ~/.cache | ||
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/package.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-node- | ||
|
|
||
| - name: Install Rust | ||
| run: | | ||
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal | ||
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Use Rust nightly | ||
| run: rustup default nightly | ||
| - name: Install root deps | ||
| run: npm ci | ||
|
|
||
| - name: Cache cargo | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Build iOS (make ios) | ||
| run: | | ||
| set -e | ||
| make ios | ||
|
|
||
| - name: Build and copy iOS XCFramework | ||
| run: | | ||
| set -e | ||
| ./tools/scripts/canvas-build.sh | ||
|
|
||
| - name: Upload iOS platforms | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ios-platforms | ||
| path: packages/canvas/platforms/ios | ||
|
|
||
| publish: | ||
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
|
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| name: Publish to npm | ||
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
|
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| runs-on: ubuntu-22.04 | ||
| needs: [ build-linux, build-macos ] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Download linux artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: napi-linux-artifacts | ||
| path: ./artifacts/linux | ||
|
|
||
| - name: Cache cargo | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Download mac artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: napi-macos-artifacts | ||
| path: ./artifacts/macos | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Install root deps | ||
| run: npm ci | ||
|
|
||
| - name: Compute NPM_VERSION | ||
| run: | | ||
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | ||
| TAG=${GITHUB_REF#refs/tags/} | ||
| echo "Detected tag $TAG" | ||
| echo "NPM_VERSION=$TAG" >> $GITHUB_ENV | ||
| # set NPM_TAG to prefix of tag (e.g. rc/, beta) or the tag itself | ||
| echo "NPM_TAG=${TAG%%-*}" >> $GITHUB_ENV | ||
| else | ||
| if [ -n "${{ github.event.inputs.npm_tag }}" ]; then | ||
| NT="${{ github.event.inputs.npm_tag }}" | ||
| else | ||
| NT="$NPM_TAG" | ||
| fi | ||
| echo "NPM_TAG=$NT" >> $GITHUB_ENV | ||
| echo "NPM_VERSION=$(node -e \"console.log(require('./packages/canvas/package.json').version)\")-$NT-$(date +\"%Y%m%d\")-$GITHUB_RUN_ID" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| - name: Bump packages (no git tags) | ||
| run: | | ||
| 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 | ||
| if [ -f "$pkg/package.json" ]; then | ||
| (cd "$pkg" && npm --no-git-tag-version version "$NPM_VERSION") | ||
| fi | ||
| done | ||
|
|
||
| - name: Create project .npmrc (in-repo) | ||
| if: ${{ secrets.NPM_PUBLISH_TOKEN != '' }} | ||
| run: | | ||
| echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_TOKEN }}" > .npmrc | ||
|
|
||
| - name: Build all packages | ||
| run: | | ||
| npx nx run canvas:build.all | ||
|
|
||
| - name: Publish packages | ||
| if: ${{ github.event.inputs.dry_run != 'true' }} | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
| run: | | ||
| if [ -z "$NPM_TOKEN" ]; then | ||
| echo "NPM token missing. Set secrets.NPM_PUBLISH_TOKEN to proceed." && exit 1 | ||
| fi | ||
| echo "Publishing packages with version $NPM_VERSION and tag $NPM_TAG" | ||
| npm run publish-packages --name "$NPM_PACKAGES" --verify true --version "$NPM_VERSION" --tag "$NPM_TAG" | ||
|
|
||
| - name: Clean up .npmrc | ||
| if: always() | ||
| run: rm -f .npmrc || true | ||
|
|
||
| - name: Create release tarball | ||
| if: startsWith(github.ref, 'refs/tags/') && github.event.inputs.dry_run != 'true' | ||
| run: | | ||
| set -e | ||
| TAR_NAME=release-${NPM_VERSION}.tar.gz | ||
| tar -czf ${TAR_NAME} dist packages/canvas/platforms || true | ||
| echo "Created ${TAR_NAME}" | ||
|
|
||
| - name: Create GitHub release and upload assets | ||
| if: startsWith(github.ref, 'refs/tags/') && github.event.inputs.dry_run != 'true' | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| files: release-${NPM_VERSION}.tar.gz | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
Uh oh!
There was an error while loading. Please reload this page.