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

YAML parse error when .goreleaser.yml contains anchor #397

Open
at-wat opened this issue Feb 21, 2023 · 3 comments · May be fixed by #414
Open

YAML parse error when .goreleaser.yml contains anchor #397

at-wat opened this issue Feb 21, 2023 · 3 comments · May be fixed by #414
Labels
enhancement New feature or request

Comments

@at-wat
Copy link

at-wat commented Feb 21, 2023

Reproduction of the issue: at-wat/goreleaser-repro-action-anchor#1

When .goreleaser.yml contains YAML anchor like,

&shared:
  build: &build_base
    env:
      - CGO_ENABLED=0

project_name: test
builds:
  - <<: *build_base

goreleaser/goreleaser-action fails with an error:

...
  • release succeeded after 14s
Error: end of the stream or a document separator is expected (6:1)

 3 |     env:
 4 |       - CGO_ENABLED=0
 5 | 
 6 | project_name: test
-----^
 7 | builds:
 8 |   - <<: *build_base

GoReleaser does support YAML anchor, but goreleaser-action seems parsing .goreleaser.yml by different yaml library which doesn't support anchor.

Workaround

Use goreleaser-action with install-only: true option, and run goreleaser command in different step.

      - name: Install GoReleaser
        uses: goreleaser/goreleaser-action@v4
        with:
          version: latest
          install-only: true
      - name: Run GoReleaser
        run: goreleaser release
@caarlos0
Copy link
Member

hmmm, likely

export async function getDistPath(yamlfile: string): Promise<string> {

@crazy-max we are already using the latest js-yaml, should we try to switch to another lib?

@crazy-max
Copy link
Member

Argh yeah this is one of the caveats when using this lib: https://github.com/nodeca/js-yaml#caveats

Will take a look.

@crazy-max
Copy link
Member

Looks like we could switch to https://eemeli.org/yaml/#parsing-yaml

@crazy-max crazy-max added the enhancement New feature or request label Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants