exec icon indicating copy to clipboard operation
exec copied to clipboard

Run several commands

Open grv87 opened this issue 5 years ago • 7 comments

Is it possible to run several commands (i.e. array)?

Using && with a long list is not so convenient.

grv87 avatar Apr 28 '20 18:04 grv87

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 ..."
      ]
    }],
  ]
}

AndyOGo avatar Jun 09 '20 07:06 AndyOGo

I found that this works:

[
      "@semantic-release/exec",
      {
        "someStep": "echo \"cmd 1\"; echo \"cmd2\"",
      }
],

MisterBE2 avatar Aug 31 '20 07:08 MisterBE2

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.

mirkolenz avatar Dec 18 '22 18:12 mirkolenz

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/

SpyrosPsarras avatar Dec 21 '22 12:12 SpyrosPsarras

The best way to solve this is to use a bash script as mentioned in the README.

coreyar avatar Jan 17 '24 18:01 coreyar

There's a PR about this https://github.com/semantic-release/exec/pull/360

MrGadget1024 avatar Apr 15 '24 00:04 MrGadget1024