diff --git a/.github/workflows/release-preview-publish.yml b/.github/workflows/release-preview-publish.yml index 8087744888d..8168c9988d3 100644 --- a/.github/workflows/release-preview-publish.yml +++ b/.github/workflows/release-preview-publish.yml @@ -5,6 +5,10 @@ on: branches: - 'release/**' +permissions: + contents: read + packages: write + jobs: publish-preview: runs-on: ubuntu-latest @@ -23,6 +27,8 @@ jobs: - name: Install Packages run: | + # Use hoisted mode to avoid `bundleDependencies` issues + echo 'nodeLinker: "hoisted"' >> pnpm-workspace.yaml pnpm install --frozen-lockfile env: CYPRESS_CACHE_FOLDER: .cache/Cypress @@ -41,6 +47,11 @@ jobs: npm set registry https://npm.pkg.github.com/mermaid-js json -I -f package.json -e 'this.name="@mermaid-js/mermaid"' # Package name needs to be set to a scoped one because GitHub registry requires this json -I -f package.json -e 'this.repository="git://github.com/mermaid-js/mermaid"' # Repo url needs to have a specific format too - npm publish + # We don't publish a separate `@mermaid-js/parser` so bundle it instead + json -I -f package.json -e 'this.bundleDependencies??=[]' -e 'this.bundleDependencies.push("@mermaid-js/parser")' + pnpm pack + npm publish --tag preview *.tgz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Prevent `npm publish` from failing if the docs verification fails. + ONLY_WARN_ON_VERIFY_ERROR: 'true' diff --git a/packages/mermaid/scripts/update-release-version.mts b/packages/mermaid/scripts/update-release-version.mts index 0459d344436..09a86819954 100644 --- a/packages/mermaid/scripts/update-release-version.mts +++ b/packages/mermaid/scripts/update-release-version.mts @@ -17,6 +17,10 @@ import { const verifyOnly: boolean = process.argv.includes('--verify'); const versionPlaceholder = ''; +/** + * This is so we can run `npm publish` for previews, without blocking the release. + */ +const onlyWarnOnVerifyError = process.env.ONLY_WARN_ON_VERIFY_ERROR === 'true'; const verifyDocumentation = async () => { const fileContent = await readFile('./src/docs/community/contributing.md', 'utf-8'); @@ -51,7 +55,7 @@ const main = async () => { console.log( `${mdFilesWithPlaceholder.length} file(s) were found with the placeholder ${versionPlaceholder}. Run \`pnpm --filter mermaid docs:release-version\` to update them.` ); - process.exit(1); + process.exit(onlyWarnOnVerifyError ? 0 : 1); } for (const mdFile of mdFilesWithPlaceholder) {