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

The for loop does not support specifying multiple commands #1599

Closed
QianChenglong opened this issue Apr 17, 2024 · 1 comment
Closed

The for loop does not support specifying multiple commands #1599

QianChenglong opened this issue Apr 17, 2024 · 1 comment

Comments

@QianChenglong
Copy link

image
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Apr 17, 2024
@pd93
Copy link
Member

pd93 commented Apr 28, 2024

This is by design. The recommended way to do this would be something like this:

version: 3

vars:
  IMAGE: my/image
  GIT_VERSION: latest

tasks:
  release:
    vars:
      OS: linux
      ARCH: amd64 arm64
      TARGET: "{{.IMAGE}}:{{.GIT_VERSION}}"
    cmds:
      - for: { var: ARCH }
        task: release-arch
        vars:
          OS: "{{.OS}}"
          ARCH: "{{.ITEM}}"
          TARGET: "{{.TARGET}}"

  release-arch:
    internal: true # optional
    cmds:
      - docker manifest create {{.TARGET}} {{.TARGET}}-{{.OS}}-{{.ARCH}}
      - docker manifest annotate {{.TAGET}} {{.TARGET}}-{{.OS}}-{{.ARCH}} --os {{.OS}} --arch {{.ARCH}}

This results in:

❯ task -d ./tmp/1599 --dry release
task: [release-arch] docker manifest create my/image:latest my/image:latest-linux-amd64
task: [release-arch] docker manifest annotate  my/image:latest-linux-amd64 --os linux --arch amd64
task: [release-arch] docker manifest create my/image:latest my/image:latest-linux-arm64
task: [release-arch] docker manifest annotate  my/image:latest-linux-arm64 --os linux --arch arm64

if you wanted the release task for each arch to run in parallel, you can also swap cmds for deps in the release task.

@pd93 pd93 closed this as completed Apr 28, 2024
@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Apr 28, 2024
@pd93 pd93 added the type: question Further information is requested. label Apr 28, 2024
@pd93 pd93 removed the type: question Further information is requested. label Dec 15, 2024
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

No branches or pull requests

3 participants