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

Previous git notes are being overwritten rather than merged #3097

Open
ncrmro opened this issue Dec 7, 2023 · 3 comments
Open

Previous git notes are being overwritten rather than merged #3097

ncrmro opened this issue Dec 7, 2023 · 3 comments

Comments

@ncrmro
Copy link

ncrmro commented Dec 7, 2023

Current behavior

Given the following branching strategy.

staging (default branch, channel: beta) -> main (channel: RC) -> LTS

  1. Merge main into staging to resolve conflicts with commit message release: merging main -> staging , hash is xyz
  2. Commit xyz in staging has a release and beta tag/release created
  3. Checkout main git merge --ff-only staging, rc tag/release created
  4. Merge squashed PR commit into staging, semantic-release errors with tag already exists
    • Showing the notes for that commit git notes --ref semantic-release show xyz | cat results in {"channels":["rc"]} which should be {"channels":["rc", "beta"]}

Expected behavior

Subsequent commits into staging do not cause a duplicate tag error.

semantic-release version

21.1.1

CI environment

Github Actions

Plugins used

These are documented in in the config below.

semantic-release configuration

{
  "branches": [
    {
      "name": "1.x",
      "range": "1.x",
      "channel": "1.x"
    },
    {
      "name": "main",
      "channel": "rc",
      "prerelease": "rc"
    },
    {
      "name": "staging",
      "channel": "beta",
      "prerelease": "beta"
    },
    "lts"
  ],
  "ci": false,
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "conventionalcommits",
        "releaseRules": [
          {
            "scope": "norelease",
            "release": false
          }
        ]
      }
    ],
    "@semantic-release/release-notes-generator",
    [
      "@semantic-release/changelog",
      {
        "changelogFile": "http://CHANGELOG.md "
      }
    ],
    "@semantic-release/npm",
    "@semantic-release/github",
    [
      "semantic-release-slack-bot",
      {
        "packageName": "unsupervised",
        "notifyOnSuccess": false,
        "notifyOnFail": false,
        "slackWebhook": "https://hooks.slack.com/services/REDACTED/REDACTED",
        "markdownReleaseNotes": true,
        "branchesConfig": [
          {
            "pattern": "main",
            "notifyOnSuccess": true,
            "notifyOnFail": false
          },
          {
            "pattern": "lts",
            "notifyOnSuccess": true,
            "notifyOnFail": false
          }
        ]
      }
    ]
  ]
}

CI logs

Show notes before action

Run git fetch origin +refs/notes/semantic-release:refs/notes/semantic-release
From https://github.com/REDACTED
 * [new ref]           refs/notes/semantic-release -> refs/notes/semantic-release
{"channels":["beta"]}
[4:01:21 PM] [semantic-release] › ℹ  Running semantic-release version 21.1.1
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[4:01:[21](https://github.com/REDACTED/actions/runs/7130713663/job/19417722801#step:4:22) PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "semantic-release-slack-bot"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/npm"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "success" from "semantic-release-slack-bot"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[4:01:21 PM] [semantic-release] › ✔  Loaded plugin "fail" from "semantic-release-slack-bot"
[4:02:21 PM] [semantic-release] › ✔  Run automated release from branch main on repository https://github.com/REDACTED
[4:02:21 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[4:02:21 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[4:02:[22](https://github.com/REDACTED) PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[4:02:22 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/npm"
[4:02:22 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/npm"
[4:02:22 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/github"
[4:02:22 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication (https://api.github.com/)
[4:02:22 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/github"
[4:02:22 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "semantic-release-slack-bot"
[4:02:22 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "semantic-release-slack-bot"
[4:02:22 PM] [semantic-release] › ℹ  Found git tag v3.0.0-rc.13 associated with version 3.0.0-rc.13 on branch main
[4:02:22 PM] [semantic-release] › ℹ  Found 11 commits since last release
[4:02:22 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"

REDACTED_COMMIT_MESSAGES

[4:02:22 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The release type for the commit is patch
[4:02:22 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analysis of 11 commits complete: minor release
[4:02:22 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[4:02:22 PM] [semantic-release] › ℹ  The next release version is 3.0.0-rc.14
[4:02:22 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[4:02:22 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"

REDACTED

[4:02:52 PM] [semantic-release] › ✔  Completed step "success" of plugin "@semantic-release/github"
[4:02:52 PM] [semantic-release] › ℹ  Start step "success" of plugin "semantic-release-slack-bot"
[4:02:52 PM] [semantic-release] [semantic-release-slack-bot] › ℹ  Sending slack notification on success
[4:02:52 PM] [semantic-release] › ✔  Completed step "success" of plugin "semantic-release-slack-bot"
[4:02:52 PM] [semantic-release] › ✔  Published release 3.0.0-rc.14 on rc channel

Show notes after action

Run git notes --ref semantic-release show 3efe5bd538cac2039a4f80700d25146b224edba9 | cat
{"channels":["rc"]}
@travi
Copy link
Member

travi commented Dec 8, 2023

by using a squash merge, you are rewriting history in a way that is losing the details you are describing. dont squash your release branches.

to recover: https://semantic-release.gitbook.io/semantic-release/support/troubleshooting#release-not-found-release-branch-after-git-push-force

@ncrmro
Copy link
Author

ncrmro commented Dec 24, 2023

@travi we only squash the PR's into staging (default branch). PR's into main and LTS are not squashed.

@hakalb
Copy link

hakalb commented Mar 6, 2024

It happens to us as well when we fast-forward merge a higher branch (e.g. develop) into a pre-release branch, hence a backmerge. The pre-release branch release job overwrites channel info created by previous develop release job.

In get-release-to-add.js it looks like pre-release branches are ignored, which cause the channel overwrite instead of adding to the current content.

const higherChannels = branches
  // Consider only releases of higher branches
  .slice(branches.findIndex(({ name }) => name === branch.name) + 1)
  // Exclude prerelease branches
  .filter(({ type }) => type !== "prerelease")
  .map(({ channel }) => channel || null);

Is it intentional to work like this?

Update:
Just read release notes for v23 and noticed that there is one note reference per tag. We are using v21 with a single reference.
Shouldn't this change prevent channel overwrite?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants