Skip to content
Merged
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
64 changes: 64 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: ci

on:
pull_request:
branches:
- main
- 'release-*'
types:
- opened
- reopened
- synchronize
- closed

permissions:
contents: read # Baseline for actions/checkout; elevated scopes are granted per-job

concurrency:
group: pages-preview-${{ github.event.pull_request.number }}
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read # Only reads for checkout; gh-pages push and PR comment use the platform-mesh-publisher app token
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false

- id: app-token
name: Generate platform-mesh-publisher app token
if: ${{ !github.event.pull_request.head.repo.fork }} # Secrets are unavailable on fork PRs; preview deploy below is likewise skipped
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: "1415820" # platform-mesh-publisher
private-key: ${{ secrets.PM_PUBLISHER_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: 24
cache: npm

- id: configure
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6

- id: set-version
name: Set documentation version
run: echo "version=" >> $GITHUB_OUTPUT

- run: npm ci
- run: npm run build
env:
DOCS_VERSION: ${{ steps.set-version.outputs.version }}
PAGES_BASE: ${{ format('pr-preview/pr-{0}', github.event.pull_request.number) }}

- uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1
if: ${{ !github.event.pull_request.head.repo.fork }}
with:
token: ${{ steps.app-token.outputs.token }}
source-dir: .vitepress/dist
114 changes: 0 additions & 114 deletions .github/workflows/pages.yaml

This file was deleted.

86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: release

on:
push:
branches:
- main
- 'release-*'
workflow_dispatch:

permissions:
contents: read # Baseline for actions/checkout; elevated scopes are granted per-job

concurrency:
group: pages-${{ github.ref_name }}
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read # Only reads for checkout; pushes to gh-pages use the platform-mesh-publisher app token
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false

- id: app-token
name: Generate platform-mesh-publisher app token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: "1415820" # platform-mesh-publisher
private-key: ${{ secrets.PM_PUBLISHER_PRIVATE_KEY }}
permission-contents: write

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: 24
cache: npm # zizmor: ignore[cache-poisoning]

- id: configure
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6

- id: set-version
name: Set documentation version
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
echo "version=main" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_REF}" == refs/heads/release-* ]]; then
echo "version=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
else
echo "version=" >> $GITHUB_OUTPUT
fi

- run: npm ci
- run: npm run build
env:
DOCS_VERSION: ${{ steps.set-version.outputs.version }}
PAGES_BASE: ''

- uses: JamesIves/github-pages-deploy-action@fa24774553152dd7873cd16ebd8d959b010c5445 # v4
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-') }}
with:
token: ${{ steps.app-token.outputs.token }}
folder: .vitepress/dist
branch: gh-pages
target-folder: ${{ steps.set-version.outputs.version }}
clean-exclude: pr-preview
force: false

- uses: JamesIves/github-pages-deploy-action@fa24774553152dd7873cd16ebd8d959b010c5445 # v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
token: ${{ steps.app-token.outputs.token }}
folder: .
branch: gh-pages
target-folder: .
clean: false
clean-exclude: |
pr-preview
main
release-*
force: false
include: |
index.html
llms.txt
5 changes: 4 additions & 1 deletion .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const base = 'DOCS_VERSION' in process.env && process.env.DOCS_VERSION != ''
export default withMermaid({
title: "Platform Mesh",
head: [
['link', { rel: 'icon', href: `${base}favicon.ico` }]
['link', { rel: 'icon', href: `${base}favicon.ico` }],
// Deliberately synchronous: the shared version list must be available before
// Vue mounts. Use the site root, not this build's release/preview base path.
['script', { src: '/versions.js' }]
],

base,
Expand Down
50 changes: 28 additions & 22 deletions .vitepress/theme/components/VersionSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,15 @@ interface Version {
rootOnly?: boolean
}

// Define available versions - update this list when adding new versions.
// Set rootOnly: true for versions whose URL structure differs from the current
// docs layout (pre-v0.3 used a different directory structure), so switching
// to them always lands on the version root instead of trying to map the
// current path.
const versions: Version[] = [
{ name: 'main', label: 'main (latest)' },
{ name: 'release-26.10', label: 'v26.10' },
{ name: 'release-0.5', label: 'v0.5' },
{ name: 'release-0.4', label: 'v0.4' },
{ name: 'release-0.3', label: 'v0.3' },
{ name: 'release-0.2', label: 'v0.2', rootOnly: true },
{ name: 'release-0.1', label: 'v0.1', rootOnly: true },
]
declare global {
interface Window {
PLATFORM_MESH_VERSIONS?: Version[]
}
}

// The root-level /versions.js is shared by all documentation releases.
// Keep server rendering independent of window; load the list on mount.
const versions = ref<Version[]>([{ name: 'main', label: 'main (latest)' }])

const currentVersion = ref<string>('')
const isPreview = ref<boolean>(false)
Expand All @@ -67,12 +62,10 @@ function getCurrentVersion(): string {
const path = window.location.pathname
const segments = path.split('/').filter(Boolean)

// Check if first segment matches a known version
if (segments.length > 0) {
const firstSegment = segments[0]
if (versions.some(v => v.name === firstSegment)) {
return firstSegment
}
// Detect the current release even when the shared script is unavailable.
const firstSegment = segments[0]
if (firstSegment === 'main' || /^release-\d+\.\d+$/.test(firstSegment || '')) {
return firstSegment
}

// Default to main if no version detected
Expand All @@ -82,7 +75,7 @@ function getCurrentVersion(): string {
function switchVersion(): void {
if (typeof window === 'undefined') return

const selected = versions.find(v => v.name === currentVersion.value)
const selected = versions.value.find(v => v.name === currentVersion.value)

if (selected?.rootOnly) {
window.location.href = `/${currentVersion.value}/`
Expand All @@ -94,7 +87,7 @@ function switchVersion(): void {

// Remove the version from the path if it exists
let pathWithoutVersion = ''
if (segments.length > 0 && versions.some(v => v.name === segments[0])) {
if (segments.length > 0 && versions.value.some(v => v.name === segments[0])) {
pathWithoutVersion = '/' + segments.slice(1).join('/')
} else {
pathWithoutVersion = currentPath
Expand All @@ -117,6 +110,19 @@ function switchVersion(): void {
onMounted(() => {
isPreview.value = isPreviewContext()
currentVersion.value = getCurrentVersion()
if (window.PLATFORM_MESH_VERSIONS?.length) {
versions.value = [...window.PLATFORM_MESH_VERSIONS]
}

// Local builds, a failed script request, or a stale cached list should still
// show the current version and allow navigation back to main.
if (!versions.value.some(v => v.name === currentVersion.value)) {
versions.value.push({
name: currentVersion.value,
label: `v${currentVersion.value.replace(/^release-/, '')}`,
rootOnly: ['release-0.1', 'release-0.2'].includes(currentVersion.value),
})
}
})
</script>

Expand Down
Loading
Loading