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

How do you set branches #11

Closed
RampedIndent opened this issue Feb 21, 2023 · 15 comments
Closed

How do you set branches #11

RampedIndent opened this issue Feb 21, 2023 · 15 comments
Labels

Comments

@RampedIndent
Copy link

I keep getting this error because i'm not using the master branch

      code: 'ERELEASEBRANCHES',
      details: 'A minimum of 1 and a maximum of 3 release branches are required in the [branches configuration](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches).\n' +
        '\n' +
        'This may occur if your repository does not have a release branch, such as `master`.\n' +
        '\n' +
        'Your configuration for the problematic branches is `[]`.',
@EricCrosson
Copy link
Contributor

I don't have enough information to know what might be happening here. Are you able to link to GitHub Actions logs and your repository?

@EricCrosson
Copy link
Contributor

EricCrosson commented Feb 22, 2023

Hmm, could be because main isn't in the default list of release branches1. This looks related: semantic-release/semantic-release#1581

Footnotes

  1. https://semantic-release.gitbook.io/semantic-release/usage/configuration#branches

@RampedIndent
Copy link
Author

The one time i managed to make semantic-release run successfully i had to set the branches in the workflow file
https://github.com/RampedIndent/polylauncher/actions/runs/4232522924/workflow

@EricCrosson
Copy link
Contributor

This workflow ignores your repository's semantic-release configuration1. From that link:

    # Clear out any existing semantic-release configuration.
    #
    # This step is necessary in my projects that use a .releaserc.json file
    # with a non-stock semantic-release plugin, because semantic-release throws
    # an error when the plugin is referenced in the configuration but not
    # present in the node_modules directory.
    #
    # Therefore, a quick and drity workaround is to clear out the configuration
    # before invoking semantic-release.

This means semantic-release's default value for branches2 is used. We could hack in support for main branches specifically, but it seems more desirable to support the host repository's arbitrary branches configuration.

Footnotes

  1. https://github.com/semantic-release-action/next-release-version/blob/51270e55e25801f8a2846f0e581c85323190503d/internal/action.yml#L77

  2. https://semantic-release.gitbook.io/semantic-release/usage/configuration#branches

@RampedIndent
Copy link
Author

This workflow ignores your repository's semantic-release configuration1. From that link:

is that step only necessary for .releaserc files that use non stock semantic release plugins?
if so maybe there could be a toggle to disable that step if it is not necessary

@RampedIndent
Copy link
Author

RampedIndent commented Feb 25, 2023

the command yq '.branches | {"branches": .}' .releaserc.yaml > .releaserc.json will isolate the branches and convert them to json
yq -p '.branches | {"branches": .}' .releaserc.json > .releaserc.json should work for json files

RampedIndent added a commit to RampedIndent/next-release-version that referenced this issue Feb 25, 2023
Started fix for semantic-release-action#11 
missing fix for `.releaserc{,.js,.cjs} .release.config.{js,cjs}` files
@RampedIndent
Copy link
Author

RampedIndent commented Feb 25, 2023

Implemented a fix for .json , .yml, and .yaml files that should work.
Currently it just deletes everything apart from .branches in the files, this can be changed if it would work better
Edit:
Should probably just delete the plugins section

github-actions bot pushed a commit that referenced this issue Feb 25, 2023
## [4.0.3](v4.0.2...v4.0.3) (2023-02-25)

### Bug Fixes

* use host semantic-release configuration ([ebbae10](ebbae10)), closes [#11](#11)
@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@EricCrosson
Copy link
Contributor

Should probably just delete the plugins section

This is the approach I was leaning towards too, but it turns out we can override the plugins section with a CLI option. Please give it a shot and let me know if the issue is resolved!

@RampedIndent
Copy link
Author

it runs successfully after i commented out some additional sections in my .releaserc

@EricCrosson
Copy link
Contributor

Hmm, were these the necessary changes? RampedIndent/polylauncher@e941501

@RampedIndent
Copy link
Author

I got this error so i commented out all the stuff that i figured wasn't required.
https://github.com/RampedIndent/polylauncher/actions/runs/4273772915/jobs/7439904486

@EricCrosson
Copy link
Contributor

Thanks for the link, copying the error here for posterity

Run : calculate next semantic-release version
[6:42:41 AM] [semantic-release] › ℹ  Running semantic-release version 20.1.0
[6:42:41 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "semantic-release-export-data"
[6:42:41 AM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[6:42:41 AM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "semantic-release-export-data"
[6:42:41 AM] [semantic-release] › ✘  An error occurred while running semantic-release: Error: Cannot find module '@semantic-release/git'
Require stack:
- /home/runner/work/polylauncher/polylauncher/noop.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at resolveFileName (/home/runner/work/_temp/.semantic-release-action_next-release-version/node_modules/resolve-from/index.js:29:39)
    at resolveFrom (/home/runner/work/_temp/.semantic-release-action_next-release-version/node_modules/resolve-from/index.js:43:9)
    at module.exports (/home/runner/work/_temp/.semantic-release-action_next-release-version/node_modules/resolve-from/index.js:46:47)
    at loadPlugin (file:///home/runner/work/_temp/.semantic-release-action_next-release-version/node_modules/semantic-release/lib/plugins/utils.js:59:54)
    at default (file:///home/runner/work/_temp/.semantic-release-action_next-release-version/node_modules/semantic-release/lib/plugins/normalize.js:18:24)
    at file:///home/runner/work/_temp/.semantic-release-action_next-release-version/node_modules/semantic-release/lib/plugins/index.js:76:11
    at Array.map (<anonymous>)
    at file:///home/runner/work/_temp/.semantic-release-action_next-release-version/node_modules/semantic-release/lib/plugins/index.js:75:34
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/runner/work/polylauncher/polylauncher/noop.js' ]
}

EricCrosson added a commit that referenced this issue Feb 26, 2023
Relevant documentation:
https://semantic-release.gitbook.io/semantic-release/usage/plugins#plugins

In #11, @RampedIndent found that `semantic-release --dry-run` tries
`require`-ing plugins for all steps, even the
prepare/publish/success/fail steps that are not executed in `--dry-run`.

This commit uses the CLI options to override the configured plugins
for all steps, with the exception of analyze-commits.

That means this GitHub Action does not support semantic-release with
a non-stock analyze-commits configuration. Punt that issue until it's
observed in the wild.
@EricCrosson
Copy link
Contributor

I found a way to mitigate this issue, using the same pattern: 538bd6f

Thank you for the bug reports!

github-actions bot pushed a commit that referenced this issue Feb 26, 2023
## [4.0.5](v4.0.4...v4.0.5) (2023-02-26)

### Bug Fixes

* override plugins for each release step ([538bd6f](538bd6f)), closes [#11](#11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants