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

Make patch release a default for each commit #143

Closed
demisx opened this issue Sep 20, 2019 · 6 comments
Closed

Make patch release a default for each commit #143

demisx opened this issue Sep 20, 2019 · 6 comments

Comments

@demisx
Copy link

demisx commented Sep 20, 2019

Hi,

Thank you for such an excellent plugin. We have a dedicated prod branch where each commit should trigger a release. Currently, certain commit types (e.g. chore) do not trigger a release. Is it possible to configure commit analyzer to bump patch version by default for any type except "no-release"? I've tried something like this, but it's not working:

  [
      "@semantic-release/commit-analyzer",
      {
        "preset": "angular",
        "releaseRules": [
          {"scope": "no-release", "release": false},
          {"type": "*", "release": "patch"}
        ]
      }
    ],

Another option, is to list each type with release: "patch", but it's not as flexible as having a wildcard. Thank you very much!

@pvdlg
Copy link
Member

pvdlg commented Sep 23, 2019

I just tested your config and it works as expected, all commits triggers a patch except the one with the scope no-release.

Can you run semantic-release with the --debug option and provide the logs?

@demisx
Copy link
Author

demisx commented Sep 24, 2019

Thank you for your prompt reply. Here is my current config:

# In .releaserc.js
module.exports = {
  plugins: [
    [
      '@semantic-release/commit-analyzer',
      {
        preset: 'angular',
        releaseRules: [
          {scope: 'skip release', release: false},
          {type: '*', release: 'patch'},
        ],
      },
    ],
    '@semantic-release/release-notes-generator',
    [
      '@semantic-release/exec',
      {
        prepareCmd: [
          './api/app/scripts/release-images.sh ${nextRelease.version}',
          './web/scripts/release-images.sh ${nextRelease.version}',
        ].join(' && '),
      },
    ],
  ],
}

And this is what's written to the CI log. Please note "ci" type commit doesn't trigger patch version bump:

[9:17:19 PM] [semantic-release] › ℹ  Running semantic-release version 0.0.0-development
2019-09-24T21:17:19.115Z semantic-release:config load config from: /builds/[path]/.releaserc.js
2019-09-24T21:17:19.121Z semantic-release:config options values: { branch: 'prod',
  repositoryUrl:
   'https://gitlab-ci-token:[secure]@[repoUrl]',
  tagFormat: 'v${version}',
  plugins:
   [ [ '@semantic-release/commit-analyzer', [Object] ],
     '@semantic-release/release-notes-generator',
     [ '@semantic-release/exec', [Object] ] ],
  _: [],
  b: 'prod',
  r:
   'https://gitlab-ci-token:[secure]@[repoUrl]'
  'repository-url':
   'https://gitlab-ci-token:[secure]@[repoUrl]',
  debug: true,
  '$0': 'node_modules/.bin/semantic-release' }
2019-09-24T21:17:19.224Z semantic-release:plugins options for @semantic-release/exec/verifyConditions: { prepareCmd:
   './api/app/scripts/release-images.sh ${nextRelease.version} && ./web/scripts/release-images.sh ${nextRelease.version}' }
[9:17:19 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/exec"
2019-09-24T21:17:19.226Z semantic-release:plugins options for @semantic-release/commit-analyzer/analyzeCommits: { preset: 'angular',
  releaseRules:
   [ { scope: 'skip release', release: false },
     { type: '*', release: 'patch' } ] }
[9:17:19 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
...
2019-09-24T21:17:19.859Z semantic-release:commit-analyzer Analyzing with custom rules
2019-09-24T21:17:19.859Z semantic-release:commit-analyzer Analyzing with default rules
2019-09-24T21:17:19.859Z semantic-release:commit-analyzer Analyzing with custom rules
2019-09-24T21:17:19.859Z semantic-release:commit-analyzer Analyzing with default rules
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: ci: update ci config and disable gitlab publish step
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: Auto-release registry.example.com/[path]/web:0.1.1

[ci skip]
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: Auto-release registry.example.com/[path]/api:0.1.1

[ci skip]
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The commit should not trigger a release
[9:17:19 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analysis of 9 commits complete: no release
2019-09-24T21:17:19.860Z semantic-release:commit-analyzer Analyzing with custom rules
2019-09-24T21:17:19.860Z semantic-release:commit-analyzer Analyzing with default rules
2019-09-24T21:17:19.860Z semantic-release:commit-analyzer Analyzing with custom rules
2019-09-24T21:17:19.860Z semantic-release:commit-analyzer Analyzing with default rules
[9:17:19 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[9:17:19 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/exec"
[9:17:19 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/exec"
[9:17:19 PM] [semantic-release] › ℹ  There are no relevant changes, so no new version is released.

@pvdlg
Copy link
Member

pvdlg commented Sep 24, 2019

What version of semantic-release and of the @semantic-release/commit-analyzer are you running?

It's quite weird that the first line of log is Running semantic-release version 0.0.0-development

@demisx
Copy link
Author

demisx commented Sep 24, 2019

I am running a fresh fork https://github.com/beocommedia/semantic-release. I created it a couple of hours ago for another issue. The @semantic-release/commit-analyzer is @6.3.0.

@pvdlg
Copy link
Member

pvdlg commented Sep 24, 2019

In version 6.x.x of @semantic-release/commit-analyzer we are not using globs in the release rules but regex. It was change in the next version (currently in beta).

So in 6.x.x instead of {"type": "*", "release": "patch"} you should do {"type": "/.*/", "release": "patch"}

@demisx
Copy link
Author

demisx commented Sep 24, 2019

Nice! Thank you for clarification on regex. Works perfectly now!

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

No branches or pull requests

2 participants