From 7ccd187cc3ba7f852f1b48aff684f2bf178f028d Mon Sep 17 00:00:00 2001 From: zoobestik Date: Mon, 27 Jun 2022 16:34:18 +0300 Subject: [PATCH] Add new release manual for website --- RELEASE.md | 3 ++- redirects.mjs | 42 +++++++++++++++++++++++++++++++++ site/deploy.sh | 64 -------------------------------------------------- 3 files changed, 44 insertions(+), 65 deletions(-) create mode 100644 redirects.mjs delete mode 100755 site/deploy.sh diff --git a/RELEASE.md b/RELEASE.md index e297abd3c4..5e3144de99 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -63,7 +63,8 @@ To release a new `` of `kotlinx-coroutines`: * Cut & paste lines from [`CHANGES.md`](CHANGES.md) into description. 4. Build and publish the documentation for the web-site:
- `site/deploy.sh push` + * Set new value for [`kotlinx.coroutines.release.tag`](https://buildserver.labs.intellij.net/admin/editProject.html?projectId=Kotlin_KotlinSites_Builds_KotlinlangOrg_LibrariesAPIs&tab=projectParams) + * And run deploy [configuration](https://buildserver.labs.intellij.net/buildConfiguration/Kotlin_KotlinSites_Builds_KotlinlangOrg_KotlinCoroutinesApi?branch=%3Cdefault%3E&buildTypeTab=overview&mode=builds) 5. Announce the new release in [Slack](https://kotlinlang.slack.com) diff --git a/redirects.mjs b/redirects.mjs new file mode 100644 index 0000000000..7115e9bb30 --- /dev/null +++ b/redirects.mjs @@ -0,0 +1,42 @@ +import { cwd } from 'process'; +import { extname, resolve } from 'path'; +import { promises as fsPromises } from 'fs'; + +const { readdir, writeFile, unlink } = fsPromises + +async function* getFiles(dir) { + const dirents = await readdir(dir, { withFileTypes: true }); + + for (const dirent of dirents) { + const { name } = dirent; + const fullPath = resolve(dir, name); + + if (dirent.isDirectory()) { + yield* getFiles(fullPath); + } else { + yield { name, fullPath }; + } + } +} + +(async function main() { + const cwdpath = cwd(); + const library = 'kotlinx.coroutines'; + + for await (const { name, fullPath } of getFiles(cwdpath)) { + if (name === 'navigation.html') await unlink(fullPath); + else { + const ext = extname(name); + + if (ext === '.html') { + let relativeUrl = fullPath.substring(cwdpath.length + 1); + + if (name === 'index.html') + relativeUrl = relativeUrl.substring(0, relativeUrl.length - 'index.html'.length); + + const url = new URL(`/api/${library}/${relativeUrl}`, 'https://kotlinlang.org'); + await writeFile(fullPath, ``); + } + } + } +})(); diff --git a/site/deploy.sh b/site/deploy.sh deleted file mode 100755 index a04e49258d..0000000000 --- a/site/deploy.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. -# - -# Abort on first error -set -e - -# Directories -SITE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -ROOT_DIR="$SITE_DIR/.." -BUILD_DIR="$ROOT_DIR/build" -DIST_DIR="$BUILD_DIR/dokka/htmlMultiModule" -PAGES_DIR="$BUILD_DIR/pages" - -# Init options -GRADLE_OPT= -PUSH_OPT= - -# Set dry run if needed -if [ "$2" == "push" ] ; then - echo "--- Doing LIVE site deployment, so do clean build" - GRADLE_OPT=clean -else - echo "--- Doing dry-run. To commit do 'deploy.sh push'" - PUSH_OPT=--dry-run -fi - -# Makes sure that site is built -"$ROOT_DIR/gradlew" $GRADLE_OPT dokkaHtmlMultiModule - -# Cleanup dist directory (and ignore errors) -rm -rf "$PAGES_DIR" || true - -# Prune worktrees to avoid errors from previous attempts -git --work-tree "$ROOT_DIR" worktree prune - -# Create git worktree for gh-pages branch -git --work-tree "$ROOT_DIR" worktree add -B gh-pages "$PAGES_DIR" origin/gh-pages - -# Now work in newly created workspace -cd "$PAGES_DIR" - -# Fixup all the old documentation files -# Remove non-.html files -git rm `find . -type f -not -name '*.html' -not -name '.git'` > /dev/null - -# Remove all the old documentation -git rm -r * > /dev/null - -# Copy new documentation from dist -cp -r "$DIST_DIR"/* "$PAGES_DIR" - -# Add it all to git -git add * - -# Commit docs for the new version -if [ -z "$1" ] ; then - echo "No argument with version supplied -- skipping commit" -else - git commit -m "Version $1 docs" - git push $PUSH_OPT origin gh-pages:gh-pages -fi