From 2154c521fc14e8d4655d9a5835e5cfc5babdb065 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:21:03 +0200 Subject: [PATCH 01/72] ci: upload docs on icp-pages branch --- .github/actions/publish-docs/action.yml | 110 ++++++++++++++++++++++++ .github/workflows/tmp-publish-docs.yml | 27 ++++++ 2 files changed, 137 insertions(+) create mode 100644 .github/actions/publish-docs/action.yml create mode 100644 .github/workflows/tmp-publish-docs.yml diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml new file mode 100644 index 000000000..a6f8d42dc --- /dev/null +++ b/.github/actions/publish-docs/action.yml @@ -0,0 +1,110 @@ +name: Publish docs +description: Push static docs assets to the `icp-pages` branch and triggers the `pull-project-docs` workflow on the docs repo + +inputs: + docs_output_dir: + description: The directory containing the static docs assets to publish + required: true + docs_version: + description: The version of the docs to publish. Allowed values: `vX | vX.Y | vX.Y.Z | beta | dev | next | nightly` (where `X`, `Y`, `Z` are numbers) + required: true + docs_version_label: + description: The label to use for the docs version. If not provided, the `docs_version` will be used. + required: false + docs_repo: + description: The repository to trigger the workflow on to publish the docs + required: false + default: 'dfinity/icp-sdk-js-docs' + is_latest: + description: Whether the docs version is the latest version. If `true`, the `docs_version` will be symlinked to the `latest` version of the published docs. + required: true + github_token: + description: The GitHub token to use for authentication to the destination repository + required: true + +runs: + using: 'composite' + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: icp-pages + path: icp-pages + + - name: Check if the docs version is valid + shell: bash + id: check-docs-version + run: | + if [[ ${{ inputs.docs_version }} =~ ^v[0-9]+(\.[0-9]+)?(\.[0-9]+)?$ ]]; then + echo "STABLE_VERSION=${{ inputs.docs_version }}" >> $GITHUB_ENV + elif [[ ! ${{ inputs.docs_version }} =~ ^beta|dev|next|nightly$ ]]; then + echo "Not a stable version, versions.json will not be updated" + echo "STABLE_VERSION=" >> $GITHUB_ENV + else + echo "Invalid docs version: ${{ inputs.docs_version }}" + exit 1 + fi + + - name: Zip files from the docs output directory + shell: bash + id: zip-files + run: | + ZIP_FILE_NAME=${{ inputs.docs_version }}.zip + zip -r $ZIP_FILE_NAME ${{ inputs.docs_output_dir }} + echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV + + - name: Copy zip to the icp-pages branch + shell: bash + run: | + cp $ZIP_FILE_NAME icp-pages/ + + - name: Symlink the zip file to the latest version + shell: bash + working-directory: icp-pages + if: ${{ inputs.is_latest }} == 'true' + run: | + ln -s $ZIP_FILE_NAME latest.zip + + - name: Create versions.json if it doesn't exist + shell: bash + working-directory: icp-pages + run: | + if [ ! -f versions.json ]; then + echo "[]" > versions.json + fi + + - name: Add or update the version in versions.json + shell: bash + working-directory: icp-pages + if: ${{ env.STABLE_VERSION }} != '' + env: + DOCS_VERSION_LABEL: ${{ inputs.docs_version_label }} + run: | + # Upsert the docs_version: if it exists, update the label; if not, add it + jq --arg version "$STABLE_VERSION" --arg label "$DOCS_VERSION_LABEL" ' + if any(.path == $version) then + # Update existing version with new label, if the label is provided + map(if ((.path == $version) and ($label != "")) then .label = $label else . end) + else + # Add new version with the provided label, or fallback to the version for the label + . + [{"path": $version, "label": (if $label != "" then $label else $version end)}] + end' versions.json > versions.json.tmp + + mv versions.json.tmp versions.json + + - name: Add or update the latest version in versions.json + shell: bash + if: ${{ inputs.is_latest }} == 'true' && ${{ env.STABLE_VERSION }} != '' + working-directory: icp-pages + run: | + VERSION_LABEL="$(jq -r '.[] | select(.path == "$STABLE_VERSION") | .label' versions.json)" + LATEST_LABEL="latest ($VERSION_LABEL)" + + # Upsert the latest version to versions.json + jq --arg version "latest" --arg label "$LATEST_LABEL" ' + if any(.path == $version) then + map(if .path == $version then .label = $label else . end) + else + [{"path": $version, "label": $label}] + . + end' versions.json > versions.json.tmp + + mv versions.json.tmp versions.json diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml new file mode 100644 index 000000000..dc1727ca2 --- /dev/null +++ b/.github/workflows/tmp-publish-docs.yml @@ -0,0 +1,27 @@ +# TODO: remove this workflow once the action works +name: Publish and Release + +on: + pull_request: + +jobs: + publish-docs: + runs-on: ubuntu-latest + if: ${{ github.head_ref == 'luca/SDK-2264-push-docs' }} + steps: + - uses: actions/checkout@v4 + + - name: Setup PNPM + uses: dfinity/ci-tools/actions/setup-pnpm@main + with: + node_version_file: '.nvmrc' + + - run: pnpm build + + - name: Publish docs + uses: ./.github/actions/publish-docs + with: + docs_output_dir: 'docs/dist' + github_token: ${{ secrets.GITHUB_TOKEN }} + docs_version: v3 + is_latest: true From 7627f76f78979736078234c5d2646cfd9b20c256 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:26:11 +0200 Subject: [PATCH 02/72] ci: update workflow title --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index dc1727ca2..4b79e64fb 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -1,5 +1,5 @@ # TODO: remove this workflow once the action works -name: Publish and Release +name: Tmp publish docs on: pull_request: From acdab8d011426961ac99a9f7c5639727a748a028 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:29:16 +0200 Subject: [PATCH 03/72] fix: remove backticks and add push step --- .github/actions/publish-docs/action.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index a6f8d42dc..27659c109 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -1,25 +1,25 @@ name: Publish docs -description: Push static docs assets to the `icp-pages` branch and triggers the `pull-project-docs` workflow on the docs repo +description: Push static docs assets to the icp-pages branch and triggers the pull-project-docs workflow on the docs repo inputs: docs_output_dir: description: The directory containing the static docs assets to publish required: true docs_version: - description: The version of the docs to publish. Allowed values: `vX | vX.Y | vX.Y.Z | beta | dev | next | nightly` (where `X`, `Y`, `Z` are numbers) + description: The version of the docs to publish. Allowed values: vX | vX.Y | vX.Y.Z | beta | dev | next | nightly (where X, Y, Z are numbers) required: true docs_version_label: - description: The label to use for the docs version. If not provided, the `docs_version` will be used. + description: The label to use for the docs version. If not provided, the docs_version will be used. required: false docs_repo: description: The repository to trigger the workflow on to publish the docs required: false default: 'dfinity/icp-sdk-js-docs' is_latest: - description: Whether the docs version is the latest version. If `true`, the `docs_version` will be symlinked to the `latest` version of the published docs. + description: Whether the docs version is the latest version. If true, the docs_version will be symlinked to the latest version of the published docs. required: true github_token: - description: The GitHub token to use for authentication to the destination repository + description: The GitHub token to use for pushing to the icp-pages branch required: true runs: @@ -108,3 +108,13 @@ runs: end' versions.json > versions.json.tmp mv versions.json.tmp versions.json + + - name: Commit and push the changes + shell: bash + working-directory: icp-pages + run: | + git config user.name "GitHub Actions" + git config user.email "github-actions@github.com" + git add . + git commit -m "Update static docs assets for version: $STABLE_VERSION" + git push origin icp-pages From 952c6e2fbc8a96a71a160928163722e737f99c95 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:30:58 +0200 Subject: [PATCH 04/72] fix: add github token --- .github/actions/publish-docs/action.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index 27659c109..631a05f02 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -109,12 +109,19 @@ runs: mv versions.json.tmp versions.json - - name: Commit and push the changes + - name: Commit changes shell: bash working-directory: icp-pages run: | - git config user.name "GitHub Actions" - git config user.email "github-actions@github.com" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Update static docs assets for version: $STABLE_VERSION" + + - name: Push changes + shell: bash + working-directory: icp-pages + env: + GITHUB_TOKEN: ${{ inputs.github_token }} + run: | git push origin icp-pages From 2f609fec45aa521fc5462b3de94ad708ece166b2 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:33:03 +0200 Subject: [PATCH 05/72] ci: build docs only --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 4b79e64fb..306280e29 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -16,7 +16,7 @@ jobs: with: node_version_file: '.nvmrc' - - run: pnpm build + - run: pnpm build -F docs - name: Publish docs uses: ./.github/actions/publish-docs From fb43fbabf60c195fa54498de92be02f7d21b3369 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:36:33 +0200 Subject: [PATCH 06/72] fix: remove colon --- .github/actions/publish-docs/action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index 631a05f02..47c4479a4 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -1,25 +1,25 @@ name: Publish docs -description: Push static docs assets to the icp-pages branch and triggers the pull-project-docs workflow on the docs repo +description: Push static docs assets to the `icp-pages` branch and triggers the `pull-project-docs` workflow on the docs repo inputs: docs_output_dir: description: The directory containing the static docs assets to publish required: true docs_version: - description: The version of the docs to publish. Allowed values: vX | vX.Y | vX.Y.Z | beta | dev | next | nightly (where X, Y, Z are numbers) + description: The version of the docs to publish. Allowed values are `vX` | `vX.Y` | `vX.Y.Z` | `beta` | `dev` | `next` | `nightly` (where `X`, `Y`, `Z` are numbers) required: true docs_version_label: - description: The label to use for the docs version. If not provided, the docs_version will be used. + description: The label to use for the docs version. If not provided, the `docs_version` will be used required: false docs_repo: description: The repository to trigger the workflow on to publish the docs required: false default: 'dfinity/icp-sdk-js-docs' is_latest: - description: Whether the docs version is the latest version. If true, the docs_version will be symlinked to the latest version of the published docs. + description: Whether the docs version is the latest version. If true, the `docs_version` will be symlinked to the latest version of the published docs required: true github_token: - description: The GitHub token to use for pushing to the icp-pages branch + description: The GitHub token to use for pushing to the `icp-pages` branch required: true runs: From c6a72b6113a35a1bef265dd15834773be9643418 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:38:47 +0200 Subject: [PATCH 07/72] fix: build only docs --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 306280e29..33ad4c2ab 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -16,7 +16,7 @@ jobs: with: node_version_file: '.nvmrc' - - run: pnpm build -F docs + - run: pnpm -F docs build - name: Publish docs uses: ./.github/actions/publish-docs From acec88707d310abc2160f6e08c8e9d84539742a4 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:50:25 +0200 Subject: [PATCH 08/72] fix: typos --- .github/actions/publish-docs/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index 47c4479a4..c7e117f4c 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -96,7 +96,7 @@ runs: if: ${{ inputs.is_latest }} == 'true' && ${{ env.STABLE_VERSION }} != '' working-directory: icp-pages run: | - VERSION_LABEL="$(jq -r '.[] | select(.path == "$STABLE_VERSION") | .label' versions.json)" + VERSION_LABEL="$(jq -r --arg version "$STABLE_VERSION" '.[] | select(.path == $version) | .label' versions.json)" LATEST_LABEL="latest ($VERSION_LABEL)" # Upsert the latest version to versions.json @@ -116,7 +116,7 @@ runs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . - git commit -m "Update static docs assets for version: $STABLE_VERSION" + git commit -m "Update static docs assets for version: ${{ inputs.docs_version }}" - name: Push changes shell: bash From e97dccd3718fc2a920e88f4014563a3d2262a09c Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:54:42 +0200 Subject: [PATCH 09/72] fix: remove symlink if it exist --- .github/actions/publish-docs/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index c7e117f4c..a87a21f62 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -62,6 +62,8 @@ runs: working-directory: icp-pages if: ${{ inputs.is_latest }} == 'true' run: | + # Remove existing symlink if it exists, then create new one + rm -f latest.zip ln -s $ZIP_FILE_NAME latest.zip - name: Create versions.json if it doesn't exist From 2a8cbfe470cd399ca14921db4517dd526c9dcf2b Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 6 Aug 2025 23:58:49 +0200 Subject: [PATCH 10/72] ci: test action with beta --- .github/workflows/tmp-publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 33ad4c2ab..159c3e8e1 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: v3 - is_latest: true + docs_version: beta + is_latest: false From acbd392457e089b5b385b729383bc4bfc34968a2 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:00:59 +0200 Subject: [PATCH 11/72] fix: beta check --- .github/actions/publish-docs/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index a87a21f62..f2aff582b 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -36,7 +36,7 @@ runs: run: | if [[ ${{ inputs.docs_version }} =~ ^v[0-9]+(\.[0-9]+)?(\.[0-9]+)?$ ]]; then echo "STABLE_VERSION=${{ inputs.docs_version }}" >> $GITHUB_ENV - elif [[ ! ${{ inputs.docs_version }} =~ ^beta|dev|next|nightly$ ]]; then + elif [[ ${{ inputs.docs_version }} =~ ^beta|dev|next|nightly$ ]]; then echo "Not a stable version, versions.json will not be updated" echo "STABLE_VERSION=" >> $GITHUB_ENV else From 6ab1b2ba23662b6307c4a8fb20909c6392c0b5ba Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:07:17 +0200 Subject: [PATCH 12/72] fix: check for STABLE_VERSION --- .github/actions/publish-docs/action.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index f2aff582b..845b8bd2b 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -36,9 +36,8 @@ runs: run: | if [[ ${{ inputs.docs_version }} =~ ^v[0-9]+(\.[0-9]+)?(\.[0-9]+)?$ ]]; then echo "STABLE_VERSION=${{ inputs.docs_version }}" >> $GITHUB_ENV - elif [[ ${{ inputs.docs_version }} =~ ^beta|dev|next|nightly$ ]]; then + elif [[ ${{ inputs.docs_version }} =~ ^(beta|dev|next|nightly)$ ]]; then echo "Not a stable version, versions.json will not be updated" - echo "STABLE_VERSION=" >> $GITHUB_ENV else echo "Invalid docs version: ${{ inputs.docs_version }}" exit 1 @@ -77,7 +76,7 @@ runs: - name: Add or update the version in versions.json shell: bash working-directory: icp-pages - if: ${{ env.STABLE_VERSION }} != '' + if: ${{ env.STABLE_VERSION != '' }} env: DOCS_VERSION_LABEL: ${{ inputs.docs_version_label }} run: | @@ -95,7 +94,7 @@ runs: - name: Add or update the latest version in versions.json shell: bash - if: ${{ inputs.is_latest }} == 'true' && ${{ env.STABLE_VERSION }} != '' + if: ${{ inputs.is_latest }} == 'true' && ${{ env.STABLE_VERSION != '' }} working-directory: icp-pages run: | VERSION_LABEL="$(jq -r --arg version "$STABLE_VERSION" '.[] | select(.path == $version) | .label' versions.json)" From c90f3af9290b235a8dd5ea71ec761f01f38eccec Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:09:52 +0200 Subject: [PATCH 13/72] ci: test a non-valid version --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 159c3e8e1..c1ebd74ca 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: beta + docs_version: not_valid is_latest: false From 34e072908a7e6b0f47f9ad94e3af6055121741b1 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:13:07 +0200 Subject: [PATCH 14/72] ci: test next version --- .github/actions/publish-docs/action.yml | 2 +- .github/workflows/tmp-publish-docs.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index 845b8bd2b..eba6b2f28 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -94,7 +94,7 @@ runs: - name: Add or update the latest version in versions.json shell: bash - if: ${{ inputs.is_latest }} == 'true' && ${{ env.STABLE_VERSION != '' }} + if: ${{ inputs.is_latest == 'true' && env.STABLE_VERSION != '' }} working-directory: icp-pages run: | VERSION_LABEL="$(jq -r --arg version "$STABLE_VERSION" '.[] | select(.path == $version) | .label' versions.json)" diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index c1ebd74ca..d6e98d899 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: not_valid + docs_version: next is_latest: false From dbc318ec259ea578eb62aaa1567112d5a7df8f47 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:16:23 +0200 Subject: [PATCH 15/72] fix: latest should not change --- .github/actions/publish-docs/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index eba6b2f28..38274899b 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -59,7 +59,7 @@ runs: - name: Symlink the zip file to the latest version shell: bash working-directory: icp-pages - if: ${{ inputs.is_latest }} == 'true' + if: ${{ inputs.is_latest == 'true' }} run: | # Remove existing symlink if it exists, then create new one rm -f latest.zip From 60dfdac5c31793f72c3922dcecca6cc0e788ed56 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:16:46 +0200 Subject: [PATCH 16/72] ci: test v3 again --- .github/workflows/tmp-publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index d6e98d899..33ad4c2ab 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: next - is_latest: false + docs_version: v3 + is_latest: true From 0a101aa389fd639961f7ecf3ca3c96335debaa33 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:18:52 +0200 Subject: [PATCH 17/72] ci: test label --- .github/workflows/tmp-publish-docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 33ad4c2ab..6d845740d 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -24,4 +24,5 @@ jobs: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} docs_version: v3 + docs_version_label: 'Version 3' is_latest: true From 1c168f361c4144cadbb92df743dd92d7fe83d66e Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:19:29 +0200 Subject: [PATCH 18/72] ci: test another version --- .github/workflows/tmp-publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 6d845740d..e76881351 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,6 +23,6 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: v3 - docs_version_label: 'Version 3' + docs_version: v4 + docs_version_label: 'Version 4' is_latest: true From 7982fdaedefd12fe708afc7ed5927b579c8693a0 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:20:53 +0200 Subject: [PATCH 19/72] ci: test beta --- .github/workflows/tmp-publish-docs.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index e76881351..159c3e8e1 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,6 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: v4 - docs_version_label: 'Version 4' - is_latest: true + docs_version: beta + is_latest: false From 46cc614eb6361c8389103432fa00ec12d1b94591 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:22:46 +0200 Subject: [PATCH 20/72] ci: test not allowed version --- .github/workflows/tmp-publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 159c3e8e1..a8729d058 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: beta - is_latest: false + docs_version: not_valid + is_latest: true From b47a743464ae1c7fcd779a547b83f3263ff64677 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:24:43 +0200 Subject: [PATCH 21/72] ci: test v3 again --- .github/workflows/tmp-publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index a8729d058..8e3450cc5 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: not_valid - is_latest: true + docs_version: v3 + is_latest: false From 03c4d88a4e4b955c772e429bc611a676a01ed1e8 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 00:26:06 +0200 Subject: [PATCH 22/72] ci: test with v5 --- .github/workflows/tmp-publish-docs.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 8e3450cc5..a42dc8028 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,6 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: v3 - is_latest: false + docs_version: v5 + docs_version_label: 'Version 5' + is_latest: true From 65ab6306f3885d1152c7b9a61711d113057b33bb Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 11:49:03 +0200 Subject: [PATCH 23/72] chore: test minor --- .github/actions/publish-docs/action.yml | 7 +++---- .github/workflows/tmp-publish-docs.yml | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index 38274899b..624fcca34 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -45,7 +45,6 @@ runs: - name: Zip files from the docs output directory shell: bash - id: zip-files run: | ZIP_FILE_NAME=${{ inputs.docs_version }}.zip zip -r $ZIP_FILE_NAME ${{ inputs.docs_output_dir }} @@ -58,8 +57,8 @@ runs: - name: Symlink the zip file to the latest version shell: bash - working-directory: icp-pages if: ${{ inputs.is_latest == 'true' }} + working-directory: icp-pages run: | # Remove existing symlink if it exists, then create new one rm -f latest.zip @@ -75,8 +74,8 @@ runs: - name: Add or update the version in versions.json shell: bash - working-directory: icp-pages if: ${{ env.STABLE_VERSION != '' }} + working-directory: icp-pages env: DOCS_VERSION_LABEL: ${{ inputs.docs_version_label }} run: | @@ -100,7 +99,7 @@ runs: VERSION_LABEL="$(jq -r --arg version "$STABLE_VERSION" '.[] | select(.path == $version) | .label' versions.json)" LATEST_LABEL="latest ($VERSION_LABEL)" - # Upsert the latest version to versions.json + # Upsert the latest version into versions.json jq --arg version "latest" --arg label "$LATEST_LABEL" ' if any(.path == $version) then map(if .path == $version then .label = $label else . end) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index a42dc8028..1c22a5345 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,6 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: v5 - docs_version_label: 'Version 5' + docs_version: v5.1 is_latest: true From 9e7b0d022876a1c48e70e98c387dae30d6958e32 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 11:59:33 +0200 Subject: [PATCH 24/72] ci: test patch version --- .github/workflows/tmp-publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 1c22a5345..12dfee1ab 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -23,5 +23,5 @@ jobs: with: docs_output_dir: 'docs/dist' github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: v5.1 - is_latest: true + docs_version: v4.0.3 + is_latest: false From e871c0e0f1b3fdbff4c4889a417a103c50d1af19 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 15:39:06 +0200 Subject: [PATCH 25/72] fix: do not commit and push if no file was touched --- .github/actions/publish-docs/action.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index 624fcca34..e33eec66a 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -109,19 +109,26 @@ runs: mv versions.json.tmp versions.json - - name: Commit changes + - name: Check for git changes + id: git_diff shell: bash working-directory: icp-pages run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Update static docs assets for version: ${{ inputs.docs_version }}" + if [ -z "$(git status --porcelain)" ]; then + echo "is_dirty=false" >> $GITHUB_OUTPUT + else + echo "is_dirty=true" >> $GITHUB_OUTPUT + fi - - name: Push changes + - name: Commit and push changes shell: bash + if: steps.git_diff.outputs.is_dirty == 'true' working-directory: icp-pages env: GITHUB_TOKEN: ${{ inputs.github_token }} run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Update static docs assets for version: ${{ inputs.docs_version }}" git push origin icp-pages From cf0f2f6f59471d20bbc53eca916cc709288e69f1 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 7 Aug 2025 15:43:41 +0200 Subject: [PATCH 26/72] ci: simplify detecting git changes --- .github/actions/publish-docs/action.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml index e33eec66a..47869e13d 100644 --- a/.github/actions/publish-docs/action.yml +++ b/.github/actions/publish-docs/action.yml @@ -109,24 +109,17 @@ runs: mv versions.json.tmp versions.json - - name: Check for git changes - id: git_diff + - name: Commit and push changes if there are any shell: bash working-directory: icp-pages + env: + GITHUB_TOKEN: ${{ inputs.github_token }} run: | if [ -z "$(git status --porcelain)" ]; then - echo "is_dirty=false" >> $GITHUB_OUTPUT - else - echo "is_dirty=true" >> $GITHUB_OUTPUT + echo "No changes to commit" + exit 0 fi - - name: Commit and push changes - shell: bash - if: steps.git_diff.outputs.is_dirty == 'true' - working-directory: icp-pages - env: - GITHUB_TOKEN: ${{ inputs.github_token }} - run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . From 56977f4d1f5f2ab25e454d16cea4cc7534a92d73 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Fri, 8 Aug 2025 19:52:07 +0200 Subject: [PATCH 27/72] ci: use github action from ci-tools --- .github/actions/publish-docs/action.yml | 127 ------------------------ .github/workflows/tmp-publish-docs.yml | 26 ++++- docs/astro.config.mjs | 2 +- docs/src/content/docs/index.mdx | 2 +- 4 files changed, 23 insertions(+), 134 deletions(-) delete mode 100644 .github/actions/publish-docs/action.yml diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml deleted file mode 100644 index 47869e13d..000000000 --- a/.github/actions/publish-docs/action.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: Publish docs -description: Push static docs assets to the `icp-pages` branch and triggers the `pull-project-docs` workflow on the docs repo - -inputs: - docs_output_dir: - description: The directory containing the static docs assets to publish - required: true - docs_version: - description: The version of the docs to publish. Allowed values are `vX` | `vX.Y` | `vX.Y.Z` | `beta` | `dev` | `next` | `nightly` (where `X`, `Y`, `Z` are numbers) - required: true - docs_version_label: - description: The label to use for the docs version. If not provided, the `docs_version` will be used - required: false - docs_repo: - description: The repository to trigger the workflow on to publish the docs - required: false - default: 'dfinity/icp-sdk-js-docs' - is_latest: - description: Whether the docs version is the latest version. If true, the `docs_version` will be symlinked to the latest version of the published docs - required: true - github_token: - description: The GitHub token to use for pushing to the `icp-pages` branch - required: true - -runs: - using: 'composite' - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - ref: icp-pages - path: icp-pages - - - name: Check if the docs version is valid - shell: bash - id: check-docs-version - run: | - if [[ ${{ inputs.docs_version }} =~ ^v[0-9]+(\.[0-9]+)?(\.[0-9]+)?$ ]]; then - echo "STABLE_VERSION=${{ inputs.docs_version }}" >> $GITHUB_ENV - elif [[ ${{ inputs.docs_version }} =~ ^(beta|dev|next|nightly)$ ]]; then - echo "Not a stable version, versions.json will not be updated" - else - echo "Invalid docs version: ${{ inputs.docs_version }}" - exit 1 - fi - - - name: Zip files from the docs output directory - shell: bash - run: | - ZIP_FILE_NAME=${{ inputs.docs_version }}.zip - zip -r $ZIP_FILE_NAME ${{ inputs.docs_output_dir }} - echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV - - - name: Copy zip to the icp-pages branch - shell: bash - run: | - cp $ZIP_FILE_NAME icp-pages/ - - - name: Symlink the zip file to the latest version - shell: bash - if: ${{ inputs.is_latest == 'true' }} - working-directory: icp-pages - run: | - # Remove existing symlink if it exists, then create new one - rm -f latest.zip - ln -s $ZIP_FILE_NAME latest.zip - - - name: Create versions.json if it doesn't exist - shell: bash - working-directory: icp-pages - run: | - if [ ! -f versions.json ]; then - echo "[]" > versions.json - fi - - - name: Add or update the version in versions.json - shell: bash - if: ${{ env.STABLE_VERSION != '' }} - working-directory: icp-pages - env: - DOCS_VERSION_LABEL: ${{ inputs.docs_version_label }} - run: | - # Upsert the docs_version: if it exists, update the label; if not, add it - jq --arg version "$STABLE_VERSION" --arg label "$DOCS_VERSION_LABEL" ' - if any(.path == $version) then - # Update existing version with new label, if the label is provided - map(if ((.path == $version) and ($label != "")) then .label = $label else . end) - else - # Add new version with the provided label, or fallback to the version for the label - . + [{"path": $version, "label": (if $label != "" then $label else $version end)}] - end' versions.json > versions.json.tmp - - mv versions.json.tmp versions.json - - - name: Add or update the latest version in versions.json - shell: bash - if: ${{ inputs.is_latest == 'true' && env.STABLE_VERSION != '' }} - working-directory: icp-pages - run: | - VERSION_LABEL="$(jq -r --arg version "$STABLE_VERSION" '.[] | select(.path == $version) | .label' versions.json)" - LATEST_LABEL="latest ($VERSION_LABEL)" - - # Upsert the latest version into versions.json - jq --arg version "latest" --arg label "$LATEST_LABEL" ' - if any(.path == $version) then - map(if .path == $version then .label = $label else . end) - else - [{"path": $version, "label": $label}] + . - end' versions.json > versions.json.tmp - - mv versions.json.tmp versions.json - - - name: Commit and push changes if there are any - shell: bash - working-directory: icp-pages - env: - GITHUB_TOKEN: ${{ inputs.github_token }} - run: | - if [ -z "$(git status --porcelain)" ]; then - echo "No changes to commit" - exit 0 - fi - - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Update static docs assets for version: ${{ inputs.docs_version }}" - git push origin icp-pages diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 12dfee1ab..f16bb688c 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -16,12 +16,28 @@ jobs: with: node_version_file: '.nvmrc' - - run: pnpm -F docs build + - uses: dfinity/ci-tools/actions/extract-version@luca/extract-version-action + id: ver + with: + file: 'package.json' + + - name: Build docs for version + working-directory: docs + env: + BASE_PATH: /core/${{ steps.ver.outputs.major }}/ + run: pnpm build --outDir dist/${{ steps.ver.outputs.major }} + + - name: Build docs for latest + working-directory: docs + env: + BASE_PATH: /core/latest/ + run: pnpm build --outDir dist/latest - - name: Publish docs - uses: ./.github/actions/publish-docs + - name: Assemble docs + uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action with: docs_output_dir: 'docs/dist' + docs_version: v${{ steps.ver.outputs.major }} + docs_version_label: v${{ steps.ver.outputs.major }} + latest_version: v${{ steps.ver.outputs.major }} github_token: ${{ secrets.GITHUB_TOKEN }} - docs_version: v4.0.3 - is_latest: false diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 95e0c66c1..5e989617d 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -7,7 +7,7 @@ import { dfinityStarlightTheme } from './src/plugins/theme'; // https://astro.build/config export default defineConfig({ site: 'https://js.icp.build/', - base: '/core/', + base: process.env.BASE_PATH ?? '/core/local/', integrations: [ starlight({ title: 'ICP JS SDK Core', diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index 4d196e18a..0433fdf23 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -5,6 +5,6 @@ template: splash hero: actions: - text: Getting started - link: /core/libs/agent/ + link: /core/latest/libs/agent/ icon: right-arrow --- From 8785a3e964d7eeefdf9d203f41f5f8e25974c85b Mon Sep 17 00:00:00 2001 From: ilbertt Date: Fri, 8 Aug 2025 20:13:30 +0200 Subject: [PATCH 28/72] fix: prefix with `v` --- .github/workflows/tmp-publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index f16bb688c..65066fa98 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -24,8 +24,8 @@ jobs: - name: Build docs for version working-directory: docs env: - BASE_PATH: /core/${{ steps.ver.outputs.major }}/ - run: pnpm build --outDir dist/${{ steps.ver.outputs.major }} + BASE_PATH: /core/v${{ steps.ver.outputs.major }}/ + run: pnpm build --outDir dist/v${{ steps.ver.outputs.major }} - name: Build docs for latest working-directory: docs From 5e4a501c2e8219d7ebc587ce3367974a3f601c37 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 10:46:42 +0200 Subject: [PATCH 29/72] ci: point to specific commit --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 65066fa98..570087132 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -34,7 +34,7 @@ jobs: run: pnpm build --outDir dist/latest - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action + uses: dfinity/ci-tools/actions/assemble-docs@be75dec96ed874f1a9c47b9df76994ebfdec5ab3 with: docs_output_dir: 'docs/dist' docs_version: v${{ steps.ver.outputs.major }} From e8695a18e1b1bde6853dc77254f0e3b1308a63b4 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 10:53:11 +0200 Subject: [PATCH 30/72] ci: update commit --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 570087132..564b7d613 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -34,7 +34,7 @@ jobs: run: pnpm build --outDir dist/latest - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@be75dec96ed874f1a9c47b9df76994ebfdec5ab3 + uses: dfinity/ci-tools/actions/assemble-docs@f2c970e1840c795fdcb060627cb7eb9c721a0f48 with: docs_output_dir: 'docs/dist' docs_version: v${{ steps.ver.outputs.major }} From 3ee3117d42a8f509a5225c3e410e6b4d2618f91d Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 10:56:55 +0200 Subject: [PATCH 31/72] ci: update commit --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 564b7d613..908098d3e 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -34,7 +34,7 @@ jobs: run: pnpm build --outDir dist/latest - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@f2c970e1840c795fdcb060627cb7eb9c721a0f48 + uses: dfinity/ci-tools/actions/assemble-docs@e7a23b307ec728909594191295a533de7d03114a with: docs_output_dir: 'docs/dist' docs_version: v${{ steps.ver.outputs.major }} From ec3816915660b6efdb62cd44baea4b4551e5adb8 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 11:07:18 +0200 Subject: [PATCH 32/72] ci: change commit and prepare version step --- .github/workflows/tmp-publish-docs.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 908098d3e..e61661d8e 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -17,24 +17,29 @@ jobs: node_version_file: '.nvmrc' - uses: dfinity/ci-tools/actions/extract-version@luca/extract-version-action - id: ver + id: extract-version with: file: 'package.json' - - name: Build docs for version + - name: Prepare version + id: ver + run: | + echo "version=v${{ steps.extract-version.outputs.major }}" >> $GITHUB_OUTPUT + + - name: Build docs for version ${{ steps.ver.outputs.version }} working-directory: docs env: - BASE_PATH: /core/v${{ steps.ver.outputs.major }}/ - run: pnpm build --outDir dist/v${{ steps.ver.outputs.major }} + BASE_PATH: /core/${{ steps.ver.outputs.version }}/ + run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} - - name: Build docs for latest + - name: Build docs for version latest working-directory: docs env: BASE_PATH: /core/latest/ run: pnpm build --outDir dist/latest - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@e7a23b307ec728909594191295a533de7d03114a + uses: dfinity/ci-tools/actions/assemble-docs@b1731b162e1677d5c7a89cf667b77e2b1109baf6 with: docs_output_dir: 'docs/dist' docs_version: v${{ steps.ver.outputs.major }} From 4bcec5c178aba10bd2d9a5438347cc9f59080056 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 11:18:54 +0200 Subject: [PATCH 33/72] ci: fix version --- .github/workflows/tmp-publish-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index e61661d8e..7640abd89 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -42,7 +42,7 @@ jobs: uses: dfinity/ci-tools/actions/assemble-docs@b1731b162e1677d5c7a89cf667b77e2b1109baf6 with: docs_output_dir: 'docs/dist' - docs_version: v${{ steps.ver.outputs.major }} - docs_version_label: v${{ steps.ver.outputs.major }} - latest_version: v${{ steps.ver.outputs.major }} + docs_version: ${{ steps.ver.outputs.version }} + docs_version_label: ${{ steps.ver.outputs.version }} + latest_version: ${{ steps.ver.outputs.version }} github_token: ${{ secrets.GITHUB_TOKEN }} From 1dd2c1ec5e395545aebc4ca67a5f7546e66c2842 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 11:39:36 +0200 Subject: [PATCH 34/72] ci: update assemble docs action commit --- .github/workflows/tmp-publish-docs.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 7640abd89..455596099 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -38,8 +38,14 @@ jobs: BASE_PATH: /core/latest/ 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@b1731b162e1677d5c7a89cf667b77e2b1109baf6 + uses: dfinity/ci-tools/actions/assemble-docs@965d31562a9430df7062e3de160980171de75e9f with: docs_output_dir: 'docs/dist' docs_version: ${{ steps.ver.outputs.version }} From 409d570eadaf0c66cc2d90ef9e972e97ca132d3f Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 11:49:02 +0200 Subject: [PATCH 35/72] ci: update ref for assemble docs --- .github/workflows/tmp-publish-docs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 455596099..cf37b2878 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -45,10 +45,11 @@ jobs: path: icp-pages - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@965d31562a9430df7062e3de160980171de75e9f + uses: dfinity/ci-tools/actions/assemble-docs@62c77c0025a556278392c17d5a9d7f013113e5a6 with: docs_output_dir: 'docs/dist' docs_version: ${{ steps.ver.outputs.version }} docs_version_label: ${{ steps.ver.outputs.version }} latest_version: ${{ steps.ver.outputs.version }} + icp_pages_dir: 'icp-pages' github_token: ${{ secrets.GITHUB_TOKEN }} From 3a28013eaadced636a901847582b7ea9a525e811 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 11:52:51 +0200 Subject: [PATCH 36/72] ci: update ref for assemble docs --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index cf37b2878..d749b9eb7 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -45,7 +45,7 @@ jobs: path: icp-pages - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@62c77c0025a556278392c17d5a9d7f013113e5a6 + uses: dfinity/ci-tools/actions/assemble-docs@ac005ed55ab9ff680da042b3b9b3a9041d2598ab with: docs_output_dir: 'docs/dist' docs_version: ${{ steps.ver.outputs.version }} From fef692b7b4159f631626e59b2878d0a4f09a9e2f Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 11:59:23 +0200 Subject: [PATCH 37/72] ci: test beta version --- .github/workflows/tmp-publish-docs.yml | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index d749b9eb7..0a31e1ae7 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -26,17 +26,23 @@ jobs: run: | echo "version=v${{ steps.extract-version.outputs.major }}" >> $GITHUB_OUTPUT - - name: Build docs for version ${{ steps.ver.outputs.version }} + # - name: Build docs for version ${{ steps.ver.outputs.version }} + # working-directory: docs + # env: + # BASE_PATH: /core/${{ steps.ver.outputs.version }}/ + # run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} + + # - name: Build docs for version latest + # working-directory: docs + # env: + # BASE_PATH: /core/latest/ + # run: pnpm build --outDir dist/latest + + - name: Build docs for version beta working-directory: docs env: - BASE_PATH: /core/${{ steps.ver.outputs.version }}/ - run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} - - - name: Build docs for version latest - working-directory: docs - env: - BASE_PATH: /core/latest/ - run: pnpm build --outDir dist/latest + BASE_PATH: /core/beta/ + run: pnpm build --outDir dist/beta - name: Checkout icp-pages branch uses: actions/checkout@v4 @@ -45,11 +51,10 @@ jobs: path: icp-pages - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@ac005ed55ab9ff680da042b3b9b3a9041d2598ab + uses: dfinity/ci-tools/actions/assemble-docs@1457f3e283537f907cc593a76fa92ede21f22a0e with: docs_output_dir: 'docs/dist' - docs_version: ${{ steps.ver.outputs.version }} - docs_version_label: ${{ steps.ver.outputs.version }} - latest_version: ${{ steps.ver.outputs.version }} + docs_version: beta + docs_version_label: Beta icp_pages_dir: 'icp-pages' github_token: ${{ secrets.GITHUB_TOKEN }} From 57c65d717c08fdb2cea7b66fa1c7faa3b263df6a Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 12:08:54 +0200 Subject: [PATCH 38/72] ci: test next tag --- .github/workflows/tmp-publish-docs.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 0a31e1ae7..2250fe7d4 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -38,11 +38,11 @@ jobs: # BASE_PATH: /core/latest/ # run: pnpm build --outDir dist/latest - - name: Build docs for version beta + - name: Build docs for version next working-directory: docs env: - BASE_PATH: /core/beta/ - run: pnpm build --outDir dist/beta + BASE_PATH: /core/next/ + run: pnpm build --outDir dist/next - name: Checkout icp-pages branch uses: actions/checkout@v4 @@ -51,10 +51,10 @@ jobs: path: icp-pages - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@1457f3e283537f907cc593a76fa92ede21f22a0e + uses: dfinity/ci-tools/actions/assemble-docs@1f4ceaa7a105c2f13ebe79126cc026a992b43648 with: docs_output_dir: 'docs/dist' - docs_version: beta + docs_version: next docs_version_label: Beta icp_pages_dir: 'icp-pages' github_token: ${{ secrets.GITHUB_TOKEN }} From d33ba6908962b8c7dd47b8b019e79c8637e83523 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 13:10:44 +0200 Subject: [PATCH 39/72] chore: update action version --- .github/workflows/tmp-publish-docs.yml | 32 +++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 2250fe7d4..1ee18996b 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -26,23 +26,17 @@ jobs: run: | echo "version=v${{ steps.extract-version.outputs.major }}" >> $GITHUB_OUTPUT - # - name: Build docs for version ${{ steps.ver.outputs.version }} - # working-directory: docs - # env: - # BASE_PATH: /core/${{ steps.ver.outputs.version }}/ - # run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} - - # - name: Build docs for version latest - # working-directory: docs - # env: - # BASE_PATH: /core/latest/ - # run: pnpm build --outDir dist/latest - - - name: Build docs for version next + - name: Build docs for version ${{ steps.ver.outputs.version }} working-directory: docs env: - BASE_PATH: /core/next/ - run: pnpm build --outDir dist/next + BASE_PATH: /core/${{ steps.ver.outputs.version }}/ + run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} + + - name: Build docs for version latest + working-directory: docs + env: + BASE_PATH: /core/latest/ + run: pnpm build --outDir dist/latest - name: Checkout icp-pages branch uses: actions/checkout@v4 @@ -51,10 +45,10 @@ jobs: path: icp-pages - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@1f4ceaa7a105c2f13ebe79126cc026a992b43648 + uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action with: docs_output_dir: 'docs/dist' - docs_version: next - docs_version_label: Beta + docs_version: ${{ steps.ver.outputs.version }} + docs_version_label: ${{ steps.ver.outputs.version }} + latest_version: ${{ steps.ver.outputs.version }} icp_pages_dir: 'icp-pages' - github_token: ${{ secrets.GITHUB_TOKEN }} From e195b0b919d958bf28062e61e9636a776ee7af79 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 16:13:27 +0200 Subject: [PATCH 40/72] feat: submit docs to dfinity/icp-js-sdk-docs repo --- .github/workflows/tmp-publish-docs.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 1ee18996b..cb8fc58a8 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -9,6 +9,13 @@ jobs: runs-on: ubuntu-latest if: ${{ github.head_ref == 'luca/SDK-2264-push-docs' }} steps: + - name: Create GitHub App Token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + id: generate_token + with: + app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }} + private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }} + - uses: actions/checkout@v4 - name: Setup PNPM @@ -52,3 +59,8 @@ jobs: docs_version_label: ${{ steps.ver.outputs.version }} latest_version: ${{ steps.ver.outputs.version }} icp_pages_dir: 'icp-pages' + + - name: Submit Documentation + uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action + with: + token: ${{ steps.generate_token.outputs.token }} From 8254712777dee54ff2d97123a33602d87bceb6e0 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 16:14:11 +0200 Subject: [PATCH 41/72] refactor: explicit params --- .github/workflows/tmp-publish-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index cb8fc58a8..e976f80d2 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -63,4 +63,6 @@ jobs: - name: Submit Documentation uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action with: + destination_repo: 'dfinity/icp-js-sdk-docs' + source_branch: 'icp-pages' token: ${{ steps.generate_token.outputs.token }} From 1bd7adc26ecd31840974f9a42d31dda7b5187395 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 18:23:07 +0200 Subject: [PATCH 42/72] feat: versions dropdown plugin --- docs/astro.config.mjs | 2 + .../versions/components/VersionDropdown.astro | 75 +++++++++++++++++++ .../components/VersionedSidebar.astro | 18 +++++ docs/src/plugins/versions/index.ts | 1 + docs/src/plugins/versions/versions-plugin.ts | 16 ++++ 5 files changed, 112 insertions(+) create mode 100644 docs/src/plugins/versions/components/VersionDropdown.astro create mode 100644 docs/src/plugins/versions/components/VersionedSidebar.astro create mode 100644 docs/src/plugins/versions/index.ts create mode 100644 docs/src/plugins/versions/versions-plugin.ts diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 5e989617d..3da052f9a 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -3,6 +3,7 @@ import { defineConfig } from 'astro/config'; import starlight from '@astrojs/starlight'; import { libsPlugin } from './src/plugins/libs'; import { dfinityStarlightTheme } from './src/plugins/theme'; +import { versionsPlugin } from './src/plugins/versions'; // https://astro.build/config export default defineConfig({ @@ -34,6 +35,7 @@ export default defineConfig({ }, ], }), + versionsPlugin(), ], sidebar: [ { diff --git a/docs/src/plugins/versions/components/VersionDropdown.astro b/docs/src/plugins/versions/components/VersionDropdown.astro new file mode 100644 index 000000000..3b2db3a41 --- /dev/null +++ b/docs/src/plugins/versions/components/VersionDropdown.astro @@ -0,0 +1,75 @@ +--- +const IS_DEV = import.meta.env.DEV; +const BASE_URL = import.meta.env.BASE_URL; +--- + +
+ + +
+ + + + diff --git a/docs/src/plugins/versions/components/VersionedSidebar.astro b/docs/src/plugins/versions/components/VersionedSidebar.astro new file mode 100644 index 000000000..c5ac19773 --- /dev/null +++ b/docs/src/plugins/versions/components/VersionedSidebar.astro @@ -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; +--- + + + + + + + +
+ +
diff --git a/docs/src/plugins/versions/index.ts b/docs/src/plugins/versions/index.ts new file mode 100644 index 000000000..2ce087533 --- /dev/null +++ b/docs/src/plugins/versions/index.ts @@ -0,0 +1 @@ +export * from './versions-plugin.ts'; diff --git a/docs/src/plugins/versions/versions-plugin.ts b/docs/src/plugins/versions/versions-plugin.ts new file mode 100644 index 000000000..dd733a0d7 --- /dev/null +++ b/docs/src/plugins/versions/versions-plugin.ts @@ -0,0 +1,16 @@ +import type { StarlightPlugin } from '@astrojs/starlight/types'; + +export function versionsPlugin(): StarlightPlugin { + return { + name: 'versions-starlight-plugin', + hooks: { + 'config:setup': ctx => { + ctx.updateConfig({ + components: { + Sidebar: './src/plugins/versions/components/VersionedSidebar.astro', + }, + }); + }, + }, + }; +} From f3a97ea2944ab69a99cb544a5b92e61093ed5b28 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 18:36:19 +0200 Subject: [PATCH 43/72] ci: pin submit-docs action version --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index e976f80d2..89f836daf 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -61,7 +61,7 @@ jobs: icp_pages_dir: 'icp-pages' - name: Submit Documentation - uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action + uses: dfinity/ci-tools/actions/submit-docs@3e21d03bce30d70e2c13748e70ae05086107b1b1 with: destination_repo: 'dfinity/icp-js-sdk-docs' source_branch: 'icp-pages' From 6d55abf83d69250282f2fee2d410030f862c1515 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 18:44:17 +0200 Subject: [PATCH 44/72] ci:m update submit-docs action ref --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 89f836daf..7e8ccbe21 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -61,7 +61,7 @@ jobs: icp_pages_dir: 'icp-pages' - name: Submit Documentation - uses: dfinity/ci-tools/actions/submit-docs@3e21d03bce30d70e2c13748e70ae05086107b1b1 + uses: dfinity/ci-tools/actions/submit-docs@7b3d4498f491e2d3e740273f9788f649848969e3 with: destination_repo: 'dfinity/icp-js-sdk-docs' source_branch: 'icp-pages' From 2279b6320ad3b9021d1920fe4500a288615305db Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 19:10:50 +0200 Subject: [PATCH 45/72] fix: correct versions.json path --- .github/workflows/tmp-publish-docs.yml | 4 ++-- docs/astro.config.mjs | 9 ++++++-- .../versions/components/VersionDropdown.astro | 14 ++++++++++--- docs/src/plugins/versions/versions-plugin.ts | 21 ++++++++++++++++++- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 7e8ccbe21..40dd913e1 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -36,13 +36,13 @@ jobs: - name: Build docs for version ${{ steps.ver.outputs.version }} working-directory: docs env: - BASE_PATH: /core/${{ steps.ver.outputs.version }}/ + DOCS_VERSION: ${{ steps.ver.outputs.version }} run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} - name: Build docs for version latest working-directory: docs env: - BASE_PATH: /core/latest/ + DOCS_VERSION: latest run: pnpm build --outDir dist/latest - name: Checkout icp-pages branch diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 3da052f9a..6a3d556cb 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -5,10 +5,13 @@ import { libsPlugin } from './src/plugins/libs'; import { dfinityStarlightTheme } from './src/plugins/theme'; import { versionsPlugin } from './src/plugins/versions'; +const BASE_DOCS_PATH = '/core'; +const docsVersion = process.env.DOCS_VERSION ?? 'local'; + // https://astro.build/config export default defineConfig({ site: 'https://js.icp.build/', - base: process.env.BASE_PATH ?? '/core/local/', + base: `${BASE_DOCS_PATH}/${docsVersion}/`, integrations: [ starlight({ title: 'ICP JS SDK Core', @@ -35,7 +38,9 @@ export default defineConfig({ }, ], }), - versionsPlugin(), + versionsPlugin({ + versionsJsonPath: `${BASE_DOCS_PATH}/versions.json`, + }), ], sidebar: [ { diff --git a/docs/src/plugins/versions/components/VersionDropdown.astro b/docs/src/plugins/versions/components/VersionDropdown.astro index 3b2db3a41..4449e8f6b 100644 --- a/docs/src/plugins/versions/components/VersionDropdown.astro +++ b/docs/src/plugins/versions/components/VersionDropdown.astro @@ -18,10 +18,14 @@ const BASE_URL = import.meta.env.BASE_URL; const currentBase = BASE_URL.endsWith('/') ? BASE_URL : BASE_URL + '/'; - const versionsUrl = `${BASE_URL}versions.json`; - let versions = [{ path: 'local', label: 'local' }]; + 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(); @@ -29,7 +33,11 @@ const BASE_URL = import.meta.env.BASE_URL; versions = data; } } - } catch {} + } catch (e) { + console.error('Error fetching versions.json', e); + } + } else { + versions = [{ path: 'local', label: 'local' }]; } const currentVersion = (currentBase.replace(/\/$/, '').split('/').pop() || '').toLowerCase(); diff --git a/docs/src/plugins/versions/versions-plugin.ts b/docs/src/plugins/versions/versions-plugin.ts index dd733a0d7..f1e360e1b 100644 --- a/docs/src/plugins/versions/versions-plugin.ts +++ b/docs/src/plugins/versions/versions-plugin.ts @@ -1,11 +1,30 @@ import type { StarlightPlugin } from '@astrojs/starlight/types'; -export function versionsPlugin(): StarlightPlugin { +/** + * Options for the VersionsPlugin. + */ +interface VersionsPluginOptions { + /** + * The path at which the `versions.json` file is served in production. + */ + versionsJsonPath: string; +} + +export function versionsPlugin(opts: VersionsPluginOptions): StarlightPlugin { return { name: 'versions-starlight-plugin', hooks: { 'config:setup': ctx => { ctx.updateConfig({ + head: [ + { + tag: 'meta', + attrs: { + name: 'versions-json-path', + content: opts.versionsJsonPath, + }, + }, + ], components: { Sidebar: './src/plugins/versions/components/VersionedSidebar.astro', }, From f6ebaa765c896131689887948d692fab4ca123d6 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Mon, 11 Aug 2025 21:08:45 +0200 Subject: [PATCH 46/72] ci: use action branch --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 40dd913e1..9bfcb9611 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -61,7 +61,7 @@ jobs: icp_pages_dir: 'icp-pages' - name: Submit Documentation - uses: dfinity/ci-tools/actions/submit-docs@7b3d4498f491e2d3e740273f9788f649848969e3 + uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action with: destination_repo: 'dfinity/icp-js-sdk-docs' source_branch: 'icp-pages' From 5072f5cac3a0d5ea3da9fec844114fc9872ab8cb Mon Sep 17 00:00:00 2001 From: ilbertt Date: Tue, 12 Aug 2025 10:55:55 +0200 Subject: [PATCH 47/72] ci: update param --- .github/workflows/tmp-publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 9bfcb9611..5819015fc 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -57,7 +57,7 @@ jobs: docs_output_dir: 'docs/dist' docs_version: ${{ steps.ver.outputs.version }} docs_version_label: ${{ steps.ver.outputs.version }} - latest_version: ${{ steps.ver.outputs.version }} + latest_version_label: 'latest (${{ steps.ver.outputs.version }})' icp_pages_dir: 'icp-pages' - name: Submit Documentation From d6ec937d209c87267ac77a72257558765a1c18ab Mon Sep 17 00:00:00 2001 From: ilbertt Date: Tue, 12 Aug 2025 11:56:16 +0200 Subject: [PATCH 48/72] ci: add token for icp-js-sdk-docs --- .github/workflows/tmp-publish-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 5819015fc..2c55082a6 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -15,6 +15,8 @@ jobs: with: 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@v4 From 68293cb392365ebf917580f56bfb7cc7160ef995 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Tue, 12 Aug 2025 17:34:57 +0200 Subject: [PATCH 49/72] fix: add current tag to version dropdown if not present --- .../versions/components/VersionDropdown.astro | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/src/plugins/versions/components/VersionDropdown.astro b/docs/src/plugins/versions/components/VersionDropdown.astro index 4449e8f6b..d8b4b2306 100644 --- a/docs/src/plugins/versions/components/VersionDropdown.astro +++ b/docs/src/plugins/versions/components/VersionDropdown.astro @@ -16,8 +16,6 @@ const BASE_URL = import.meta.env.BASE_URL; return; } - const currentBase = BASE_URL.endsWith('/') ? BASE_URL : BASE_URL + '/'; - let versions = []; if (!IS_DEV) { try { @@ -36,13 +34,17 @@ const BASE_URL = import.meta.env.BASE_URL; } catch (e) { console.error('Error fetching versions.json', e); } - } else { - versions = [{ path: 'local', label: 'local' }]; } - - const currentVersion = (currentBase.replace(/\/$/, '').split('/').pop() || '').toLowerCase(); + + 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 = currentBase.replace(/([^/]+)\/$/, `${v.path}/`); @@ -55,7 +57,7 @@ const BASE_URL = import.meta.env.BASE_URL; } select.appendChild(opt); } - + select.addEventListener('change', () => { const href = select.value; const current = pathname + search + hash; From 5e3e965c29e59c203140ebf0879eb7c0c34ef2f5 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Tue, 12 Aug 2025 17:35:10 +0200 Subject: [PATCH 50/72] refactor: rename from core to agent --- docs/astro.config.mjs | 4 ++-- docs/src/content/docs/index.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 6a3d556cb..baeac4438 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -5,7 +5,7 @@ import { libsPlugin } from './src/plugins/libs'; import { dfinityStarlightTheme } from './src/plugins/theme'; import { versionsPlugin } from './src/plugins/versions'; -const BASE_DOCS_PATH = '/core'; +const BASE_DOCS_PATH = '/agent'; const docsVersion = process.env.DOCS_VERSION ?? 'local'; // https://astro.build/config @@ -14,7 +14,7 @@ export default defineConfig({ base: `${BASE_DOCS_PATH}/${docsVersion}/`, integrations: [ starlight({ - title: 'ICP JS SDK Core', + title: 'ICP JS SDK Agent', social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/dfinity/agent-js' }], plugins: [ dfinityStarlightTheme(), diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index 0433fdf23..eaead04d9 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -1,10 +1,10 @@ --- -title: ICP JavaScript SDK - Core +title: ICP JavaScript SDK - Agent description: Get started building your JavaScript powered ICP application. template: splash hero: actions: - text: Getting started - link: /core/latest/libs/agent/ + link: /agent/latest/libs/agent/ icon: right-arrow --- From 85a02c91996b3128e1bbd56c9c83c5845ca518da Mon Sep 17 00:00:00 2001 From: ilbertt Date: Tue, 12 Aug 2025 17:57:25 +0200 Subject: [PATCH 51/72] feat: index page and version dropdown fixes --- docs/src/content/docs/index.mdx | 22 +++++++++++++------ docs/src/plugins/libs/libs-plugin.ts | 1 + .../versions/components/VersionDropdown.astro | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index eaead04d9..a37ba060a 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -1,10 +1,18 @@ --- title: ICP JavaScript SDK - Agent -description: Get started building your JavaScript powered ICP application. -template: splash -hero: - actions: - - text: Getting started - link: /agent/latest/libs/agent/ - icon: right-arrow +description: This package has been superseded by @icp-sdk/core. Please use the new SDK instead. +template: doc +next: + link: libs/agent/ + label: Go to Agent docs --- + +import { Aside } from '@astrojs/starlight/components'; + +# New package + + diff --git a/docs/src/plugins/libs/libs-plugin.ts b/docs/src/plugins/libs/libs-plugin.ts index f96779822..498d44a25 100644 --- a/docs/src/plugins/libs/libs-plugin.ts +++ b/docs/src/plugins/libs/libs-plugin.ts @@ -254,6 +254,7 @@ export function libsPlugin(opts: LibsLoaderOptions): StarlightPlugin { ctx.updateConfig({ sidebar: [ + { label: 'Overview', link: '/' }, { label: 'Libraries', items: librarySidebarItems }, ...(ctx.config.sidebar || []), ...sidebarItems, diff --git a/docs/src/plugins/versions/components/VersionDropdown.astro b/docs/src/plugins/versions/components/VersionDropdown.astro index d8b4b2306..f85fb97d4 100644 --- a/docs/src/plugins/versions/components/VersionDropdown.astro +++ b/docs/src/plugins/versions/components/VersionDropdown.astro @@ -47,8 +47,8 @@ const BASE_URL = import.meta.env.BASE_URL; select.innerHTML = ''; for (const v of versions) { - const newBase = currentBase.replace(/([^/]+)\/$/, `${v.path}/`); - const href = pathname.replace(currentBase, newBase) + search + hash; + const newBase = BASE_URL.replace(/([^/]+)\/$/, `${v.path}/`); + const href = pathname.replace(BASE_URL, newBase) + search + hash; const opt = document.createElement('option'); opt.value = href; opt.textContent = v.label; From 4a008efcb0fcfa2e9cdeee91fad01f11ed3f2f7e Mon Sep 17 00:00:00 2001 From: ilbertt Date: Tue, 12 Aug 2025 18:00:06 +0200 Subject: [PATCH 52/72] feat: add publish docs step to publish action --- .github/workflows/publish.yml | 63 ++++++++++++++++++++++++++ .github/workflows/tmp-publish-docs.yml | 1 - 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 66b09ea07..6633f7bff 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -43,3 +43,66 @@ jobs: env: JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} PROJECT_PATH: docs + + publish-docs: + if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') + runs-on: ubuntu-latest + steps: + - name: Create GitHub App Token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + id: generate_token + with: + 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@v4 + + - name: Setup PNPM + uses: dfinity/ci-tools/actions/setup-pnpm@main + with: + node_version_file: '.nvmrc' + + - uses: dfinity/ci-tools/actions/extract-version@luca/extract-version-action + id: extract-version + with: + file: 'package.json' + + - name: Prepare version + id: ver + run: | + echo "version=v${{ steps.extract-version.outputs.major }}" >> $GITHUB_OUTPUT + + - name: Build docs for version ${{ steps.ver.outputs.version }} + working-directory: docs + env: + DOCS_VERSION: ${{ steps.ver.outputs.version }} + run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} + + - name: Build docs for version latest + working-directory: docs + env: + DOCS_VERSION: latest + 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@luca/assemble-docs-action + with: + docs_output_dir: 'docs/dist' + docs_version: ${{ steps.ver.outputs.version }} + docs_version_label: ${{ steps.ver.outputs.version }} + latest_version_label: 'latest (${{ steps.ver.outputs.version }})' + icp_pages_dir: 'icp-pages' + + - name: Submit Documentation + uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action + with: + destination_repo: 'dfinity/icp-js-sdk-docs' + token: ${{ steps.generate_token.outputs.token }} diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 2c55082a6..91d67e56c 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -66,5 +66,4 @@ jobs: uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action with: destination_repo: 'dfinity/icp-js-sdk-docs' - source_branch: 'icp-pages' token: ${{ steps.generate_token.outputs.token }} From 573d45e35e6f09c99a1517f716cb95b18c9435d5 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Tue, 12 Aug 2025 19:53:05 +0200 Subject: [PATCH 53/72] refactor: add todos --- .github/workflows/publish.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6633f7bff..ae1f65d81 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,6 +36,7 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + # TODO: remove this step once we migrate to the new docs deployment workflow - name: Deploy Docs to Juno satellite uses: junobuild/juno-action@main with: @@ -44,6 +45,8 @@ jobs: JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} PROJECT_PATH: docs + # For now, this job only runs in parallel to test the new docs deployment workflow + # TODO: make it depend on the publish job once we remove the docs deployment step from the publish job publish-docs: if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') runs-on: ubuntu-latest From 4c4b54a2e2b6bebd66c9cd1691028cbda9c03ce5 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 13 Aug 2025 14:15:17 +0200 Subject: [PATCH 54/72] ci: update actions branches --- .github/workflows/publish.yml | 2 +- .github/workflows/tmp-publish-docs.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae1f65d81..27762b5f2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -105,7 +105,7 @@ jobs: icp_pages_dir: 'icp-pages' - name: Submit Documentation - uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action + uses: dfinity/ci-tools/actions/submit-docs@main with: destination_repo: 'dfinity/icp-js-sdk-docs' token: ${{ steps.generate_token.outputs.token }} diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 91d67e56c..4338d736a 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -63,7 +63,7 @@ jobs: icp_pages_dir: 'icp-pages' - name: Submit Documentation - uses: dfinity/ci-tools/actions/submit-docs@luca/submit-docs-action + uses: dfinity/ci-tools/actions/submit-docs@main with: destination_repo: 'dfinity/icp-js-sdk-docs' token: ${{ steps.generate_token.outputs.token }} From 976c81aee510e0e4d243d7b248424f8457576f9a Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 13 Aug 2025 15:43:01 +0200 Subject: [PATCH 55/72] ci: update actions references --- .github/workflows/tmp-publish-docs.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 4338d736a..e7bb71285 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -56,14 +56,21 @@ jobs: - name: Assemble docs uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action with: - docs_output_dir: 'docs/dist' - docs_version: ${{ steps.ver.outputs.version }} - docs_version_label: ${{ steps.ver.outputs.version }} - latest_version_label: 'latest (${{ steps.ver.outputs.version }})' - icp_pages_dir: 'icp-pages' + assets_dir: 'docs/dist/${{ steps.ver.outputs.version }}' + version: ${{ steps.ver.outputs.version }} + target_dir: 'icp-pages' + version_label: 'Version ${{ steps.ver.outputs.version }}' + + - name: Assemble docs + uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action + with: + assets_dir: 'docs/dist/latest' + version: 'latest' + target_dir: 'icp-pages' + version_label: 'Latest (${{ steps.ver.outputs.version }})' - name: Submit Documentation - uses: dfinity/ci-tools/actions/submit-docs@main + uses: dfinity/ci-tools/actions/submit-docs@luca/assemble-docs-action with: destination_repo: 'dfinity/icp-js-sdk-docs' token: ${{ steps.generate_token.outputs.token }} From 24c9aef97a4f80a82c44c08c9d1a76d8bc2a3a65 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 13 Aug 2025 16:06:16 +0200 Subject: [PATCH 56/72] ci: update steps --- .github/workflows/tmp-publish-docs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index e7bb71285..772c05858 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -25,7 +25,7 @@ jobs: with: node_version_file: '.nvmrc' - - uses: dfinity/ci-tools/actions/extract-version@luca/extract-version-action + - uses: dfinity/ci-tools/actions/extract-version@luca/assemble-docs-action id: extract-version with: file: 'package.json' @@ -74,3 +74,4 @@ jobs: with: destination_repo: 'dfinity/icp-js-sdk-docs' token: ${{ steps.generate_token.outputs.token }} + target_dir: 'icp-pages' From d301638d253efa1571415bd44102a99dd2e0813d Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 13 Aug 2025 16:39:38 +0200 Subject: [PATCH 57/72] ci: point main branch for docs actions --- .github/workflows/publish.yml | 22 +++++++++++++++------- .github/workflows/tmp-publish-docs.yml | 8 ++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 27762b5f2..95d8c6677 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -67,7 +67,7 @@ jobs: with: node_version_file: '.nvmrc' - - uses: dfinity/ci-tools/actions/extract-version@luca/extract-version-action + - uses: dfinity/ci-tools/actions/extract-version@main id: extract-version with: file: 'package.json' @@ -96,16 +96,24 @@ jobs: path: icp-pages - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action + uses: dfinity/ci-tools/actions/assemble-docs@main with: - docs_output_dir: 'docs/dist' - docs_version: ${{ steps.ver.outputs.version }} - docs_version_label: ${{ steps.ver.outputs.version }} - latest_version_label: 'latest (${{ steps.ver.outputs.version }})' - icp_pages_dir: 'icp-pages' + assets_dir: 'docs/dist/${{ steps.ver.outputs.version }}' + version: ${{ steps.ver.outputs.version }} + target_dir: 'icp-pages' + version_label: 'Version ${{ steps.ver.outputs.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.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' diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 772c05858..1c9cb3aee 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -25,7 +25,7 @@ jobs: with: node_version_file: '.nvmrc' - - uses: dfinity/ci-tools/actions/extract-version@luca/assemble-docs-action + - uses: dfinity/ci-tools/actions/extract-version@main id: extract-version with: file: 'package.json' @@ -54,7 +54,7 @@ jobs: path: icp-pages - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action + uses: dfinity/ci-tools/actions/assemble-docs@main with: assets_dir: 'docs/dist/${{ steps.ver.outputs.version }}' version: ${{ steps.ver.outputs.version }} @@ -62,7 +62,7 @@ jobs: version_label: 'Version ${{ steps.ver.outputs.version }}' - name: Assemble docs - uses: dfinity/ci-tools/actions/assemble-docs@luca/assemble-docs-action + uses: dfinity/ci-tools/actions/assemble-docs@main with: assets_dir: 'docs/dist/latest' version: 'latest' @@ -70,7 +70,7 @@ jobs: version_label: 'Latest (${{ steps.ver.outputs.version }})' - name: Submit Documentation - uses: dfinity/ci-tools/actions/submit-docs@luca/assemble-docs-action + uses: dfinity/ci-tools/actions/submit-docs@main with: destination_repo: 'dfinity/icp-js-sdk-docs' token: ${{ steps.generate_token.outputs.token }} From 132a32f60c647f02641e77dd5d8c25ef455053b2 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 13 Aug 2025 18:07:15 +0200 Subject: [PATCH 58/72] chore: remove temporary action --- .github/workflows/tmp-publish-docs.yml | 77 -------------------------- 1 file changed, 77 deletions(-) delete mode 100644 .github/workflows/tmp-publish-docs.yml diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml deleted file mode 100644 index 1c9cb3aee..000000000 --- a/.github/workflows/tmp-publish-docs.yml +++ /dev/null @@ -1,77 +0,0 @@ -# TODO: remove this workflow once the action works -name: Tmp publish docs - -on: - pull_request: - -jobs: - publish-docs: - runs-on: ubuntu-latest - if: ${{ github.head_ref == 'luca/SDK-2264-push-docs' }} - steps: - - name: Create GitHub App Token - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 - id: generate_token - with: - 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@v4 - - - 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 "version=v${{ steps.extract-version.outputs.major }}" >> $GITHUB_OUTPUT - - - name: Build docs for version ${{ steps.ver.outputs.version }} - working-directory: docs - env: - DOCS_VERSION: ${{ steps.ver.outputs.version }} - run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} - - - name: Build docs for version latest - working-directory: docs - env: - DOCS_VERSION: latest - 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.version }}' - version: ${{ steps.ver.outputs.version }} - target_dir: 'icp-pages' - version_label: 'Version ${{ steps.ver.outputs.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.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' From 99d58c3b4bfba9d79485486bb11f21fe2bae8855 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 13 Aug 2025 18:41:05 +0200 Subject: [PATCH 59/72] Revert "chore: remove temporary action" This reverts commit 132a32f60c647f02641e77dd5d8c25ef455053b2. --- .github/workflows/tmp-publish-docs.yml | 77 ++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/tmp-publish-docs.yml diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml new file mode 100644 index 000000000..1c9cb3aee --- /dev/null +++ b/.github/workflows/tmp-publish-docs.yml @@ -0,0 +1,77 @@ +# TODO: remove this workflow once the action works +name: Tmp publish docs + +on: + pull_request: + +jobs: + publish-docs: + runs-on: ubuntu-latest + if: ${{ github.head_ref == 'luca/SDK-2264-push-docs' }} + steps: + - name: Create GitHub App Token + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + id: generate_token + with: + 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@v4 + + - 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 "version=v${{ steps.extract-version.outputs.major }}" >> $GITHUB_OUTPUT + + - name: Build docs for version ${{ steps.ver.outputs.version }} + working-directory: docs + env: + DOCS_VERSION: ${{ steps.ver.outputs.version }} + run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} + + - name: Build docs for version latest + working-directory: docs + env: + DOCS_VERSION: latest + 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.version }}' + version: ${{ steps.ver.outputs.version }} + target_dir: 'icp-pages' + version_label: 'Version ${{ steps.ver.outputs.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.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' From 002194d0186623b4510ebfa44b8edb8408a2a4af Mon Sep 17 00:00:00 2001 From: ilbertt Date: Wed, 13 Aug 2025 19:41:00 +0200 Subject: [PATCH 60/72] fix: use text size from theme --- docs/src/plugins/versions/components/VersionDropdown.astro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/src/plugins/versions/components/VersionDropdown.astro b/docs/src/plugins/versions/components/VersionDropdown.astro index f85fb97d4..5fcbbedb6 100644 --- a/docs/src/plugins/versions/components/VersionDropdown.astro +++ b/docs/src/plugins/versions/components/VersionDropdown.astro @@ -78,8 +78,7 @@ const BASE_URL = import.meta.env.BASE_URL; } .sidebar-version-select-label { display: block; - font-size: 0.875rem; - opacity: 0.9; + font-size: var(--sl-text-sm); cursor: pointer; } From 643fd8a8f53a59863dd21d6b94a4fbda2b3937d2 Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 14 Aug 2025 18:33:46 +0200 Subject: [PATCH 61/72] refactor: update versions labels --- .github/workflows/tmp-publish-docs.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tmp-publish-docs.yml b/.github/workflows/tmp-publish-docs.yml index 1c9cb3aee..49a68d3fd 100644 --- a/.github/workflows/tmp-publish-docs.yml +++ b/.github/workflows/tmp-publish-docs.yml @@ -33,13 +33,14 @@ jobs: - name: Prepare version id: ver run: | - echo "version=v${{ steps.extract-version.outputs.major }}" >> $GITHUB_OUTPUT + echo "major_version=v${{ steps.extract-version.outputs.major }}" >> $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.version }} + - name: Build docs for version ${{ steps.ver.outputs.major_version }} working-directory: docs env: - DOCS_VERSION: ${{ steps.ver.outputs.version }} - run: pnpm build --outDir dist/${{ steps.ver.outputs.version }} + DOCS_VERSION: ${{ steps.ver.outputs.major_version }} + run: pnpm build --outDir dist/${{ steps.ver.outputs.major_version }} - name: Build docs for version latest working-directory: docs @@ -56,10 +57,10 @@ jobs: - name: Assemble docs uses: dfinity/ci-tools/actions/assemble-docs@main with: - assets_dir: 'docs/dist/${{ steps.ver.outputs.version }}' - version: ${{ steps.ver.outputs.version }} + assets_dir: 'docs/dist/${{ steps.ver.outputs.major_version }}' + version: ${{ steps.ver.outputs.major_version }} target_dir: 'icp-pages' - version_label: 'Version ${{ steps.ver.outputs.version }}' + version_label: '${{ steps.ver.outputs.major_version }}.x' - name: Assemble docs uses: dfinity/ci-tools/actions/assemble-docs@main @@ -67,7 +68,7 @@ jobs: assets_dir: 'docs/dist/latest' version: 'latest' target_dir: 'icp-pages' - version_label: 'Latest (${{ steps.ver.outputs.version }})' + version_label: 'Latest (${{ steps.ver.outputs.major_minor_patch_version }})' - name: Submit Documentation uses: dfinity/ci-tools/actions/submit-docs@main From f2761e0dc326d563aeb0d70bd33a0ad524e9153d Mon Sep 17 00:00:00 2001 From: ilbertt Date: Thu, 14 Aug 2025 19:15:05 +0200 Subject: [PATCH 62/72] fix: handle trailing slash --- .../versions/components/VersionDropdown.astro | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/src/plugins/versions/components/VersionDropdown.astro b/docs/src/plugins/versions/components/VersionDropdown.astro index 5fcbbedb6..9a083ab29 100644 --- a/docs/src/plugins/versions/components/VersionDropdown.astro +++ b/docs/src/plugins/versions/components/VersionDropdown.astro @@ -9,6 +9,18 @@ const BASE_URL = import.meta.env.BASE_URL;