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

Updated release process for Search and Comments UI #22146

Merged
merged 2 commits into from
Feb 10, 2025
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
4 changes: 3 additions & 1 deletion .github/scripts/release-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const semver = require('semver');

// Maps a package name to the config key in defaults.json
const CONFIG_KEYS = {
'@tryghost/portal': 'portal'
'@tryghost/portal': 'portal',
'@tryghost/sodo-search': 'sodoSearch',
'@tryghost/comments-ui': 'comments'
};

const CURRENT_DIR = process.cwd();
Expand Down
135 changes: 135 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1138,3 +1138,138 @@ jobs:
with:
url: |
https://cdn.jsdelivr.net/ghost/portal@~{{ env.current_minor }}/umd/portal.min.js
publish_search:
needs: [
job_setup,
job_lint,
job_unit-tests
]
name: Publish @tryghost/sodo-search
runs-on: ubuntu-latest
if: always() && needs.job_setup.result == 'success' && needs.job_lint.result == 'success' && needs.job_unit-tests.result == 'success' && needs.job_setup.outputs.is_main == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Restore caches
uses: ./.github/actions/restore-cache
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_setup.outputs.dependency_cache_key }}

- name: Check if version changed
id: version_check
working-directory: apps/sodo-search
run: |
CURRENT_VERSION=$(cat package.json | jq -r .version)
PUBLISHED_VERSION=$(npm show @tryghost/sodo-search version || echo "0.0.0")
echo "Current version: $CURRENT_VERSION"
echo "Published version: $PUBLISHED_VERSION"
CURRENT_MINOR=$(cat package.json | jq -r .version | awk -F. '{print $1"."$2}')
echo "current_minor=$CURRENT_MINOR" >> $GITHUB_ENV
if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "Version is unchanged."
echo "version_changed=false" >> $GITHUB_ENV
else
echo "Version has changed."
echo "version_changed=true" >> $GITHUB_ENV
fi
- name: Build the package
if: env.version_changed == 'true'
run: yarn run nx build @tryghost/sodo-search

- name: Configure .npmrc
if: env.version_changed == 'true'
run: |
echo "@tryghost:registry=https://registry.npmjs.org/" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- name: Publish to npm
if: env.version_changed == 'true'
working-directory: apps/sodo-search
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public

- name: Purge jsdelivr cache
if: env.version_changed == 'true'
uses: gacts/purge-jsdelivr-cache@v1
with:
url: |
https://cdn.jsdelivr.net/ghost/sodo-search@~{{ env.current_minor }}/umd/sodo-search.min.js
https://cdn.jsdelivr.net/ghost/sodo-search@~{{ env.current_minor }}/umd/main.css
publish_comments:
needs: [
job_setup,
job_lint,
job_unit-tests
]
name: Publish @tryghost/comments-ui
runs-on: ubuntu-latest
if: always() && needs.job_setup.result == 'success' && needs.job_lint.result == 'success' && needs.job_unit-tests.result == 'success' && needs.job_setup.outputs.is_main == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Restore caches
uses: ./.github/actions/restore-cache
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_setup.outputs.dependency_cache_key }}

- name: Check if version changed
id: version_check
working-directory: apps/comments-ui
run: |
CURRENT_VERSION=$(cat package.json | jq -r .version)
PUBLISHED_VERSION=$(npm show @tryghost/comments-ui version || echo "0.0.0")
echo "Current version: $CURRENT_VERSION"
echo "Published version: $PUBLISHED_VERSION"
CURRENT_MINOR=$(cat package.json | jq -r .version | awk -F. '{print $1"."$2}')
echo "current_minor=$CURRENT_MINOR" >> $GITHUB_ENV
if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "Version is unchanged."
echo "version_changed=false" >> $GITHUB_ENV
else
echo "Version has changed."
echo "version_changed=true" >> $GITHUB_ENV
fi
- name: Build the package
if: env.version_changed == 'true'
run: yarn run nx build @tryghost/comments-ui

- name: Configure .npmrc
if: env.version_changed == 'true'
run: |
echo "@tryghost:registry=https://registry.npmjs.org/" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- name: Publish to npm
if: env.version_changed == 'true'
working-directory: apps/comments-ui
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public

- name: Purge jsdelivr cache
if: env.version_changed == 'true'
uses: gacts/purge-jsdelivr-cache@v1
with:
url: |
https://cdn.jsdelivr.net/ghost/comments-ui@~{{ env.current_minor }}/umd/comments-ui.min.js
9 changes: 6 additions & 3 deletions apps/comments-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ A patch release can be rolled out instantly in production, whereas a minor/major
### Patch release

1. Run `yarn ship` and select a patch version when prompted
2. (Optional) Clear JsDelivr cache to get the new version out instantly ([docs](https://www.notion.so/ghost/How-to-clear-jsDelivr-CDN-cache-2930bdbac02946eca07ac23ab3199bfa?pvs=4)). Typically, you'll need to open `https://purge.jsdelivr.net/ghost/comments-ui@~${COMMENTS_UI_VERSION}/umd/comments-ui.min.js` and
`https://purge.jsdelivr.net/ghost/comments-ui@~${COMMENTS_UI_VERSION}/umd/main.css` in your browser, where `COMMENTS_UI_VERSION` is the latest minor version in `ghost/core/core/shared/config/defaults.json` ([code](https://github.com/TryGhost/Ghost/blob/0aef3d3beeebcd79a4bfd3ad27e0ac67554b5744/ghost/core/core/shared/config/defaults.json#L198))
2. Merge the release commit to `main`

### Minor / major release

1. Run `yarn ship` and select a minor or major version when prompted
2. Update the Comments UI version in `ghost/core/core/shared/config/defaults.json` to the new minor or major version ([code](https://github.com/TryGhost/Ghost/blob/0aef3d3beeebcd79a4bfd3ad27e0ac67554b5744/ghost/core/core/shared/config/defaults.json#L198))
2. Merge the release commit to `main`
3. Wait until a new version of Ghost is released

### JsDelivr cache
If the CI doesn't clear JsDelivr cache to get the new version out instantly, you may want to do it yourself manually ([docs](https://www.notion.so/ghost/How-to-clear-jsDelivr-CDN-cache-2930bdbac02946eca07ac23ab3199bfa?pvs=4)). Typically, you'll need to open `https://purge.jsdelivr.net/ghost/comments-ui@~${COMMENTS_UI_VERSION}/umd/comments-ui.min.js` and
`https://purge.jsdelivr.net/ghost/comments-ui@~${COMMENTS_UI_VERSION}/umd/main.css` in your browser, where `COMMENTS_UI_VERSION` is the latest minor version in `ghost/core/core/shared/config/defaults.json` ([code](https://github.com/TryGhost/Ghost/blob/0aef3d3beeebcd79a4bfd3ad27e0ac67554b5744/ghost/core/core/shared/config/defaults.json#L198))

# Copyright & License

Copyright (c) 2013-2025 Ghost Foundation - Released under the [MIT license](LICENSE).
3 changes: 1 addition & 2 deletions apps/comments-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"test:e2e:full": "ALL_BROWSERS=1 yarn test:e2e",
"lint": "eslint src --ext .js,.ts,.jsx,.tsx --cache",
"preship": "yarn lint",
"ship": "STATUS=$(git status --porcelain .); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn version; else echo \"Uncommitted changes found.\" && exit 1; fi",
"postship": "git push ${GHOST_UPSTREAM:-origin} --follow-tags && npm publish",
"ship": "node ../../.github/scripts/release-apps.js",
"prepublishOnly": "yarn build"
},
"browserslist": {
Expand Down
3 changes: 1 addition & 2 deletions apps/sodo-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"test:unit": "yarn test:ci",
"lint": "eslint src --ext .js --cache",
"preship": "yarn lint",
"ship": "STATUS=$(git status --porcelain .); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn version; else echo \"Uncommitted changes found.\" && exit 1; fi",
"postship": "git push ${GHOST_UPSTREAM:-origin} --follow-tags && npm publish",
"ship": "node ../../.github/scripts/release-apps.js",
"prepublishOnly": "yarn build"
},
"eslintConfig": {
Expand Down
Loading