Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
2154c52
ci: upload docs on icp-pages branch
ilbertt Aug 6, 2025
7627f76
ci: update workflow title
ilbertt Aug 6, 2025
acdab8d
fix: remove backticks and add push step
ilbertt Aug 6, 2025
952c6e2
fix: add github token
ilbertt Aug 6, 2025
2f609fe
ci: build docs only
ilbertt Aug 6, 2025
fb43fba
fix: remove colon
ilbertt Aug 6, 2025
c6a72b6
fix: build only docs
ilbertt Aug 6, 2025
acec887
fix: typos
ilbertt Aug 6, 2025
e97dccd
fix: remove symlink if it exist
ilbertt Aug 6, 2025
2a8cbfe
ci: test action with beta
ilbertt Aug 6, 2025
acbd392
fix: beta check
ilbertt Aug 6, 2025
6ab1b2b
fix: check for STABLE_VERSION
ilbertt Aug 6, 2025
c90f3af
ci: test a non-valid version
ilbertt Aug 6, 2025
34e0729
ci: test next version
ilbertt Aug 6, 2025
dbc318e
fix: latest should not change
ilbertt Aug 6, 2025
60dfdac
ci: test v3 again
ilbertt Aug 6, 2025
0a101aa
ci: test label
ilbertt Aug 6, 2025
1c168f3
ci: test another version
ilbertt Aug 6, 2025
7982fda
ci: test beta
ilbertt Aug 6, 2025
46cc614
ci: test not allowed version
ilbertt Aug 6, 2025
b47a743
ci: test v3 again
ilbertt Aug 6, 2025
03c4d88
ci: test with v5
ilbertt Aug 6, 2025
65ab630
chore: test minor
ilbertt Aug 7, 2025
70d50ec
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 7, 2025
9e7b0d0
ci: test patch version
ilbertt Aug 7, 2025
db3936e
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 7, 2025
e871c0e
fix: do not commit and push if no file was touched
ilbertt Aug 7, 2025
cf0f2f6
ci: simplify detecting git changes
ilbertt Aug 7, 2025
56977f4
ci: use github action from ci-tools
ilbertt Aug 8, 2025
8785a3e
fix: prefix with `v`
ilbertt Aug 8, 2025
5e4a501
ci: point to specific commit
ilbertt Aug 11, 2025
e8695a1
ci: update commit
ilbertt Aug 11, 2025
3ee3117
ci: update commit
ilbertt Aug 11, 2025
ec38169
ci: change commit and prepare version step
ilbertt Aug 11, 2025
4bcec5c
ci: fix version
ilbertt Aug 11, 2025
1dd2c1e
ci: update assemble docs action commit
ilbertt Aug 11, 2025
409d570
ci: update ref for assemble docs
ilbertt Aug 11, 2025
3a28013
ci: update ref for assemble docs
ilbertt Aug 11, 2025
fef692b
ci: test beta version
ilbertt Aug 11, 2025
57c65d7
ci: test next tag
ilbertt Aug 11, 2025
d33ba69
chore: update action version
ilbertt Aug 11, 2025
e195b0b
feat: submit docs to dfinity/icp-js-sdk-docs repo
ilbertt Aug 11, 2025
8254712
refactor: explicit params
ilbertt Aug 11, 2025
1bd7adc
feat: versions dropdown plugin
ilbertt Aug 11, 2025
f3a97ea
ci: pin submit-docs action version
ilbertt Aug 11, 2025
6d55abf
ci:m update submit-docs action ref
ilbertt Aug 11, 2025
2279b63
fix: correct versions.json path
ilbertt Aug 11, 2025
f6ebaa7
ci: use action branch
ilbertt Aug 11, 2025
18b1508
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 12, 2025
5072f5c
ci: update param
ilbertt Aug 12, 2025
d6ec937
ci: add token for icp-js-sdk-docs
ilbertt Aug 12, 2025
68293cb
fix: add current tag to version dropdown if not present
ilbertt Aug 12, 2025
5e3e965
refactor: rename from core to agent
ilbertt Aug 12, 2025
85a02c9
feat: index page and version dropdown fixes
ilbertt Aug 12, 2025
4a008ef
feat: add publish docs step to publish action
ilbertt Aug 12, 2025
573d45e
refactor: add todos
ilbertt Aug 12, 2025
717d3b2
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 12, 2025
4c4b54a
ci: update actions branches
ilbertt Aug 13, 2025
976c81a
ci: update actions references
ilbertt Aug 13, 2025
24c9aef
ci: update steps
ilbertt Aug 13, 2025
d301638
ci: point main branch for docs actions
ilbertt Aug 13, 2025
132a32f
chore: remove temporary action
ilbertt Aug 13, 2025
99d58c3
Revert "chore: remove temporary action"
ilbertt Aug 13, 2025
6ad707b
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 13, 2025
002194d
fix: use text size from theme
ilbertt Aug 13, 2025
643fd8a
refactor: update versions labels
ilbertt Aug 14, 2025
f2761e0
fix: handle trailing slash
ilbertt Aug 14, 2025
9e47d5b
feat: show version above dropdown
ilbertt Aug 15, 2025
7527033
ci: update publish action
ilbertt Aug 18, 2025
145da31
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 20, 2025
0567692
refactor: move to plugins
ilbertt Aug 20, 2025
042538d
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 20, 2025
261ff67
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 20, 2025
ed5ce57
refactor: move release notes to upgrading folder
ilbertt Aug 20, 2025
831c478
refactor: move upgrading guide to v4 path
ilbertt Aug 20, 2025
341c253
Merge remote-tracking branch 'origin/luca/upgrading-guide' into luca/…
ilbertt Aug 20, 2025
f08aa65
Merge remote-tracking branch 'origin/main' into luca/upgrading-guide
ilbertt Aug 20, 2025
532ccca
Merge remote-tracking branch 'origin/main' into luca/upgrading-guide
ilbertt Aug 20, 2025
17bda4f
Merge remote-tracking branch 'origin/luca/upgrading-guide' into luca/…
ilbertt Aug 20, 2025
7ffb50b
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 20, 2025
faa053f
ci: remove temporary action
ilbertt Aug 20, 2025
9695ac6
Merge remote-tracking branch 'origin/main' into luca/SDK-2264-push-docs
ilbertt Aug 20, 2025
638e025
Revert "ci: remove temporary action"
ilbertt Aug 20, 2025
33390f2
docs: remove @icp-sdk/core references for now
ilbertt Aug 20, 2025
fd333e2
ci: remove temporary action
ilbertt Aug 21, 2025
d2be7c3
ci: pin checkout actions versions
ilbertt Aug 21, 2025
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
84 changes: 76 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ on:
- closed

jobs:
publish:
publish-packages:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Extract version from branch name
run: |
BRANCH="${{ github.event.pull_request.head.ref }}"
VERSION="${BRANCH#release/}"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
echo "VERSION_TAG=v$VERSION" >> $GITHUB_ENV

- name: Mark as Latest Release in GitHub Releases
env:
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
Expand All @@ -31,15 +32,82 @@ jobs:
with:
node_version_file: '.nvmrc'

- run: pnpm build
- run: pnpm build:packages

- run: pnpm publish:packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Deploy Docs to Juno satellite
uses: junobuild/juno-action@main
publish-docs:
needs: publish-packages
runs-on: ubuntu-latest
steps:
- name: Create GitHub App Token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
id: generate_token
with:
args: deploy --mode production --immediate
app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: icp-js-sdk-docs

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup PNPM
uses: dfinity/ci-tools/actions/setup-pnpm@main
with:
node_version_file: '.nvmrc'

- uses: dfinity/ci-tools/actions/extract-version@main
id: extract-version
with:
file: 'package.json'

- name: Prepare version
id: ver
run: |
echo "major_minor_version=v${{ steps.extract-version.outputs.major }}.${{ steps.extract-version.outputs.minor }}" >> $GITHUB_OUTPUT
echo "major_minor_patch_version=v${{ steps.extract-version.outputs.major }}.${{ steps.extract-version.outputs.minor }}.${{ steps.extract-version.outputs.patch }}" >> $GITHUB_OUTPUT

- name: Build docs for version ${{ steps.ver.outputs.major_minor_version }}
working-directory: docs
env:
DOCS_VERSION: ${{ steps.ver.outputs.major_minor_version }}
DOCS_VERSIONS_DROPDOWN_TITLE_VERSION: ${{ steps.ver.outputs.major_minor_patch_version }}
run: pnpm build --outDir dist/${{ steps.ver.outputs.major_minor_version }}

- name: Build docs for version latest
working-directory: docs
env:
JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }}
PROJECT_PATH: docs
DOCS_VERSION: latest
DOCS_VERSIONS_DROPDOWN_TITLE_VERSION: ${{ steps.ver.outputs.major_minor_patch_version }}
run: pnpm build --outDir dist/latest

- name: Checkout icp-pages branch
uses: actions/checkout@v4
with:
ref: icp-pages
path: icp-pages

- name: Assemble docs
uses: dfinity/ci-tools/actions/assemble-docs@main
with:
assets_dir: 'docs/dist/${{ steps.ver.outputs.major_minor_version }}'
version: ${{ steps.ver.outputs.major_minor_version }}
target_dir: 'icp-pages'
version_label: ${{ steps.ver.outputs.major_minor_version }}

- name: Assemble docs
uses: dfinity/ci-tools/actions/assemble-docs@main
with:
assets_dir: 'docs/dist/latest'
version: 'latest'
target_dir: 'icp-pages'
version_label: 'Latest (${{ steps.ver.outputs.major_minor_patch_version }})'

- name: Submit Documentation
uses: dfinity/ci-tools/actions/submit-docs@main
with:
destination_repo: 'dfinity/icp-js-sdk-docs'
token: ${{ steps.generate_token.outputs.token }}
target_dir: 'icp-pages'
24 changes: 22 additions & 2 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ import { additionalFilesPlugin } from '@dfinity/starlight/additional-files';
import { markdownUrlsPlugin } from '@dfinity/starlight/markdown-urls';
import { dfinityStarlightTheme } from '@dfinity/starlight/theme';
import { libsPlugin } from '@dfinity/starlight/libs';
import { versionedSidebarPlugin } from '@dfinity/starlight/versioned-sidebar';

const BASE_DOCS_PATH = '/core';
const docsVersion = process.env.DOCS_VERSION ?? 'local';

const UPGRADE_BANNER_CONTENT =
'Still using <code>@dfinity/agent</code>? Migrate to <a href="/core/latest/upgrading/v4">@icp-sdk/core</a>!';

// https://astro.build/config
export default defineConfig({
site: 'https://js.icp.build/',
base: '/core/',
base: `${BASE_DOCS_PATH}/${docsVersion}/`,
image: {
service: passthroughImageService(),
},
Expand All @@ -26,7 +33,14 @@ export default defineConfig({
typeDoc: {
exclude: ['../packages/core', '../packages/migrate'],
},
frontmatter: { editUrl: false, next: true, prev: true },
frontmatter: {
editUrl: false,
next: true,
prev: true,
banner: {
content: UPGRADE_BANNER_CONTENT,
},
},
}),
additionalFilesPlugin({
additionalFiles: [
Expand All @@ -38,10 +52,16 @@ export default defineConfig({
editUrl: false,
next: false,
prev: false,
banner: {
content: UPGRADE_BANNER_CONTENT,
},
},
},
],
}),
versionedSidebarPlugin({
versionsJsonPath: `${BASE_DOCS_PATH}/versions.json`,
}),
],
sidebar: [
{
Expand Down
5 changes: 4 additions & 1 deletion docs/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"./additional-files": "./src/additional-files.ts",
"./libs": "./src/libs.ts",
"./markdown-urls": "./src/markdown-urls.ts",
"./theme": "./src/theme.ts"
"./theme": "./src/theme.ts",
"./versioned-sidebar": "./src/versioned-sidebar/index.ts",
"./versioned-sidebar/components/VersionedSidebar.astro": "./src/versioned-sidebar/components/VersionedSidebar.astro",
"./versioned-sidebar/components/VersionDropdown.astro": "./src/versioned-sidebar/components/VersionDropdown.astro"
}
}
100 changes: 100 additions & 0 deletions docs/plugins/src/versioned-sidebar/components/VersionDropdown.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
const IS_DEV = import.meta.env.DEV;
const BASE_URL = import.meta.env.BASE_URL;
const DOCS_VERSIONS_DROPDOWN_TITLE_VERSION = import.meta.env.DOCS_VERSIONS_DROPDOWN_TITLE_VERSION;
---

<div>
<label for="sidebar-version-select" class="sidebar-version-select-label">
Version{DOCS_VERSIONS_DROPDOWN_TITLE_VERSION ? ` (${DOCS_VERSIONS_DROPDOWN_TITLE_VERSION})` : ''}
</label>
<select id="sidebar-version-select" aria-label="Select documentation version"></select>
</div>

<script define:vars={{ IS_DEV, BASE_URL }} is:inline>
const BASE_URL_NO_TRAILING_SLASH = BASE_URL.replace(/\/$/, '');

function removeBaseUrlFromPath(pathname) {
const relative = pathname.startsWith(BASE_URL)
? pathname.slice(BASE_URL.length)
: pathname.startsWith(BASE_URL_NO_TRAILING_SLASH)
? pathname.slice(BASE_URL_NO_TRAILING_SLASH.length)
: pathname;

return relative.startsWith('/') ? relative.slice(1) : relative;
}

async function initVersionDropdown() {
const select = document.getElementById('sidebar-version-select');
if (!select || !(select instanceof HTMLSelectElement)) {
console.error('No select element found');
return;
}

let versions = [];
if (!IS_DEV) {
try {
const versionsUrl = document.getElementsByName('versions-json-path')[0]?.getAttribute('content');
if (!versionsUrl) {
console.error('No versions.json path found');
return;
}
const res = await fetch(versionsUrl, { cache: 'no-store' });
if (res.ok) {
const data = await res.json();
if (Array.isArray(data)) {
versions = data;
}
}
} catch (e) {
console.error('Error fetching versions.json', e);
}
}

const currentVersion = (BASE_URL.replace(/\/$/, '').split('/').pop() || '').toLowerCase();
const { pathname, search, hash } = window.location;

// If the current URL's base segment doesn't match any known versions,
// add a synthetic option so users can see/select the current build.
if (!versions.some(v => v.path.toLowerCase() === currentVersion)) {
versions.unshift({ path: currentVersion, label: currentVersion });
}

select.innerHTML = '';
for (const v of versions) {
const newBase = BASE_URL.replace(/([^/]+)\/$/, `${v.path}/`);
const relative = removeBaseUrlFromPath(pathname);
const href = newBase + relative + search + hash;
const opt = document.createElement('option');
opt.value = href;
opt.textContent = v.label;
if (v.path.toLowerCase() === currentVersion) {
opt.selected = true;
}
select.appendChild(opt);
}

select.addEventListener('change', () => {
const href = select.value;
const current = pathname + search + hash;
if (href && href !== current) {
window.location.href = href;
}
});
};

initVersionDropdown();
</script>

<style>
#sidebar-version-select {
width: 100%;
padding: 0.25rem 0.5rem;
border-radius: 0.375rem;
}
.sidebar-version-select-label {
display: block;
font-size: var(--sl-text-sm);
cursor: pointer;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
import MobileMenuFooter from '@astrojs/starlight/components/MobileMenuFooter.astro';
import SidebarPersister from '@astrojs/starlight/components/SidebarPersister.astro';
import SidebarSublist from '@astrojs/starlight/components/SidebarSublist.astro';
import VersionDropdown from './VersionDropdown.astro';

const { sidebar } = Astro.locals.starlightRoute;
---

<VersionDropdown />

<SidebarPersister>
<SidebarSublist sublist={sidebar} />
</SidebarPersister>

<div class="md:sl-hidden">
<MobileMenuFooter />
</div>
55 changes: 55 additions & 0 deletions docs/plugins/src/versioned-sidebar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { StarlightPlugin } from '@astrojs/starlight/types';

/**
* Options for the VersionsPlugin.
*/
interface VersionedSidebarPluginOptions {
/**
* The path at which the `versions.json` file is served in production.
*/
versionsJsonPath: string;
}

/**
* You can set the `DOCS_VERSIONS_DROPDOWN_TITLE_VERSION` environment variable to show a version above the versions dropdown.
*
* @example
* ```bash
* DOCS_VERSIONS_DROPDOWN_TITLE_VERSION=v3.2.1 pnpm build
* ```
*
* This will result in:
* ```html
* <div>
* <label for="sidebar-version-select">Version (v3.2.1)</label>
* <select id="sidebar-version-select" aria-label="Select documentation version">
* <!-- options from {opts.versionsJsonPath} file -->
* </select>
* </div>
* ```
*/
export function versionedSidebarPlugin(opts: VersionedSidebarPluginOptions): StarlightPlugin {
return {
name: 'versions-starlight-plugin',
hooks: {
'config:setup': ctx => {
ctx.updateConfig({
head: [
...(ctx.config.head ?? []),
{
tag: 'meta',
attrs: {
name: 'versions-json-path',
content: opts.versionsJsonPath,
},
},
],
components: {
...ctx.config.components,
Sidebar: '@dfinity/starlight/versioned-sidebar/components/VersionedSidebar.astro',
},
});
},
},
};
}
5 changes: 4 additions & 1 deletion docs/plugins/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "astro/tsconfigs/strictest"
"extends": "astro/tsconfigs/strictest",
"compilerOptions": {
"types": ["@astrojs/starlight/locals"]
}
}
9 changes: 7 additions & 2 deletions docs/src/content/docs/upgrading/v3.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
title: Release notes for v3.0.0
description: Release notes for the ICP JavaScript SDK v3.0.0.
title: Upgrading to v3
description: Upgrade your project to the v3 of the ICP JavaScript SDK.
sidebar:
label: v3
order: 2
banner:
content: Still using <code>@dfinity/agent</code>? Migrate to <a href="/core/latest/upgrading/v4">@icp-sdk/core</a>!
---

This release marks a major update to the ICP JavaScript SDK, introducing several breaking changes, new features, and improvements. This guide is intended to help developers upgrade their projects to the latest version. Among the key improvements, this release eliminates Buffer and similar dependencies, significantly [reducing bundle size](#bundle-size) and improving performance across all packages.
Expand Down
Loading
Loading