Skip to content
Open
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
20 changes: 19 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,28 @@ jobs:
- name: Update npm
run: npm install -g npm@11

- name: Detect latest GA branch
id: detect-ga
run: |
# Auto-detect the latest GA release branch:
# 1. git ls-remote lists all remote release-* branches without cloning history
# 2. sed strips everything up to "release-", leaving just the version (e.g., "1.10")
# 3. sort -t. splits on "." and sorts each field numerically (-n), so
# 1.9 < 1.10 < 1.11 < 2.1 (lexicographic sort would wrongly put 1.10 before 1.9)
# 4. tail -1 picks the highest version
LATEST_GA=$(git ls-remote --heads origin 'refs/heads/release-*' \
| sed 's|.*refs/heads/release-||' \
| sort -t. -k1,1n -k2,2n \
| tail -1)
echo "branch=release-${LATEST_GA}" >> "$GITHUB_OUTPUT"

- name: Publish
run: |
if [ "${{ inputs.branch }}" = "main" ]; then
npm publish --access public
npm publish --access public --tag next
elif [ "${{ inputs.branch }}" = "${{ steps.detect-ga.outputs.branch }}" ]; then
npm publish --access public --tag latest
npm dist-tag add "$(node -p "require('./package.json').name")@$(node -p "require('./package.json').version")" "${{ inputs.branch }}"
else
npm publish --access public --tag ${{ inputs.branch }}
fi
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,19 @@ Publishing is done using [Publish Package to NPM](.github/workflows/publish.yaml

**Make sure not to release MINOR or MAJOR version that are not aligned with the corresponding RHDH release.**

This workflow is **not** currently triggered automatically. It needs to be run manually from the [Actions tab](https://github.com/redhat-developer/rhdh-cli/actions/workflows/publish.yaml) in the GitHub repository.
This workflow is **not** currently triggered automatically. It needs to be run manually from the [Actions tab](https://github.com/redhat-developer/rhdh-cli/actions/workflows/publish.yaml) in the GitHub repository. Always run the workflow from the `main` branch (the "Use workflow from" dropdown) and select the target release branch via the `branch` input parameter. This ensures the latest workflow definition is used.

#### NPM dist-tags

The workflow automatically assigns npm dist-tags based on the selected branch:

| Branch | Dist-tag | Example |
| ---------------------------------------- | --------------------------------- | ------------------------------------------------------------------ |
| `main` | `next` | `npm install @red-hat-developer-hub/cli@next` |
| Latest GA release branch (auto-detected) | `latest` + branch name | `npm install @red-hat-developer-hub/cli@latest` or `@release-1.10` |
| Older release branches | Branch name (e.g., `release-1.9`) | `npm install @red-hat-developer-hub/cli@release-1.9` |

The latest GA branch is auto-detected as the `release-*` branch with the highest semver version. Plugin builders targeting a specific RHDH version should use a semver range (e.g., `~1.10.0`) or the corresponding branch tag rather than `latest`.

## Reporting Issues

Expand Down
Loading