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

ci: add doc release runner #6240

Merged
merged 8 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish GrapesJS Docs

on:
push:
branches: [dev]
paths:
- 'packages/docs/**'
danstarns marked this conversation as resolved.
Show resolved Hide resolved

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 }}
artf marked this conversation as resolved.
Show resolved Hide resolved
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 changes: 0 additions & 28 deletions docs/deploy.sh

This file was deleted.

3 changes: 1 addition & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/releaseCore latest",
danstarns marked this conversation as resolved.
Show resolved Hide resolved
"build:cli": "pnpm --filter grapesjs-cli build",
"build:docs:api": "pnpm --filter @grapesjs/docs docs:api",
"build:docs": "pnpm --filter @grapesjs/docs build"
Expand Down
36 changes: 36 additions & 0 deletions scripts/releaseDocs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fs from 'fs';
import { resolve } from 'path';
import { runCommand } from './common';

const pathLib = resolve(__dirname, '../packages/core');
danstarns marked this conversation as resolved.
Show resolved Hide resolved

async function prepareCoreRelease() {
try {
const releaseTag = process.argv[2];
console.log('Prepare release docs tag:', releaseTag);

// 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 Core version
const versionCmd = releaseTag === 'latest' ? 'patch' : `prerelease --preid ${releaseTag}`;
runCommand(`pnpm --filter @grapesjs/docs exec npm version ${versionCmd} --no-git-tag-version --no-commit-hooks`);
danstarns marked this conversation as resolved.
Show resolved Hide resolved

// Create a new release branch
const newVersion = JSON.parse(fs.readFileSync(`${pathLib}/package.json`, 'utf8')).version;
const newBranch = `release-v${newVersion}`;
danstarns marked this conversation as resolved.
Show resolved Hide resolved
runCommand(`git checkout -b ${newBranch}`);
runCommand('git add .');
runCommand(`git commit -m "Release GrapesJS docs ${releaseTag}: v${newVersion}"`);
danstarns marked this conversation as resolved.
Show resolved Hide resolved

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();