Browse Source

ci: add doc release runner (#6240)

* ci: add doc release runner

* refactor: use release docs script and use commit with pkg version

* releaseDocs

* /docs/**

* ../docs

* release-docs-v

* refactor: remove versionCmd and commit match

* refactor: remove tag for release docs
pull/6244/head
Daniel Starns 1 year ago
committed by GitHub
parent
commit
71bb47ea69
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 48
      .github/workflows/publish-docs.yml
  2. 28
      docs/deploy.sh
  3. 3
      docs/package.json
  4. 1
      package.json
  5. 32
      scripts/releaseDocs.ts

48
.github/workflows/publish-docs.yml

@ -0,0 +1,48 @@
name: Publish GrapesJS Docs
on:
push:
branches: [dev]
paths:
- '/docs/**'
jobs:
publish-docs:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Release GrapesJS docs:')"
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-project
- name: Setup Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Build and Deploy Docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./docs
run: |
# abort on errors
set -e
# navigate into the build output directory
cd .vuepress/dist
# Need to deploy all the documentation inside docs folder
mkdir docs-new
# move all the files from the current directory in docs
mv `ls -1 ./ | grep -v docs-new` ./docs-new
# fetch the current site, remove the old docs dir and make current the new one
git clone -b main https://github.com/GrapesJS/website.git tmp && mv tmp/* tmp/.* . && rm -rf tmp
rm -fR public/docs
mv ./docs-new ./public/docs
# stage all and commit
git add -A
git commit -m 'deploy docs'
git push https://x-access-token:${GITHUB_TOKEN}@github.com/GrapesJS/website.git main
cd -

28
docs/deploy.sh

@ -1,28 +0,0 @@
#!/usr/bin/env sh
# abort on errors
set -e
# build
# npm run docs:build
# navigate into the build output directory
cd docs/.vuepress/dist
# Need to deploy all the documentation inside docs folder
mkdir docs-new
# move all the files from the current directory in docs
mv `\ls -1 ./ | grep -v docs-new` ./docs-new
# fetch the current site, remove the old docs dir and make current the new one
git clone -b main https://github.com/GrapesJS/website.git tmp && mv tmp/* tmp/.* . && rm -rf tmp
rm -fR public/docs
mv ./docs-new ./public/docs
# stage all and commit
git add -A
git commit -m 'deploy docs'
git push https://artf@github.com/GrapesJS/website.git main
cd -

3
docs/package.json

@ -34,7 +34,6 @@
"scripts": {
"docs": "vuepress dev .",
"docs:api": "node ./api.mjs",
"build": "npm run docs:api && vuepress build .",
"docs:deploy": "./deploy.sh"
"build": "npm run docs:api && vuepress build ."
}
}

1
package.json

@ -21,6 +21,7 @@
"publish:core:rc": "cd packages/core && npm publish --tag rc --access public",
"publish:core:latest": "cd packages/core && npm publish --access public",
"build:core": "pnpm --filter grapesjs build",
"release:docs": "ts-node scripts/releaseDocs latest",
"build:cli": "pnpm --filter grapesjs-cli build",
"build:docs:api": "pnpm --filter @grapesjs/docs docs:api",
"build:docs": "pnpm --filter @grapesjs/docs build"

32
scripts/releaseDocs.ts

@ -0,0 +1,32 @@
import fs from 'fs';
import { resolve } from 'path';
import { runCommand } from './common';
const pathLib = resolve(__dirname, '../docs');
async function prepareCoreRelease() {
try {
// Check if the current branch is clean (no staged changes)
runCommand(
'git diff-index --quiet HEAD --',
'You have uncommitted changes. Please commit or stash them before running the release script.',
);
// Increment the docs version
runCommand(`pnpm --filter @grapesjs/docs exec npm version patch --no-git-tag-version --no-commit-hooks`);
// Create a new release branch
const newVersion = JSON.parse(fs.readFileSync(`${pathLib}/package.json`, 'utf8')).version;
const newBranch = `release-docs-v${newVersion}`;
runCommand(`git checkout -b ${newBranch}`);
runCommand('git add .');
runCommand(`git commit -m "Release GrapesJS docs: v${newVersion}"`);
console.log(`Release prepared! Push the current "${newBranch}" branch and open a new PR targeting 'dev'`);
} catch (error) {
console.error(error);
process.exit(1);
}
}
prepareCoreRelease();
Loading…
Cancel
Save