Skip to content

Commit 71bb47e

Browse files
authored
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
1 parent 45da189 commit 71bb47e

File tree

5 files changed

+82
-30
lines changed

5 files changed

+82
-30
lines changed

.github/workflows/publish-docs.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish GrapesJS Docs
2+
3+
on:
4+
push:
5+
branches: [dev]
6+
paths:
7+
- '/docs/**'
8+
9+
jobs:
10+
publish-docs:
11+
runs-on: ubuntu-latest
12+
if: "contains(github.event.head_commit.message, 'Release GrapesJS docs:')"
13+
permissions:
14+
contents: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: ./.github/actions/setup-project
18+
- name: Setup Git
19+
run: |
20+
git config --global user.name 'github-actions[bot]'
21+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
22+
- name: Build and Deploy Docs
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
working-directory: ./docs
26+
run: |
27+
# abort on errors
28+
set -e
29+
# navigate into the build output directory
30+
cd .vuepress/dist
31+
32+
# Need to deploy all the documentation inside docs folder
33+
mkdir docs-new
34+
35+
# move all the files from the current directory in docs
36+
mv `ls -1 ./ | grep -v docs-new` ./docs-new
37+
38+
# fetch the current site, remove the old docs dir and make current the new one
39+
git clone -b main https://github.com/GrapesJS/website.git tmp && mv tmp/* tmp/.* . && rm -rf tmp
40+
rm -fR public/docs
41+
mv ./docs-new ./public/docs
42+
43+
# stage all and commit
44+
git add -A
45+
git commit -m 'deploy docs'
46+
git push https://x-access-token:${GITHUB_TOKEN}@github.com/GrapesJS/website.git main
47+
48+
cd -

docs/deploy.sh

-28
This file was deleted.

docs/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"scripts": {
3535
"docs": "vuepress dev .",
3636
"docs:api": "node ./api.mjs",
37-
"build": "npm run docs:api && vuepress build .",
38-
"docs:deploy": "./deploy.sh"
37+
"build": "npm run docs:api && vuepress build ."
3938
}
4039
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"publish:core:rc": "cd packages/core && npm publish --tag rc --access public",
2222
"publish:core:latest": "cd packages/core && npm publish --access public",
2323
"build:core": "pnpm --filter grapesjs build",
24+
"release:docs": "ts-node scripts/releaseDocs latest",
2425
"build:cli": "pnpm --filter grapesjs-cli build",
2526
"build:docs:api": "pnpm --filter @grapesjs/docs docs:api",
2627
"build:docs": "pnpm --filter @grapesjs/docs build"

scripts/releaseDocs.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import fs from 'fs';
2+
import { resolve } from 'path';
3+
import { runCommand } from './common';
4+
5+
const pathLib = resolve(__dirname, '../docs');
6+
7+
async function prepareCoreRelease() {
8+
try {
9+
// Check if the current branch is clean (no staged changes)
10+
runCommand(
11+
'git diff-index --quiet HEAD --',
12+
'You have uncommitted changes. Please commit or stash them before running the release script.',
13+
);
14+
15+
// Increment the docs version
16+
runCommand(`pnpm --filter @grapesjs/docs exec npm version patch --no-git-tag-version --no-commit-hooks`);
17+
18+
// Create a new release branch
19+
const newVersion = JSON.parse(fs.readFileSync(`${pathLib}/package.json`, 'utf8')).version;
20+
const newBranch = `release-docs-v${newVersion}`;
21+
runCommand(`git checkout -b ${newBranch}`);
22+
runCommand('git add .');
23+
runCommand(`git commit -m "Release GrapesJS docs: v${newVersion}"`);
24+
25+
console.log(`Release prepared! Push the current "${newBranch}" branch and open a new PR targeting 'dev'`);
26+
} catch (error) {
27+
console.error(error);
28+
process.exit(1);
29+
}
30+
}
31+
32+
prepareCoreRelease();

0 commit comments

Comments
 (0)