semantic-release not creating new release and changelog not pushed to GitLab
Asked Answered
A

2

6

I have the following problem: As soon, as my pipeline starts and a release should be published by semantic-release, nothing happens. Only the correct label is created.

My .releaserc looks like this:

{
  "branches": ["master"],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "@semantic-release/changelog",
      {
        "changelogFile": "docs/CHANGELOG.md"
      }
    ],
    [
      "@semantic-release/gitlab",
      {
        "assets": [{"path": "docs/CHANGELOG.md"}]
      }
    ]
  ]
}

The stage in my gitlab-ci.yml looks like this:

release:
  image: node:13
  stage: release
  only:
    refs:
    - master
  before_script:
    - 'echo Stage - Release started'
  script:
    - npm install @semantic-release/gitlab
    - npm install @semantic-release/changelog
    - npx semantic-release
  after_script:
    - 'echo Stage - Release finished'

As I said, everything works as intended. The pipeline succeeds and there are no warnings within the logs. Anyways, the only thing that happens is, that the label is created correctly. I do not have a new release. And I do not have the new CHANGELOG.md. Did I maybe miss something within my pipeline or the config?

[12:01:03 PM] [semantic-release] › ℹ  Running semantic-release version 17.4.4
[12:01:03 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[12:01:03 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/gitlab"
[12:01:03 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[12:01:03 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[12:01:03 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
[12:01:03 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/gitlab"
[12:01:05 PM] [semantic-release] › ✔  Run automated release from branch master on repository https://gitlab-ci-token:[secure]@gitlab.***.com/***.git
[12:01:06 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[12:01:06 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[12:01:06 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[12:01:06 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/gitlab"
[12:01:06 PM] [semantic-release] [@semantic-release/gitlab] › ℹ  Verify GitLab authentication (https://gitlab.***.com/api/v4)
[12:01:06 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[12:01:06 PM] [semantic-release] › ℹ  Found git tag v1.1.0 associated with version 1.1.0 on branch master
[12:01:06 PM] [semantic-release] › ℹ  Found 3 commits since last release
[12:01:06 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[12:01:06 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: Merge branch '***' into 'master'
Resolve "***"
Closes #5
See merge request ***!3
[12:01:06 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[12:01:06 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: ***
[12:01:06 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[12:01:06 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: feat: ***
[12:01:06 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The release type for the commit is minor
[12:01:06 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analysis of 3 commits complete: minor release
[12:01:06 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[12:01:06 PM] [semantic-release] › ℹ  The next release version is 1.2.0
[12:01:06 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[12:01:06 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[12:01:06 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/changelog"
[12:01:06 PM] [semantic-release] [@semantic-release/changelog] › ℹ  Create /builds/***/docs/CHANGELOG.md
[12:01:06 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/changelog"
[12:01:08 PM] [semantic-release] › ✔  Created tag v1.2.0
[12:01:08 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/gitlab"
Angelika answered 15/7, 2021 at 12:18 Comment(2)
I have similar issue. Did you find the root cause?Pensile
@JasimKhanAfridi sadly noAngelika
V
1

The default plugins that 'semantic-release' uses are:

    "@semantic-release/commit-analyzer"
    "@semantic-release/release-notes-generator"
    "@semantic-release/npm"
    "@semantic-release/github"

For your particular configuration, which matches mine, you have to replace the github one with the gitlab one.

In my particular case, based on the example in the documentation, and the tests I've done, I needed to specify the @semantic-release/git plugin as well, since it seems to be the one in charge of creating the release.

So, the full configuration you should use is:

    {
      "branches": ["master"],
      "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator",
        [
          "@semantic-release/changelog",
          {
            "changelogFile": "docs/CHANGELOG.md"
          }
        ],
        [
          "@semantic-release/gitlab",
          {
            "assets": [{"path": "docs/CHANGELOG.md"}]
          }
        ],
        "@semantic-release/git"
      ]
    }

Regards!

Vachon answered 24/3, 2022 at 12:38 Comment(1)
Adding the git plugin to the end solved it for me. Thanks!Diskson
C
0

I was having a similar issue, but not with the file .releaserc. I was using a release key in the package.json file.

In my case the file CHANGELOG.md was not being created because I added the plugins list at the root level of the json file. But it should be inside the release object. When I fixed that the changelog file got created.

This is the correct json:

{
  "name": "some-name",
  "description": "some description",
  "private": true,
  "devDependencies": {
    "@semantic-release/changelog": "^6.0.2",
    "@semantic-release/git": "^10.0.1",
    "semantic-release": "^20.1.0"
  },
  "version": "0.0.0-development",
  "scripts": {
    "semantic-release": "semantic-release"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/some-user/some-repo.git"
  },
  "publishConfig": {
    "access": "restricted"
  },
  "release": {
    "branches": [
      "main"
    ],
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      "@semantic-release/changelog",
      "@semantic-release/git",
      "@semantic-release/github"
    ]
  }
}

Canarese answered 29/1, 2023 at 20:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.