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

Run several commands #110

Open
grv87 opened this issue Apr 28, 2020 · 7 comments · May be fixed by #360
Open

Run several commands #110

grv87 opened this issue Apr 28, 2020 · 7 comments · May be fixed by #360

Comments

@grv87
Copy link

grv87 commented Apr 28, 2020

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

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

@AndyOGo
Copy link

AndyOGo commented Jun 9, 2020

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

@MisterBE2
Copy link

MisterBE2 commented Aug 31, 2020

I found that this works:

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

@mirkolenz
Copy link

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.

@SpyPower
Copy link

SpyPower commented Dec 21, 2022

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/

@coreyar
Copy link

coreyar commented Jan 17, 2024

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

@MrGadget1024
Copy link

There's a PR about this #360

@Renari Renari linked a pull request Jul 25, 2024 that will close this issue
@NoemieTav
Copy link

NoemieTav commented Aug 30, 2024

I encounter the same issue.

Can I use the plugin several times?

Like this:

[
  [
    "@semantic-release/exec",
    {
      "prepareCmd": [
        "cmd1",
      ]
    },
  ],
  [
    "@semantic-release/exec",
    {
      "prepareCmd": [
        "cmd2",
      ]
    },
  ]
]

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

Successfully merging a pull request may close this issue.

8 participants