-
Notifications
You must be signed in to change notification settings - Fork 134
ci: Include docs and /storybook site (github.io) step in Github release workflow
#2818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
awahab07
wants to merge
8
commits into
elastic:main
Choose a base branch
from
awahab07:Release_gh-pages_in-GH-release-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
70c2497
Include Storybook release with semantic-release.
awahab07 62c4445
Refactor buildkite's `main` based site release and reuse it in Github…
awahab07 800c10c
Correct duplicate workflow step naming.
awahab07 2c8bceb
Include hidden files while uploading release artifacts.
awahab07 1aa608f
Improve copies
awahab07 2ccce0e
Fis escaping
awahab07 60445e4
Improve copies
awahab07 ed65a11
Improve copies
awahab07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import path from 'path'; | ||
|
|
||
| import { assembleSite, buildDocsSite, buildStorybookSite, buildTypeDocs } from '../utils/site'; | ||
|
|
||
| const releaseSiteDir = path.resolve(__dirname, '../../.release-site'); | ||
|
|
||
| /** | ||
| * Builds the release-ready static site consumed by the GitHub release workflow. | ||
| * The assembled output matches the published GitHub Pages layout with docs at | ||
| * the root and Storybook under `/storybook`. | ||
| */ | ||
| console.log('Building release-ready docs'); | ||
| buildTypeDocs(); | ||
| buildDocsSite({ | ||
| docsUrl: 'https://elastic.github.io', | ||
| baseUrl: '/elastic-charts', | ||
| nodeEnv: 'production', | ||
| }); | ||
|
|
||
| console.log('Building release-ready Storybook'); | ||
| buildStorybookSite({ | ||
| nodeEnv: 'production', | ||
| }); | ||
|
|
||
| console.log('Assembling release site'); | ||
| assembleSite({ | ||
| outDir: releaseSiteDir, | ||
| }); | ||
|
|
||
| console.log(`Release site assembled at ${path.relative(path.resolve(__dirname, '../..'), releaseSiteDir)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { spawnSync } from 'child_process'; | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
|
|
||
| const repoRoot = path.resolve(__dirname, '../..'); | ||
| const docsDir = path.join(repoRoot, 'docs'); | ||
| const storybookDir = path.join(repoRoot, 'storybook'); | ||
|
|
||
| export const docsOutDir = path.join(docsDir, 'build'); | ||
| export const storybookOutDir = path.join(repoRoot, '.out'); | ||
|
|
||
| interface CommandOptions { | ||
| cwd?: string; | ||
| env?: NodeJS.ProcessEnv; | ||
| } | ||
|
|
||
| interface DocsBuildOptions { | ||
| docsUrl: string; | ||
| nodeEnv: 'production' | 'development'; | ||
| baseUrl?: string; | ||
| } | ||
|
|
||
| interface StorybookBuildOptions { | ||
| nodeEnv: 'production' | 'development'; | ||
| } | ||
|
|
||
| interface AssembleSiteOptions { | ||
| outDir: string; | ||
| docsSourceDir?: string; | ||
| storybookSourceDir?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Generates the TypeDoc content consumed by the Docusaurus docs build. | ||
| */ | ||
| export function buildTypeDocs() { | ||
| run('yarn', ['typedoc']); | ||
| } | ||
|
|
||
| /** | ||
| * Builds the Docusaurus site for a specific public base URL. | ||
| */ | ||
| export function buildDocsSite({ docsUrl, nodeEnv, baseUrl }: DocsBuildOptions) { | ||
| run('yarn', ['build'], { | ||
| cwd: docsDir, | ||
| env: { | ||
| DOCUSAURUS_URL: docsUrl, | ||
| ...(baseUrl ? { DOCUSAURUS_BASE_URL: baseUrl } : {}), | ||
| NODE_ENV: nodeEnv, | ||
| NODE_OPTIONS: toNodeOptions(), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Builds the static Storybook bundle used by preview and release publishing flows. | ||
| */ | ||
| export function buildStorybookSite({ nodeEnv }: StorybookBuildOptions) { | ||
| run('yarn', ['build'], { | ||
| cwd: storybookDir, | ||
| env: { | ||
| NODE_ENV: nodeEnv, | ||
| NODE_OPTIONS: toNodeOptions(), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Assembles the final static site tree with docs at the root and Storybook under `/storybook`. | ||
| */ | ||
| export function assembleSite({ | ||
| outDir, | ||
| docsSourceDir = docsOutDir, | ||
| storybookSourceDir = storybookOutDir, | ||
| }: AssembleSiteOptions) { | ||
| fs.rmSync(outDir, { force: true, recursive: true }); | ||
| fs.cpSync(docsSourceDir, outDir, { recursive: true }); | ||
| fs.cpSync(storybookSourceDir, path.join(outDir, 'storybook'), { recursive: true }); | ||
| fs.writeFileSync(path.join(outDir, '.nojekyll'), ''); | ||
|
|
||
| ensureFileExists(path.join(outDir, 'index.html')); | ||
| ensureFileExists(path.join(outDir, 'storybook', 'index.html')); | ||
| } | ||
|
|
||
| function ensureFileExists(filePath: string) { | ||
| if (!fs.existsSync(filePath)) { | ||
| throw new Error(`Expected build output at ${path.relative(repoRoot, filePath)}`); | ||
| } | ||
| } | ||
|
|
||
| function run(command: string, args: string[], { cwd = repoRoot, env = {} }: CommandOptions = {}) { | ||
| const result = spawnSync(command, args, { | ||
| cwd, | ||
| env: { ...process.env, ...env }, | ||
| shell: process.platform === 'win32', | ||
| stdio: 'inherit', | ||
| }); | ||
|
|
||
| if (result.status !== 0) { | ||
| throw new Error(`Command failed: ${command} ${args.join(' ')}`); | ||
| } | ||
| } | ||
|
|
||
| function toNodeOptions() { | ||
| return [process.env.NODE_OPTIONS, '--openssl-legacy-provider'].filter(Boolean).join(' '); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the best approach. What about for changes to the docs alone where there is no fix or feature, that requires to run a release?
I can see pros and cons to both but I think having this on
mainthat represents the current code is best.@markov00 WDYT?