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
80 changes: 39 additions & 41 deletions .github/workflows/onPushToMain.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
# test
name: version, tag and github release
name: Create Release From Package Version

on:
push:
branches: [main]
branches:
- main
workflow_dispatch:

permissions:
contents: write

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Check if version already exists
id: version-check
with:
node-version: 24

- name: Resolve release tag from package version
id: version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
TAG="v${PACKAGE_VERSION}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"

- name: Check whether release already exists
id: release_check
env:
GH_TOKEN: ${{ github.token }}
run: |
package_version=$(node -p "require('./package.json').version")
exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "")

if [ -n "$exists" ];
then
echo "Version v$package_version already exists"
echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again."
echo "skipped=true" >> $GITHUB_OUTPUT
if gh release view "${{ steps.version.outputs.tag }}" --repo "${{ github.repository }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Release ${{ steps.version.outputs.tag }} already exists; skipping."
else
echo "Version v$package_version does not exist. Creating release..."
echo "skipped=false" >> $GITHUB_OUTPUT
echo "tag=v$package_version" >> $GITHUB_OUTPUT
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Create GitHub release
if: steps.release_check.outputs.exists == 'false'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Setup git
if: ${{ steps.version-check.outputs.skipped == 'false' }}
GH_TOKEN: ${{ github.token }}
run: |
git config --global user.email ${{ secrets.GH_EMAIL }}
git config --global user.name ${{ secrets.GH_USERNAME }}
- name: Generate oclif README
if: ${{ steps.version-check.outputs.skipped == 'false' }}
id: oclif-readme
run: |
npm install
npm exec oclif readme
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -am "chore: update README.md"
git push -u origin ${{ github.ref_name }}
fi
- name: Create Github Release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
if: ${{ steps.version-check.outputs.skipped == 'false' }}
with:
name: ${{ steps.version-check.outputs.tag }}
tag: ${{ steps.version-check.outputs.tag }}
commit: ${{ github.ref_name }}
token: ${{ secrets.GH_TOKEN }}
skipIfReleaseExists: true
gh release create "${{ steps.version.outputs.tag }}" \
--repo "${{ github.repository }}" \
--target "${{ github.sha }}" \
--title "${{ steps.version.outputs.tag }}" \
--generate-notes
39 changes: 33 additions & 6 deletions .github/workflows/onRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,44 @@ name: publish

on:
release:
types: [released]
types: [published]
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
- run: npm install
- uses: JS-DevTools/npm-publish@19c28f1ef146469e409470805ea4279d47c3d35c
with:
token: ${{ secrets.NPM_TOKEN }}
node-version: 24
registry-url: "https://registry.npmjs.org/"
cache: npm

- name: Install dependencies
run: npm install

- name: Build package
run: npm run build

- name: Check npm for existing version
id: npm_check
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")

if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version >/dev/null 2>&1; then
echo "should_publish=false" >> "$GITHUB_OUTPUT"
echo "Version ${PACKAGE_VERSION} already exists for ${PACKAGE_NAME}; skipping publish."
else
echo "should_publish=true" >> "$GITHUB_OUTPUT"
fi

- name: Publish package (Trusted Publishing)
if: steps.npm_check.outputs.should_publish == 'true'
run: npm publish --provenance --access public
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
name: tests
on:
pull_request:
push:
branches-ignore: [main]
workflow_dispatch:

jobs:
readme-sync-check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- run: npm ci
- run: npm run build
- run: npm exec oclif readme
- name: Validate README sync
run: |
if ! git diff --exit-code -- README.md; then
echo "::error file=README.md,line=1::README.md is out of sync with Oclif command docs. Run 'npm exec oclif readme' and commit the result."
exit 1
fi

unit-tests:
strategy:
matrix:
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coveops-cli-plugin

Check failure on line 1 in README.md

View workflow job for this annotation

GitHub Actions / readme-sync-check

README.md is out of sync with Oclif command docs. Run 'npm exec oclif readme' and commit the result.
=================

A new CLI generated with oclif
Expand Down Expand Up @@ -27,6 +27,34 @@
...
```
<!-- usagestop -->
## Commerce Troubleshoot Console Deploy Examples

Managed key strategy (default):

```sh
coveops org commerce troubleshoot deploy --page-name commerce-troubleshoot-console
```

Provided tokens strategy:

```sh
coveops org commerce troubleshoot deploy --page-name commerce-troubleshoot-console --engine-token <ENGINE_TOKEN> --cmh-token <CMH_TOKEN>
```

Update an existing hosted page with a known ID:

```sh
coveops org commerce troubleshoot deploy --page-name commerce-troubleshoot-console --page-id <HOSTED_PAGE_ID>
```

Name-only update behavior:

```sh
coveops org commerce troubleshoot deploy --page-name commerce-troubleshoot-console
```

When `--page-id` is omitted, the deployer resolves by page name first: if a hosted page already matches that name, it updates it; otherwise deployment can create a new hosted page.

# Commands
<!-- commands -->
* [`coveops hello PERSON`](#coveops-hello-person)
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"@coveo/cli-commons": "^2.9.4",
"@coveo/platform-client": "^57.12.0",
"@coveops/commerce-troubleshoot-deployer": "^0.1.0",
"@oclif/core": "^4",
"@oclif/plugin-help": "^6",
"@oclif/plugin-plugins": "^5"
Expand Down
Loading
Loading