Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 23 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Publish
on:
push:
pull_request:
types: [closed]
branches: [master]

permissions:
Expand All @@ -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
Expand All @@ -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 }}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<version>` or
`Release grapesjs-mjml latest: v<version>`.
Push the release branch and open a PR targeting `master`. Merging a
`release-v<version>` 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

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading