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
Variables are initialized at start of taskfile and not when I actually need them to be initialized #1604
Comments
hi @berlinguyinca, To solve your issue you can do something like that : version: '4'
env:
GOARCH: arm64
GOOS: linux
CGO_ENABLED: 0
OUTPUT_DIR: ./bin/
tasks:
build:
vars:
SOURCES:
sh: find -type f -name '*.go'
cmds:
- for: { var: SOURCES }
cmd: GOARCH=$GOARCH GOOS=$GOOS CGO_ENABLED=$CGO_ENABLED go build -ldflags="-s -w" -tags lambda.norpc -o $OUTPUT_DIR {{.ITEM}}
- task: zip
zip:
vars:
OBJECTS:
sh: find {{.OUTPUT_DIR}} -type f
cmds:
- for: { var: OBJECTS }
cmd:
zip {{.ITEM}}.zip {{.ITEM}} If you want to be able to build without zip you can add a new task : version: '4'
env:
GOARCH: arm64
GOOS: linux
CGO_ENABLED: 0
OUTPUT_DIR: ./bin/
tasks:
build:
vars:
SOURCES:
sh: find -type f -name '*.go'
cmds:
- for: { var: SOURCES }
cmd: GOARCH=$GOARCH GOOS=$GOOS CGO_ENABLED=$CGO_ENABLED go build -ldflags="-s -w" -tags lambda.norpc -o $OUTPUT_DIR {{.ITEM}}
zip:
vars:
OBJECTS:
sh: find {{.OUTPUT_DIR}} -type f
cmds:
- for: { var: OBJECTS }
cmd:
zip {{.ITEM}}.zip {{.ITEM}}
build_and_zip:
cmds:
- task: build
- task: zip
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having a very simple issue. I'm trying to build a couple of go lambda functions like
I would assume this task file would
which compiles my go files and stores them in 'bin'
sadly this is not what happens, instead what seems to happen is
how can I force 'tasks' to not populate 'OBJCETCS' until the task is actually execute.
Or if this is not possible, how can I instead compile 50 go files, to 50 zip files, each containing 1 go file, fir the zip file name go-file.zip. Where go-file is the name of the file.
thanks!
The text was updated successfully, but these errors were encountered: