From 83cbd4f69a9ee4d43a9abdfd87a78e2803b90fd1 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 29 Oct 2026 14:02:21 +0400 Subject: [PATCH 1/2] Update publish workflow --- .github/workflows/publish.yml | 28 +++++++++++++++++++++++----- README.md | 12 ++++++------ scripts/release.ts | 2 +- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 523859e..342eed8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,7 @@ name: Publish on: - push: + pull_request: + types: [closed] branches: [master] permissions: @@ -9,18 +10,34 @@ permissions: jobs: publish: if: >- - startsWith(github.event.head_commit.message, 'Release grapesjs-mjml rc:') || - startsWith(github.event.head_commit.message, 'Release grapesjs-mjml latest:') + github.event.pull_request.merged == true && + github.event.pull_request.head.repo.full_name == github.repository && + startsWith(github.event.pull_request.head.ref, 'release-v') runs-on: ubuntu-latest - env: - NPM_TAG: ${{ startsWith(github.event.head_commit.message, 'Release grapesjs-mjml rc:') && 'rc' || 'latest' }} steps: - uses: actions/checkout@v7 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} - uses: actions/setup-node@v7 with: node-version: '24.x' registry-url: 'https://registry.npmjs.org' cache: npm + - name: Resolve release version + id: release + env: + RELEASE_BRANCH: ${{ github.event.pull_request.head.ref }} + run: | + node --input-type=module <<'NODE' + import { appendFileSync, readFileSync } from 'node:fs'; + const { version } = JSON.parse(readFileSync('package.json', 'utf8')); + if (!/^\d+\.\d+\.\d+(?:-rc\.\d+)?$/.test(version) || + process.env.RELEASE_BRANCH !== `release-v${version}`) { + throw new Error('The release branch must match the stable or RC version in package.json.'); + } + const tag = version.includes('-rc.') ? 'rc' : 'latest'; + appendFileSync(process.env.GITHUB_OUTPUT, `tag=${tag}\n`); + NODE - run: npm ci - run: npm run lint - run: npm run typecheck @@ -30,4 +47,5 @@ jobs: - name: Publish to npm run: npm publish --access public --tag "$NPM_TAG" env: + NPM_TAG: ${{ steps.release.outputs.tag }} NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} diff --git a/README.md b/README.md index cf9f038..af31a05 100644 --- a/README.md +++ b/README.md @@ -308,14 +308,14 @@ change. The stable command bumps the patch version, or promotes the current prerelease to its stable version. The RC command increments the current RC, or starts the next patch at `-rc.0`. -Push the release branch and open a PR targeting `master`. Keep the generated -commit message when merging (use it as the squash commit title): -`Release grapesjs-mjml rc: v` or -`Release grapesjs-mjml latest: v`. +Push the release branch and open a PR targeting `master`. Merging a +`release-v` branch from this repository triggers publishing. The branch +version must match `package.json`; PR titles and commit messages do not affect +publishing. The publish workflow runs the checks, builds the package, and publishes to npm -with the matching `rc` or `latest` tag. A GitHub release is optional and does not -trigger publishing. +with the matching `rc` or `latest` tag based on the package version. A GitHub +release is optional and does not trigger publishing. ## License diff --git a/scripts/release.ts b/scripts/release.ts index 6ece935..0468184 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -53,7 +53,7 @@ function prepareRelease() { run('git', ['commit', '--allow-empty', '-m', `Release ${name} ${tag}: v${version}`]); console.log(`Release prepared! Push release-v${version} and open a PR targeting master.`); - console.log(`Merge with the release commit message intact to publish ${name}@${version} to npm's ${tag} tag.`); + console.log(`Merging the release branch publishes ${name}@${version} to npm's ${tag} tag.`); } try { From 57b8c508098615e5bcad4a739a66e16fa3544a5b Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 29 Oct 2026 14:04:40 +0400 Subject: [PATCH 2/2] Release grapesjs-mjml rc: v1.1.1-rc.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6b1f0be..7acb273 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "grapesjs-mjml", - "version": "1.1.1-rc.0", + "version": "1.1.1-rc.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "grapesjs-mjml", - "version": "1.1.1-rc.0", + "version": "1.1.1-rc.1", "license": "BSD-3-Clause", "dependencies": { "@types/mjml-core": "^4.15.2" diff --git a/package.json b/package.json index 737b98f..ebefea6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grapesjs-mjml", - "version": "1.1.1-rc.0", + "version": "1.1.1-rc.1", "description": "MJML Componenets integration in GrapesJS", "main": "dist/index.js", "scripts": {