Skip to content

Commit

Permalink
Merge pull request #637 from contentful/next
Browse files Browse the repository at this point in the history
release@main
  • Loading branch information
ChidinmaOrajiaku committed Jun 3, 2024
2 parents 9833803 + 99aabcc commit eefd632
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
branches:
- '**'
workflow_dispatch:
inputs:
publish-prerelease:
description: 'Publish prerelease version of the selected branch'
required: false
default: false
type: boolean

jobs:
install-build:
Expand All @@ -21,14 +27,18 @@ jobs:
if: >-
(github.ref_name == 'main' ||
github.ref_name == 'development' ||
github.ref_name == 'next') &&
github.ref_name == 'next' ||
inputs.publish-prerelease
) &&
!contains(github.event.head_commit.message, 'skip-release') &&
github.actor != 'dependabot[bot]' &&
github.actor != 'contentful-automation[bot]'
permissions:
contents: write
id-token: write
uses: ./.github/workflows/publish.yaml
with:
publish-prelease: ${{ inputs.publish-prerelease }}
secrets:
VAULT_URL: ${{ secrets.VAULT_URL }}
upload-artifact-cleanup:
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Publish packages

on:
workflow_call:
inputs:
publish-prelease:
description: 'Publish prerelease version of the current ref'
default: false
required: false
type: boolean
secrets:
VAULT_URL:
required: true
Expand Down Expand Up @@ -73,14 +79,17 @@ jobs:
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor}}@users.noreply.github.com"
if [ ${{ github.ref_name }} = development ]; then
npx lerna publish --conventional-commits --conventional-prerelease --exact --force-publish --preid dev-$(date +%Y%m%dT%H%M)-$(git rev-parse HEAD | cut -c1-7) --dist-tag dev --no-changelog --no-push --yes --no-private
if [ ${{ inputs.publish-prerelease }} ]; then
npx lerna publish --conventional-commits --conventional-prerelease --exact --force-publish --preid prerelease-$(date +%Y%m%dT%H%M)-$(git rev-parse HEAD | cut -c1-7) --no-changelog --no-push --yes --no-private --dist-tag prerelease --allow-branch ${{ github.ref_name }}
elif [ ${{ github.ref_name }} = development ]; then
npx lerna publish --conventional-commits --conventional-prerelease --exact --force-publish --preid dev-$(date +%Y%m%dT%H%M)-$(git rev-parse HEAD | cut -c1-7) --dist-tag dev --no-changelog --no-push --yes --no-private
elif [ ${{ github.ref_name }} = next ]; then
npx lerna publish --conventional-commits --conventional-prerelease --exact --force-publish --preid beta --dist-tag next --no-changelog --yes --no-private
else
npx lerna publish --conventional-commits --conventional-graduate --exact --force-publish --yes --no-private --dist-tag latest --create-release github
fi
- name: 'Merge changes downstream'
if: ${{ !inputs.publish-prerelease }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ When a PR is merged into `main`, the CI/CD pipeline will automatically publish a

To fix a critical bug that is in `main`, branch of the `main` branch. When your work is complete open a PR against `main`, and when it is approved, merge it back into `main` using the "Squash and merge" option. The change will be automatically merged back into `next` and `development`. However, if there is a merge conflict doing so, you will have to resolve it manually.

### "Prerelease" packages

An option exists for developers to publish specific feature branches as an installable "prerelease" version for testing purposes. This option is presented when [manually triggering the main workflow](https://github.com/contentful/experience-builder/actions/workflows/main.yml). If the "Publish prerelease version of the selected branch" checkbox is selected, a package version for that work-in-progress feature branch will be published to the public NPM repository.

## Commit Message Guidelines

We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for our commit messages. This allows us to automatically generate changelogs and version bumps based on the commit messages. Please take care in your commit messages that make it into the main branches (`development`, `next`, and `main`) to follow this specification, as it helps with the release process.
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const OUTGOING_EVENTS = {
ComponentMoveStarted: 'componentMoveStarted',
ComponentMoveEnded: 'componentMoveEnded',
OutsideCanvasClick: 'outsideCanvasClick',
SDKFeatures: 'sdkFeatures',
};

export const INCOMING_EVENTS = {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/registries/breakpointsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const defineBreakpoints = (breakpoints: Breakpoint[]) => {
};

export const runBreakpointsValidation = () => {
if (!breakpointsRegistry.length) return;

const validation = validateBreakpointsDefinition(breakpointsRegistry);
if (!validation.success) {
throw new Error(
Expand Down
2 changes: 2 additions & 0 deletions packages/experience-builder-sdk/src/core/sdkFeatures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Object to store the SDK features that are enabled/disabled
export const sdkFeatures: Record<string, unknown> = {};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
tryParseMessage,
} from '@contentful/experiences-core';
import { INCOMING_EVENTS, OUTGOING_EVENTS } from '@contentful/experiences-core/constants';
import { sdkFeatures } from '../core/sdkFeatures';

type UseDetectEditorModeArgs = {
/** If running from a known client side only situation (ie: useFetchBySlug),
Expand Down Expand Up @@ -42,6 +43,7 @@ export const useDetectEditorMode = ({ isClientSide = false }: UseDetectEditorMod
if (typeof window !== 'undefined' && !window.__EB__?.isEditorMode) {
window.addEventListener('message', onMessage);
sendMessage(OUTGOING_EVENTS.Connected);
sendMessage(OUTGOING_EVENTS.SDKFeatures, sdkFeatures);

setTimeout(() => {
if (!receivedMessage.current) {
Expand Down

0 comments on commit eefd632

Please sign in to comment.