-
Notifications
You must be signed in to change notification settings - Fork 37
ci(release): add rebase step before versioning to prevent push race #525
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
Open
charlesmulder
wants to merge
3
commits into
RedHatInsights:main
Choose a base branch
from
charlesmulder:cm-rebase-before-release
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−4
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,9 @@ set -euo pipefail | |
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
|
|
||
| mismatch=0 | ||
| registry_error=0 | ||
| npm_stderr_file="$(mktemp)" | ||
| trap 'rm -f "$npm_stderr_file"' EXIT # clean up temp file on exit | ||
| # Column widths for alignment | ||
| printf "%-60s %-12s %-12s %-15s %s\n" "PACKAGE" "DISK" "GIT TAG" "NPM" "STATUS" | ||
| printf '%.0s-' {1..110} | ||
|
|
@@ -54,13 +57,25 @@ for dir in "$REPO_ROOT"/packages/*/; do | |
| [[ -z "$tag_ver" ]] && tag_ver="NONE" | ||
|
|
||
| # --- npm registry version --- | ||
| npm_ver="$(npm view "$pkg" version --fetch-timeout=10000 2>/dev/null)" || true | ||
| [[ -z "$npm_ver" ]] && npm_ver="NOT_ON_NPM" | ||
| npm_ver="$(npm view "$pkg" version --fetch-timeout=10000 2>"$npm_stderr_file")" && npm_rc=0 || npm_rc=$? | ||
| if [[ $npm_rc -ne 0 ]]; then | ||
| if grep -q 'E404' "$npm_stderr_file"; then | ||
| npm_ver="NOT_ON_NPM" | ||
| else | ||
| npm_ver="REGISTRY_ERROR" | ||
| fi | ||
| fi | ||
|
|
||
| # --- Compare --- | ||
| if [[ "$disk_ver" == "$tag_ver" && "$disk_ver" == "$npm_ver" ]]; then | ||
| status="OK" | ||
| marker="✓" | ||
| elif [[ "$npm_ver" == "REGISTRY_ERROR" ]]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering what happens if $npm_ver is "NOT_ON_NPM" here? Do we need another elif? |
||
| status="REGISTRY_ERROR" | ||
| marker="✗" | ||
| mismatch=1 | ||
| registry_error=1 | ||
| echo "::error::${pkg}: npm registry lookup failed (timeout, auth, or outage). Cannot verify npm version." | ||
| elif [[ "$tag_ver" == "NONE" && "$npm_ver" == "NOT_ON_NPM" ]]; then | ||
| # New package: no tag, not published. Flag as informational but still a mismatch. | ||
| status="NEW_PACKAGE" | ||
|
|
@@ -80,6 +95,16 @@ done | |
| echo "" | ||
| if [[ $mismatch -ne 0 ]]; then | ||
| echo "Version verification FAILED. Fix mismatches before releasing." | ||
| if [[ $registry_error -ne 0 ]]; then | ||
| echo "" | ||
| echo "npm registry lookup failed for one or more packages. Check registry status," | ||
| echo "network connectivity, and npm authentication before re-running." | ||
| else | ||
| echo "" | ||
| echo "If disk and tag match but npm is behind, a prior npm publish likely failed." | ||
| echo "Pull latest main with tags, build, and run 'npx nx release publish' to recover." | ||
| echo "Subsequent releases will remain blocked until the missing version is published." | ||
| fi | ||
| exit 1 | ||
| else | ||
| echo "All package versions are aligned across disk, git tags, and npm registry." | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: PR title lint | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| types: [opened, edited, reopened] | ||
|
|
||
| jobs: | ||
| pr-title-lint: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
| - uses: './.github/actions/setup-environment' | ||
| - name: Install | ||
| shell: bash | ||
| run: npm ci | ||
| - name: Validate PR title with commitlint | ||
| shell: bash | ||
| env: | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| run: echo "$PR_TITLE" | npx commitlint --verbose |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.