Skip to content

Run several commands #110

Open
Open

Description

@grv87

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

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

Activity

  1. AndyOGo commented on Jun 9, 2020

    @AndyOGo

    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 ..."
          ]
        }],
      ]
    }
  2. MisterBE2 commented on Aug 31, 2020

    @MisterBE2

    I found that this works:

    [
          "@semantic-release/exec",
          {
            "someStep": "echo \"cmd 1\"; echo \"cmd2\"",
          }
    ],
    
  3. mirkolenz commented on Dec 18, 2022

    @mirkolenz

    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.

  4. SpyrosPsarras commented on Dec 21, 2022

    @SpyrosPsarras

    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/

  5. coreyar commented on Jan 17, 2024

    @coreyar

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

  6. MrGadget1024 commented on Apr 15, 2024

    @MrGadget1024

    There's a PR about this #360

  7. NoxTav commented on Aug 30, 2024

    @NoxTav

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions