#Goreleaser module and env vars not propagating

1 messages · Page 1 of 1 (latest)

hot vessel
#

Hi, im building my first function and was looking to use the goreleaser daggerverse module.
To be able to use it i need to provide some env vars that are being used by quil to sign the binary. They are defined in my goreleaser. yaml.
However im not able to get the env vars in the goreleaser environemnt. During run i get an error that it cant find them, altough they are defined and definetely resolved durring dagger initializion.

Does someone here the module too and maybe have an example on how they do this?

upbeat tundra
#

I assume you're using WithEnvVar correct? that still doesn't work?

hot vessel
#

Yes i am, and wauw no i got totally lost in the build() and using the goreleaserbuildopts Envvars 😄

#

Thanks for pointing it out and im checking it right away

upbeat tundra
upbeat tundra
#

if you have a repro small example that'd also help 🙏

hot vessel
#

This is what im doing now. It works but i notice the env vars values being printed during a build. Is this expected behaviour or am i using env vars wrong? Im passing them in my dagger call build command btw.
i was looking at using secrets but the WithEnvVar expects. string.


    buildOpts := dagger.GoreleaserBuildOpts{
        Clean: true,
    }
    return dag.Goreleaser().
        WithGoCache().
        WithEnvVar("quillSignP12", quillSignP12, true).
        WithEnvVar("quillSignP12Pass", quillSignP12Pass, true).
        WithEnvVar("quillNotaryKey", quillNotaryKey, true).
        WithEnvVar("quillNotaryKeyId", quillNotaryKeyId, true).
        WithEnvVar("quillNotaryIssuer", quillNotaryIssuer, true).
        Build(ctx, src, buildOpts)
}```
upbeat tundra
hot vessel
#

Good idea. I will have a look at it.

amber gull
#

did this work?

amber gull
#

i have tried a few things with Excoriate but i cant make this work

func (m *Nocdkp) Release(ctx context.Context, context *dagger.Directory) (string, error) {
    return dag.Goreleaser(dagger.GoreleaserOpts{EnvVarsFromHost: "GITHUB_TOKEN"}).
        WithGoCache().
        WithSource(context).
        Release(ctx, dagger.GoreleaserReleaseOpts{
            Clean:   true,
            Cfg:     ".goreleaser.yaml",
        })
}

func (m *Nocdkp) Release(ctx context.Context, context *dagger.Directory) (string, error) {
    return dag.Goreleaser().
        WithGoCache().
        WithSource(context).
        Release(ctx, dagger.GoreleaserReleaseOpts{
            Clean: true,
            Cfg:   ".goreleaser.yaml",
            EnvVars: []string{"GITHUB_TOKEN"},
        })
}

func (m *Nocdkp) Release(ctx context.Context, context *dagger.Directory) (string, error) {
    return dag.Goreleaser().
        WithGoCache().
        WithSource(context).
        WithEnvVar("GITHUB_TOKEN", "ghp_***************", true).
        Release(ctx, dagger.GoreleaserReleaseOpts{
            Clean: true,
            Cfg:   ".goreleaser.yaml",
        })
}

only the later is working, but i dont want to hardcode it since my GHA that generates it should get token from host

func (m *Nocdkp) Generate() *dagger.Directory {
    return dag.
        Gha().
        WithWorkflow(
            dag.Gha().Workflow("Release", dagger.GhaWorkflowOpts{
                OnPush: true,
            }).
                WithJob(dag.Gha().Job("release", "release --context .", dagger.GhaJobOpts{
                    DaggerVersion: "latest",
                    Runner:        []string{"ubuntu-latest"},
                    Secrets:       []string{"GITHUB_TOKEN"},
                },
                ),
                ),
        ).
        Generate()
}