From 05c483dd5942ebf0cfeab245bb86314bb2e37b49 Mon Sep 17 00:00:00 2001 From: Schero94 <64200582+Schero94@users.noreply.github.com> Date: Fri, 20 Nov 2026 00:31:24 +0100 Subject: [PATCH] ci: stamp the package version into the Pages site at deploy The docs site source names no version. pages.yml now replaces the token __PACKAGE_VERSION__ in docs/site (JSON-LD softwareVersion and llms.txt) with the version from package.json and fails if a token is left. semantic-release commits the new version with the workflow token, which starts no push workflow, so Pages also redeploys on workflow_run after a successful "Publish Package" run that a push to main triggered. The job checks out the default branch (no pull request code), keeps contents: read plus pages: write and id-token: write, and actions stay as they were. Checked with actionlint 1.7.12. Docs read 2026-11-20: GitHub "Events that trigger workflows" (workflow_run runs the default-branch workflow with GITHUB_SHA at the last default-branch commit; branches filter; check github.event.workflow_run.conclusion). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pages.yml | 18 ++++++++++++++++++ docs/site/index.html | 1 + docs/site/llms.txt | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 40a57e8..70da591 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -4,6 +4,13 @@ on: push: branches: - main + # semantic-release commits the new version to package.json with the workflow + # token, which starts no push workflow. Redeploy after every successful Release + # run on main so the stamped version below is the published one. + workflow_run: + workflows: ['Publish Package'] + types: [completed] + branches: [main] workflow_dispatch: permissions: @@ -17,6 +24,10 @@ concurrency: jobs: deploy: + # Deploy after a successful Release run triggered by a push to main only. + if: >- + github.event_name != 'workflow_run' || + (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -24,6 +35,13 @@ jobs: steps: - name: Checkout uses: actions/checkout@v7 + - name: Stamp the package version + # The site source never hardcodes the version: JSON-LD and llms.txt carry + # __PACKAGE_VERSION__, replaced here with the version from package.json. + run: | + version="$(node -p "require('./package.json').version")" + grep -rl --include='*.html' --include='*.txt' '__PACKAGE_VERSION__' docs/site | xargs -r sed -i "s/__PACKAGE_VERSION__/${version}/g" + if grep -rq '__PACKAGE_VERSION__' docs/site; then echo 'Unreplaced version token in docs/site' >&2; exit 1; fi - name: Configure Pages uses: actions/configure-pages@v6 - name: Upload site artifact diff --git a/docs/site/index.html b/docs/site/index.html index b5bfddb..ed4dc12 100644 --- a/docs/site/index.html +++ b/docs/site/index.html @@ -66,6 +66,7 @@ "name": "Magic Session Manager", "alternateName": "strapi-plugin-magic-sessionmanager", "description": "Free Strapi 5 plugin that records every Users & Permissions sign-in as a session, lets admins end sessions and block users, and adds logout routes, failed-login lockout and optional country rules.", + "softwareVersion": "__PACKAGE_VERSION__", "applicationCategory": "DeveloperApplication", "applicationSubCategory": "Strapi plugin", "operatingSystem": "Node.js 22+ / Strapi 5", diff --git a/docs/site/llms.txt b/docs/site/llms.txt index 9f28df1..7c42366 100644 --- a/docs/site/llms.txt +++ b/docs/site/llms.txt @@ -2,7 +2,7 @@ > Magic Session Manager (npm: strapi-plugin-magic-sessionmanager, plugin id: magic-sessionmanager) is a free, MIT-licensed Strapi 5 plugin that records every Users & Permissions sign-in as a session. Admins see who is online, end single sessions or all sessions of a user, and block accounts; the app gets logout routes, a "my devices" list, failed-login lockout and optional country rules. -The current version is on npm (link below). The plugin sends no telemetry and needs no account or license key. +Current version: __PACKAGE_VERSION__ (npm). The plugin sends no telemetry and needs no account or license key. What it does: