semantic-release-action
semantic-release-action copied to clipboard
Execute Semantic Release without a package.json file
It is my understanding that the action can feed the underlying semantic release with options by using the with
fields branches
, extra_plugins
etc. Hence, executing semantic release without a package.json and without a .releaserc
file for non-javascript projects.
Describe the bug
The action extis with the following error:
AggregateError:
SemanticReleaseError: Missing `package.json` file.
at module.exports (/home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/@semantic-release/npm/lib/get-error.js:6:10)
at module.exports (/home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/@semantic-release/npm/lib/get-pkg.js:17:33)
Workflow
on:
push:
branches:
- main
- beta
jobs:
release:
name: Semantic Release
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Execute Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
semantic_version: 19
branches: |
[
"+([0-9])?(.{+([0-9]),x}).x",
"main",
{
"name": "beta",
"prerelease": true
}
]
extra_plugins: |
"@semantic-release/commit-analyzer"
"@semantic-release/release-notes-generator"
"@semantic-release/github"
CI Log
[2:20:36 PM] [semantic-release] › ℹ Running semantic-release version 19.0.3
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/npm"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/github"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/npm"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/npm"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/github"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/npm"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/github"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "success" from "@semantic-release/github"
[2:20:36 PM] [semantic-release] › ✔ Loaded plugin "fail" from "@semantic-release/github"
[2:20:37 PM] [semantic-release] › ✔ Run automated release from branch main on repository https://github.com/indisrl/conta-zip
[2:20:37 PM] [semantic-release] › ✔ Allowed to push to the Git repository
[2:20:37 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/npm"
[2:20:37 PM] [semantic-release] › ✖ Failed step "verifyConditions" of plugin "@semantic-release/npm"
[2:20:37 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/github"
[2:20:37 PM] [semantic-release] [@semantic-release/github] › ℹ Verify GitHub authentication (https://api.github.com)
[2:20:37 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/github"
[2:20:37 PM] [semantic-release] › ℹ Start step "fail" of plugin "@semantic-release/github"
[2:20:39 PM] [semantic-release] [@semantic-release/github] › ℹ Found existing semantic-release issue #1.
[2:20:40 PM] [semantic-release] [@semantic-release/github] › ℹ Added comment to issue #1: https://github.com/indisrl/conta-zip/issues/1#issuecomment-1152414450.
[2:20:40 PM] [semantic-release] › ✔ Completed step "fail" of plugin "@semantic-release/github"
[2:20:40 PM] [semantic-release] › ✖ ENOPKG Missing `package.json` file.
A package.json file (https://docs.npmjs.com/files/package.json) at the root of your project is required to release on npm.
Error: AggregateError:
SemanticReleaseError: Missing `package.json` file.
at module.exports (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/@semantic-release/npm/lib/get-error.js:6:10)
at module.exports (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/@semantic-release/npm/lib/get-pkg.js:17:[33](https://github.com/indisrl/conta-zip/runs/6832568709?check_suite_focus=true#step:3:34))
at async verifyConditions (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/@semantic-release/npm/index.js:32:17)
at async validator (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/semantic-release/lib/plugins/normalize.js:[34](https://github.com/indisrl/conta-zip/runs/6832568709?check_suite_focus=true#step:3:35):24)
at async /home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/semantic-release/lib/plugins/pipeline.js:[37](https://github.com/indisrl/conta-zip/runs/6832568709?check_suite_focus=true#step:3:38):34
at async Promise.all (index 0)
at async next (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/p-reduce/index.js:16:18)
Please follow the npm guideline (https://docs.npmjs.com/getting-started/creating-node-modules) to create a valid package.json file.
Expected behavior I expect the semantic release to run.
Additional context
The action docs states branches will override the branches attribute in your configuration file.
, so I've also tried to execute the action with an empty .releaserc file guessing it would have been populated by the action. Same error result.
Am I misunderstanding the action use or is there an error in my configuration? Even though I did not specify the @semantic-release/npm
it's like the action pulled and executed it anyway.
+1 facing same issue
+1
+1
+1
having the same issue, seem this happens regardless the repo is a node project.
Was having the same thought if we are missing some config in the workflow?
Also running into this, has anyone sorted it out?
Also running into this, has anyone sorted it out?
I've simply added a .releaserc.json
file as if it was a nodejs project with the following settings (of course they should be adapted to the project use case):
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
{
"name": "beta",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
I then invoke the action as usual in a github workflow:
- name: Execute Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Also running into this, has anyone sorted it out?
I've simply added a
.releaserc.json
file as if it was a nodejs project with the following settings (of course they should be adapted to the project use case):
@maxiride thanks a ton for sharing, that helped get it working for a dotnet project I was trying to get configured 🎉
Similar issue for me : the .releaserc.json
extra file may work in some cases... but not for me, I add the plugin @google/semantic-release-replace-plugin
with replacement configuration, and has this error:
[8:37:47 AM] [semantic-release] › ℹ Running semantic-release version 19.0.5
[8:37:47 AM] [semantic-release] › ✖ An error occurred while running semantic-release: Error: Cannot find module '@google/semantic-release-replace-plugin'
Error: Error: Cannot find module '@google/semantic-release-replace-plugin'
Require stack:
- /home/runner/work/jeedom-lgthinq-plugin/jeedom-lgthinq-plugin/noop.js
Require stack:
- /home/runner/work/jeedom-lgthinq-plugin/jeedom-lgthinq-plugin/noop.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at resolveFileName (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/resolve-from/index.js:[29](https://github.com/pifou25/jeedom-lgthinq-plugin/actions/runs/5031318515/jobs/9024323660#step:3:30):39)
at resolveFrom (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/resolve-from/index.js:43:9)
at module.exports (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/resolve-from/index.js:46:47)
at loadPlugin (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/semantic-release/lib/plugins/utils.js:51:82)
at /home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/semantic-release/lib/plugins/index.js:17:37
at Array.reduce (<anonymous>)
at module.exports (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/semantic-release/lib/plugins/index.js:14:[34](https://github.com/pifou25/jeedom-lgthinq-plugin/actions/runs/5031318515/jobs/9024323660#step:3:35))
at module.exports (/home/runner/work/_actions/cycjimmy/semantic-release-action/v3/node_modules/semantic-release/lib/get-config.js:84:[35](https://github.com/pifou25/jeedom-lgthinq-plugin/actions/runs/5031318515/jobs/9024323660#step:3:36))
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/runner/work/jeedom-lgthinq-plugin/jeedom-lgthinq-plugin/noop.js'
]
}
How can I add this dependance without a package.json
file ?
Using the .releaserc file is a good temporary for some cases, but evidently it doesn't solve all cases, and I just found that for some reason you must provide a value for "plugins", and worse still that semantic-release's behaviour is that providing a "plugins" value will override the defaults.
So I agree with the original poster that, given the wide array of inputs this action accepts, providing a superfluous package.json or .releaserc shouldn't be necessary - I'd love to see it dropped as an implicit requirement!
But in case it helps anyone, this is the pre-step I'm doing in GitHub Actions
- name: Configure Semantic Release
run: echo '{"branches":[],"plugins":["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator","@semantic-release/github"]}' > .releaserc.json
(branches are configured in the action itself)