Run several commands
Is it possible to run several commands (i.e. array)?
Using && with a long list is not so convenient.
It would be really great to support a list of executed commands in series cross platform.
{
"plugins": [
["@semantic-release/exec", {
"publishCmd": [
"cmd 1",
"cmd 2",
"cmd ..."
]
}],
]
}
I found that this works:
[
"@semantic-release/exec",
{
"someStep": "echo \"cmd 1\"; echo \"cmd2\"",
}
],
My current workaround (if using the file release.config.js) is to use the join operator on a list of strings like so:
[
"@semantic-release/exec",
{
step: [
"cmd1",
"cmd2,
"cmd3",
].join(" && "),
},
]
While not as elegant as a native support of command lists, it is still quite easy to handle this way.
I am using yaml .releaserc.yml and I have to say that the following works
branches:
- main
plugins:
- '@semantic-release/commit-analyzer'
- - '@semantic-release/exec'
- prepareCmd: echo "${nextRelease.version}" > ./version.txt
successCmd: >
if [ ! -f ./version.txt ] ;
then echo "Version file not found" && exit 1;
fi;
if [ ! -f ./XXX.zip ];
then echo "XXX.zip file not found" && exit 1;
fi;
zip -u XXX.zip version.txt;
or with newlines
branches:
- main
plugins:
- '@semantic-release/commit-analyzer'
- - '@semantic-release/exec'
- prepareCmd: echo "${nextRelease.version}" > ./version.txt
successCmd: |
if [ ! -f ./version.txt ]
then echo "Version file not found" && exit 1
fi
if [ ! -f ./XXX.zip ]
then echo "XXX.zip file not found" && exit 1
fi
zip -u XXX.zip version.txt
The above exports during the step prepareCMD, the version into a file called version.txt and then on the step successCMD executes a list of commands on bash. I am using a linux operating system for the semantic versioning build pipeline. A good for me source is the following https://learnxinyminutes.com/docs/yaml/
The best way to solve this is to use a bash script as mentioned in the README.
There's a PR about this https://github.com/semantic-release/exec/pull/360