Daniel Starns
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with
160 additions and
1 deletions
-
.github/workflows/publish-cli.yml
-
.github/workflows/publish-core-latest.yml
-
.github/workflows/publish-core-rc.yml
-
package.json
-
scripts/common.ts
-
scripts/releaseCli.ts
-
scripts/releaseCore.ts
|
|
@ -0,0 +1,17 @@ |
|
|
|
|
|
name: Publish GrapesJS CLI |
|
|
|
|
|
on: |
|
|
|
|
|
push: |
|
|
|
|
|
branches: [dev] |
|
|
|
|
|
paths: |
|
|
|
|
|
- 'packages/cli/**' |
|
|
|
|
|
|
|
|
|
|
|
jobs: |
|
|
|
|
|
publish: |
|
|
|
|
|
if: "contains(github.event.head_commit.message, 'Release GrapesJS cli:')" |
|
|
|
|
|
runs-on: ubuntu-latest |
|
|
|
|
|
steps: |
|
|
|
|
|
- uses: actions/checkout@v4 |
|
|
|
|
|
- uses: ./.github/actions/setup-project |
|
|
|
|
|
- name: Publish Core |
|
|
|
|
|
run: pnpm publish --access public |
|
|
|
|
|
working-directory: ./packages/cli |
|
|
@ -0,0 +1,26 @@ |
|
|
|
|
|
name: Publish GrapesJS Core |
|
|
|
|
|
on: |
|
|
|
|
|
push: |
|
|
|
|
|
branches: [dev] |
|
|
|
|
|
paths: |
|
|
|
|
|
- 'packages/core/**' |
|
|
|
|
|
|
|
|
|
|
|
jobs: |
|
|
|
|
|
publish: |
|
|
|
|
|
if: "contains(github.event.head_commit.message, 'Release GrapesJS core latest:')" |
|
|
|
|
|
runs-on: ubuntu-latest |
|
|
|
|
|
steps: |
|
|
|
|
|
- uses: actions/checkout@v4 |
|
|
|
|
|
- uses: ./.github/actions/setup-project |
|
|
|
|
|
- name: Build cli |
|
|
|
|
|
run: pnpm run build:cli |
|
|
|
|
|
- name: Build core |
|
|
|
|
|
run: pnpm run build:core |
|
|
|
|
|
- name: Check core TS |
|
|
|
|
|
run: pnpm run ts:check |
|
|
|
|
|
- name: Publish to npm |
|
|
|
|
|
env: |
|
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
|
|
|
|
|
run: | |
|
|
|
|
|
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ./packages/core/.npmrc |
|
|
|
|
|
yarn publish:core:latest |
|
|
@ -0,0 +1,26 @@ |
|
|
|
|
|
name: Publish GrapesJS Core |
|
|
|
|
|
on: |
|
|
|
|
|
push: |
|
|
|
|
|
branches: [dev] |
|
|
|
|
|
paths: |
|
|
|
|
|
- 'packages/core/**' |
|
|
|
|
|
|
|
|
|
|
|
jobs: |
|
|
|
|
|
publish: |
|
|
|
|
|
if: "contains(github.event.head_commit.message, 'Release GrapesJS core rc:')" |
|
|
|
|
|
runs-on: ubuntu-latest |
|
|
|
|
|
steps: |
|
|
|
|
|
- uses: actions/checkout@v4 |
|
|
|
|
|
- uses: ./.github/actions/setup-project |
|
|
|
|
|
- name: Build cli |
|
|
|
|
|
run: pnpm run build:cli |
|
|
|
|
|
- name: Build core |
|
|
|
|
|
run: pnpm run build:core |
|
|
|
|
|
- name: Check core TS |
|
|
|
|
|
run: pnpm run ts:check |
|
|
|
|
|
- name: Publish to npm |
|
|
|
|
|
env: |
|
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
|
|
|
|
|
run: | |
|
|
|
|
|
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ./packages/core/.npmrc |
|
|
|
|
|
yarn publish:core:rc |
|
|
@ -12,7 +12,15 @@ |
|
|
"ts:check": "pnpm --filter grapesjs ts:check", |
|
|
"ts:check": "pnpm --filter grapesjs ts:check", |
|
|
"clean": "find . -type d \\( -name \"node_modules\" -o -name \"build\" -o -name \"dist\" \\) -exec rm -rf {} + && rm ./pnpm-lock.yaml", |
|
|
"clean": "find . -type d \\( -name \"node_modules\" -o -name \"build\" -o -name \"dist\" \\) -exec rm -rf {} + && rm ./pnpm-lock.yaml", |
|
|
"format": "prettier . --write --ignore-path .prettierignore", |
|
|
"format": "prettier . --write --ignore-path .prettierignore", |
|
|
"format:check": "prettier . --check --ignore-path .prettierignore" |
|
|
"format:check": "prettier . --check --ignore-path .prettierignore", |
|
|
|
|
|
"release:core:rc": "ts-node scripts/releaseCore rc", |
|
|
|
|
|
"release:core:latest": "ts-node scripts/releaseCore latest", |
|
|
|
|
|
"release:cli:rc": "ts-node scripts/releaseCli rc", |
|
|
|
|
|
"release:cli:latest": "ts-node scripts/releaseCli latest", |
|
|
|
|
|
"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", |
|
|
|
|
|
"build:cli": "pnpm --filter grapesjs-cli build" |
|
|
}, |
|
|
}, |
|
|
"devDependencies": { |
|
|
"devDependencies": { |
|
|
"@babel/cli": "7.24.8", |
|
|
"@babel/cli": "7.24.8", |
|
|
|
|
|
@ -0,0 +1,10 @@ |
|
|
|
|
|
import { execSync } from 'child_process'; |
|
|
|
|
|
|
|
|
|
|
|
export function runCommand(command: string, error?: string) { |
|
|
|
|
|
try { |
|
|
|
|
|
return (execSync(command, { stdio: 'inherit' }) || '').toString().trim(); |
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
console.error(error || `Error while running command: ${command}`); |
|
|
|
|
|
throw err; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
@ -0,0 +1,36 @@ |
|
|
|
|
|
import fs from 'fs'; |
|
|
|
|
|
import { resolve } from 'path'; |
|
|
|
|
|
import { runCommand } from './common'; |
|
|
|
|
|
|
|
|
|
|
|
const pathLib = resolve(__dirname, '../packages/cli'); |
|
|
|
|
|
|
|
|
|
|
|
async function prepareCoreRelease() { |
|
|
|
|
|
try { |
|
|
|
|
|
const releaseTag = process.argv[2] || 'rc'; |
|
|
|
|
|
console.log('Prepare release cli 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 CLI version
|
|
|
|
|
|
const versionCmd = releaseTag === 'latest' ? 'patch' : `prerelease --preid ${releaseTag}`; |
|
|
|
|
|
runCommand(`pnpm --filter grapesjs-cli exec npm version ${versionCmd} --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-v${newVersion}`; |
|
|
|
|
|
runCommand(`git checkout -b ${newBranch}`); |
|
|
|
|
|
runCommand('git add .'); |
|
|
|
|
|
runCommand(`git commit -m "Release GrapesJS cli ${releaseTag}: 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(); |
|
|
@ -0,0 +1,36 @@ |
|
|
|
|
|
import fs from 'fs'; |
|
|
|
|
|
import { resolve } from 'path'; |
|
|
|
|
|
import { runCommand } from './common'; |
|
|
|
|
|
|
|
|
|
|
|
const pathLib = resolve(__dirname, '../packages/core'); |
|
|
|
|
|
|
|
|
|
|
|
async function prepareCoreRelease() { |
|
|
|
|
|
try { |
|
|
|
|
|
const releaseTag = process.argv[2] || 'rc'; |
|
|
|
|
|
console.log('Prepare release core 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 exec npm version ${versionCmd} --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-v${newVersion}`; |
|
|
|
|
|
runCommand(`git checkout -b ${newBranch}`); |
|
|
|
|
|
runCommand('git add .'); |
|
|
|
|
|
runCommand(`git commit -m "Release GrapesJS core ${releaseTag}: 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(); |