Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ updates:
cooldown:
default-days: 7
groups:
# Dependencies used only by the example apps, so a framework bump that
# breaks an example can't hold up SDK dependency updates. Dependencies
# shared with the SDK packages (react, react-native, typescript, ...)
# stay in npm-dependencies. The first matching group wins.
example-dependencies:
patterns:
- "@expo/*"
- "expo"
- "expo-*"
- "@react-native/*"
- "react-native-*"
- "@sveltejs/*"
- "svelte"
- "svelte-*"
- "@testing-library/*"
- "@vitejs/*"
- "vite"
- "@vue/*"
- "vue"
- "express"
- "jquery"
- "next"
npm-dependencies:
patterns:
- "*"
Expand Down
173 changes: 131 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@ on: [push, pull_request]

permissions:
contents: read
id-token: write
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node_version:
- 24
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
version:
name: Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
ci_tag: ${{ steps.version.outputs.ci_tag }}
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Build Reason
shell: bash
run: |
Expand All @@ -36,20 +34,10 @@ jobs:
elif [[ "${GITHUB_REF}" = refs/pull* ]]; then
branch=""
fi
echo "GIT_BRANCH_SUFFIX=$branch" >> $GITHUB_ENV
echo "GIT_BRANCH_SUFFIX=$branch" >> "$GITHUB_ENV"
echo "ref: $GITHUB_REF event: $GITHUB_EVENT_NAME branch_suffix: $branch"
- name: Setup Node.js environment
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node_version }}
registry-url: "https://registry.npmjs.org"
- name: Cache node_modules
uses: actions/cache@v6
with:
path: node_modules
key: ${{ matrix.node_version }}-${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Setup .NET SDK for MinVer
uses: actions/setup-dotnet@v6
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: "10.0.x"
- name: Build Version
Expand All @@ -67,37 +55,138 @@ jobs:
fi
fi

echo "version=$version" >> $GITHUB_OUTPUT
ci_tag="${GIT_BRANCH_SUFFIX%.}"
ci_tag="${ci_tag:-main}"
ci_tag="ci-${ci_tag//\//-}"

echo "version=$version" >> "$GITHUB_OUTPUT"
echo "ci_tag=$ci_tag" >> "$GITHUB_OUTPUT"
echo "Version: $version"
echo "### Version: $version" >> $GITHUB_STEP_SUMMARY
echo "### Version: $version" >> "$GITHUB_STEP_SUMMARY"

npm install --global replace-in-files-cli
replace-in-files --string="3.0.0-dev" --replacement=$version packages/core/src/configuration/Configuration.ts
replace-in-files --string="3.0.0-dev" --replacement=$version **/package*.json
npm ci
build:
needs: version
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node_version:
- 24
include:
- os: ubuntu-latest
node_version: 22
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node_version }}
cache: npm
- name: Set Version
shell: bash
run: node scripts/set-version.mjs "$VERSION"
env:
VERSION: ${{ needs.version.outputs.version }}
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Lint
if: matrix.os == 'ubuntu-latest' && matrix.node_version == 24
run: npm run lint
- name: Run Tests
run: npm test

# Publish jobs rebuild from a clean checkout so elevated permissions are only
# granted to the job that needs them. They skip dependency caching on purpose.
publish-npm:
name: Publish Release Packages
if: startsWith(github.ref, 'refs/tags/v')
needs: [version, build]
runs-on: ubuntu-latest
environment: npm-release
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
package-manager-cache: false
- name: Set Version
run: node scripts/set-version.mjs "$VERSION"
env:
VERSION: ${{ needs.version.outputs.version }}
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish Release Packages
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest'
run: npm publish --workspaces --access public

publish-github:
name: Push GitHub CI Packages
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && contains(needs.version.outputs.version, '-')
needs: [version, build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
package-manager-cache: false
- name: Set Version
run: node scripts/set-version.mjs "$VERSION"
env:
VERSION: ${{ needs.version.outputs.version }}
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup GitHub CI Node.js environment
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && matrix.os == 'ubuntu-latest' && contains(steps.version.outputs.version, '-')
uses: actions/setup-node@v7
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node_version }}
node-version: 24
registry-url: "https://github.com/proxy/npm.pkg.github.com/"
scope: "@exceptionless"
package-manager-cache: false
- name: Push GitHub CI Packages
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/') && matrix.os == 'ubuntu-latest' && contains(steps.version.outputs.version, '-')
shell: bash
run: |
TAG_BRANCH="${GIT_BRANCH_SUFFIX%.}"
TAG_BRANCH="${TAG_BRANCH:-main}"
TAG_BRANCH="${TAG_BRANCH//\//-}"
npm publish --workspaces --access public --tag "ci-${TAG_BRANCH}" || true
# Re-runs of the same commit produce the same version; skip packages
# that already exist and let every other publish failure fail the job.
# Publish in the root workspace order (dependencies first) so a package is
# never published before the exact dependency version it requires.
for dir in $(node -p "require('./package.json').workspaces.filter((w) => w.startsWith('packages/')).join('\n')"); do
name=$(node -p "require('./$dir/package.json').name")
existing=$(npm view "$name@$VERSION" version 2>/dev/null || true)
if [ "$existing" = "$VERSION" ]; then
echo "::notice::$name@$VERSION already exists in GitHub Packages; skipping."
continue
fi
npm publish --workspace "$dir" --access public --tag "$CI_TAG"
done
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
VERSION: ${{ needs.version.outputs.version }}
CI_TAG: ${{ needs.version.outputs.ci_tag }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import tseslint from "typescript-eslint";

export default defineConfig(
{
ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/", "**/expo-plugin/", "**/react-native.config.*"]
ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/", "**/expo-plugin/", "**/react-native.config.*", "scripts/"]
},
eslint.configs.recommended,
{
Expand Down
65 changes: 65 additions & 0 deletions scripts/set-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env node
// Stamps the computed build version over the "3.0.0-dev" placeholder in the
// core configuration, the root and workspace package.json files, and
// package-lock.json. Used by CI before `npm ci`; uses only Node built-ins.
//
// Usage: node scripts/set-version.mjs <version>

import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const PLACEHOLDER = "3.0.0-dev";
const VERSION_PATTERN = /^\d+\.\d+\.\d+\S*$/;

const version = process.argv[2];
if (!version || !VERSION_PATTERN.test(version)) {
console.error(`Usage: node scripts/set-version.mjs <version> (got: ${version ?? "nothing"})`);
process.exit(1);
}

const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const rootPackage = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));

function workspaceDirs(patterns) {
return patterns.flatMap((pattern) => {
if (!pattern.endsWith("/*")) {
return [pattern];
}

const parent = pattern.slice(0, -2);
return readdirSync(join(root, parent), { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => `${parent}/${entry.name}`);
});
}

const files = [
"packages/core/src/configuration/Configuration.ts",
"package.json",
"package-lock.json",
...workspaceDirs(rootPackage.workspaces ?? [])
.map((dir) => `${dir}/package.json`)
.filter((file) => existsSync(join(root, file)))
];

let total = 0;
for (const file of files) {
const path = join(root, file);
const content = readFileSync(path, "utf8");
const parts = content.split(PLACEHOLDER);
if (parts.length === 1) {
continue;
}

writeFileSync(path, parts.join(version));
total += parts.length - 1;
console.log(`${file}: ${parts.length - 1} replacement(s)`);
}

if (total === 0) {
console.error(`No "${PLACEHOLDER}" placeholders found; nothing was versioned.`);
process.exit(1);
}

console.log(`Set version ${version} (${total} replacement(s) in total).`);
Loading