Skip to content
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

docs: deploy prerelease docs under the /docs/next/ path #16541

Merged
merged 9 commits into from Jan 11, 2023
13 changes: 11 additions & 2 deletions Makefile.js
Expand Up @@ -344,9 +344,18 @@ function generatePrerelease(prereleaseId) {
*/
function publishRelease() {
ReleaseOps.publishRelease();
const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));
const isPreRelease = /[a-z]/u.test(releaseInfo.version);
snitin315 marked this conversation as resolved.
Show resolved Hide resolved

// push to latest branch to trigger docs deploy
exec("git push origin HEAD:latest -f");
/*
* for a pre-release, push to the "next" branch to trigger docs deploy
* for a release, push to the "latest" branch to trigger docs deploy
*/
if (isPreRelease) {
exec("git push origin HEAD:next -f");
} else {
exec("git push origin HEAD:latest -f");
}

publishSite();
}
Expand Down
8 changes: 6 additions & 2 deletions docs/.eleventy.js
Expand Up @@ -25,8 +25,9 @@ module.exports = function(eleventyConfig) {
* it's easier to see if URLs are broken.
*
* When a release is published, HEAD is pushed to the "latest" branch.
* Netlify deploys that branch as well, and in that case, we want the
* docs to be loaded from /docs/latest on eslint.org.
* When a pre-release is published, HEAD is pushed to the "next" branch.
* Netlify deploys those branches as well, and in that case, we want the
* docs to be loaded from /docs/latest or /docs/next on eslint.org.
*
* The path prefix is turned off for deploy previews so we can properly
* see changes before deployed.
Expand All @@ -38,6 +39,8 @@ module.exports = function(eleventyConfig) {
pathPrefix = "/";
} else if (process.env.BRANCH === "latest") {
pathPrefix = "/docs/latest/";
} else if (process.env.BRANCH === "next") {
pathPrefix = "/docs/next/";
}

//------------------------------------------------------------------------------
Expand All @@ -49,6 +52,7 @@ module.exports = function(eleventyConfig) {

eleventyConfig.addGlobalData("site_name", siteName);
eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH);
eleventyConfig.addGlobalData("HEAD", process.env.BRANCH !== "latest" && process.env.BRANCH !== "next");
snitin315 marked this conversation as resolved.
Show resolved Hide resolved
eleventyConfig.addGlobalData("NOINDEX", process.env.BRANCH !== "latest");
eleventyConfig.addDataExtension("yml", contents => yaml.load(contents));

Expand Down
5 changes: 3 additions & 2 deletions docs/src/_includes/components/nav-version-switcher.html
Expand Up @@ -12,8 +12,9 @@
<span class="label__text">Version</span>
</label>
<select name="version selector" id="nav-version-select" aria-describedby="nav-version-infobox" class="c-custom-select switcher__select auto-switcher">
<option value="HEAD" data-url="/docs/head/" {% if GIT_BRANCH !="latest" %}selected{% endif %}>HEAD</option>
<option value="{{ eslintVersion }}" data-url="/docs/latest/" {% if GIT_BRANCH=="latest" %}selected{% endif %}>v{{ eslintVersion }}</option>
<option value="HEAD" data-url="/docs/head/" {% if HEAD %}selected{% endif %}>HEAD</option>
<option value="NEXT" data-url="/docs/next/" {% if GIT_BRANCH == "next" %}selected{% endif %}>NEXT</option>
<option value="{{ eslintVersion }}" data-url="/docs/latest/" {% if GIT_BRANCH == "latest" %}selected{% endif %}>v{{ eslintVersion }}</option>
{% for version in versions.items %}
<option value="{{ version.number }}"
data-url="{{ version.url }}">
Expand Down
3 changes: 2 additions & 1 deletion docs/src/_includes/components/version-switcher.html
Expand Up @@ -12,7 +12,8 @@
<span class="label__text">Version</span>
</label>
<select name="version selector" id="version-select" aria-describedby="version-infobox" class="c-custom-select switcher__select auto-switcher">
<option value="HEAD" data-url="/docs/head/" {% if GIT_BRANCH != "latest" %}selected{% endif %}>HEAD</option>
<option value="HEAD" data-url="/docs/head/" {% if HEAD %}selected{% endif %}>HEAD</option>
<option value="NEXT" data-url="/docs/next/" {% if GIT_BRANCH=="next" %}selected{% endif %}>NEXT</option>
<option value="{{ eslintVersion }}" data-url="/docs/latest/" {% if GIT_BRANCH == "latest" %}selected{% endif %}>v{{ eslintVersion }}</option>
{% for version in versions.items %}
<option value="{{ version.number }}"
Expand Down
3 changes: 2 additions & 1 deletion docs/src/_includes/partials/versions-list.html
@@ -1,5 +1,6 @@
<ul class="versions-list">
<li><a href="/docs/head/" {% if GIT_BRANCH != "latest" %} data-current="true" {% endif %}>HEAD</a></li>
<li><a href="/docs/head/" {% if HEAD %} data-current="true" {% endif %}>HEAD</a></li>
<li><a href="/docs/next/" {% if GIT_BRANCH == "next" %} data-current="true" {% endif %}>NEXT</a></li>
<li><a href="/docs/latest/" {% if GIT_BRANCH == "latest" %} data-current="true" {% endif %}>v{{ eslintVersion }}</a></li>
{%- for version in versions.items -%}
<li><a href="{{ version.url }}">v{{ version.number }}</a></li>
Expand Down