CircleCI-Public / orb-tools-orb

Various tools for authoring and publishing CircleCI orbs
https://circleci.com/orbs/registry/orb/circleci/orb-tools
MIT License
51 stars 76 forks source link

Allow custom steps / logic prior to publish #212

Open eddiewebb opened 1 year ago

eddiewebb commented 1 year ago

Describe Request:

Customer is publishing single orb to many organizations and using matrix to call publish job.

They thought about using pre-steps to run some envsubt on the yaml before publishing, but since pre-steps run before workspace from prior job is attached, there is nothing to work on. Pre-step does not support special copmmands like attach_workspace so I am suggesting a parameter to publish job that is of steps type to run after checkout (#211 )/attach worksapce but before publish step.

- existing checkout or attach steps run
- custom steps parameter steps are executed
- existing publish is executed

Examples:

workflows:
  lint-pack:
    jobs:
      ...
      - orb-tools/publish:.
          matrix:
            parameters:
              org_name:
                - "org_1/resource_class"
                - "org_2/resource_class"
                - "org_3/resource_class"
              context:  [ orb-publishing ]
              pre_publish_steps:
                 - export ORG_NAME=<<matrix.org_name>>
                 - envsubst '$ORG_NAME' < ${ORB_DIR}/${ORB_FILE} > ${ORB_DIR}/${ORB_FILE}

Supporting Documentation Links:

Peter-Darton-i2 commented 1 year ago

https://circleci.com/developer/orbs/orb/circleci/orb-tools?version=12.0.0#jobs-publish onwards support a attach_workspace boolean parameter which would allow someone to set it false and then put their logic into a pre-steps block. e.g. have a pre-steps block that does everything that the publish job normally does when attach_workspace is true and then carry out the customer-specific logic.

(Weirdly, the job also supports a checkout boolean that's declared and never used ... but that's already been reported in #211)