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

goreleaser workflow testing with --snapshot on pull_request no longer works in V4 #387

Closed
jaqx0r opened this issue Jan 1, 2023 · 4 comments

Comments

@jaqx0r
Copy link

jaqx0r commented Jan 1, 2023

Happy New Year!

In V3 and earlier, one could have the same workflow launched on a pull_request as well as a tag trigger, and in the former goreleaser-action would go into --snapshot mode to allow the config to be tested. This was good as it meant one could test changes to the config in advance of merging and tagging.

goreleaser-action@v4 seems to have regressed the feature for running with --snapshot when triggered by pull_request and not tag, breaking that feature.

https://github.com/google/mtail/actions/runs/3764076951/jobs/6398151701 is a failed run on a pull request with V4 which includes the output:

Run goreleaser/goreleaser-action@v4.1.0
  with:
    version: latest
    args: release --rm-dist
    distribution: goreleaser
    workdir: .
    install-only: false
  env:
    GITHUB_TOKEN: ***
Downloading https://github.com/goreleaser/goreleaser/releases/download/v1.13.1/goreleaser_Linux_x86_64.tar.gz
Extracting GoReleaser
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/852ba213-ba3b-4f9b-9a45-711602ebb679 -f /home/runner/work/_temp/957e67b8-f4a4-461f-b458-9bff6efddef5
GoReleaser latest installed successfully
/opt/hostedtoolcache/goreleaser-action/1.13.1/x64/goreleaser release --rm-dist
  • starting release...
  • loading config file                              file=.goreleaser.yml
  • loading environment variables
  • getting and validating git state
    • building...                                    commit=cf609141417ac3163b73f892a2a9d7ec65ec3164 latest tag=v3.0.0-rc51
  ⨯ release failed after 0s                  error=git tag v3.0.0-rc51 was not made against commit cf609141417ac3163b73f892a2a9d7ec65ec3164
Error: The process '/opt/hostedtoolcache/goreleaser-action/1.13.1/x64/goreleaser' failed with exit code 1

Downgrading to V3, the workflow succeeds as see nin https://github.com/google/mtail/actions/runs/3814614109/jobs/6489047363

Run goreleaser/goreleaser-action@v3
 with:
    version: latest
    args: release --rm-dist
    distribution: goreleaser
    workdir: .
    install-only: false
  env:
    GITHUB_TOKEN: ***
Downloading https://github.com/goreleaser/goreleaser/releases/download/v1.14.0/goreleaser_Linux_x86_64.tar.gz
Extracting GoReleaser
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/3e3e09ee-2ca5-4b64-81b1-e445da0eda22 -f /home/runner/work/_temp/b0e45051-4f2f-41ec-96bb-95d5f2109911
GoReleaser latest installed successfully
No tag found for commit 'a0a3db43'. Snapshot forced
/opt/hostedtoolcache/goreleaser-action/1.14.0/x64/goreleaser release --rm-dist --snapshot
  • starting release...
  • loading config file                              file=.goreleaser.yml
  • loading environment variables
  • getting and validating git state
    • building...                                    commit=a0a3db43fa29cc3a16c4e43e44c1dd65d961ddb2 latest tag=v3.0.0-rc51
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
      • DEPRECATED: `archives.replacements` should not be used anymore, check https://goreleaser.com/deprecations#archivesreplacements for more info
  • running before hooks
    • running                                        hook=go mod download
    • took: 7s
  • snapshotting
    • building snapshot...                           version=v3.0.0-rc51-next
  • checking distribution directory
  • loading go mod information
  • build prerequisites
  • writing effective config file
...

As you can see the downgrade to V3 includes the --snapshot flag in the commandline for goreleaser, and V4 no longer adds it, causing the tag lookup error.

I presume this is related to #382 as that's intentionally changed this logic.

I'd like to preserve the behaviour in my workflow of performing a "dry" test of the goreleaser config so it isn't broken accidentally, and so that changes to the goreleaser config get correctly tested as a pull_request as well. How can I get the feature back?

@caarlos0
Copy link
Member

caarlos0 commented Jan 2, 2023

Hey, happy new year!

Here's an example: https://github.com/caarlos0/goreleaser-action-v4-auto-snapshot-example

Hope it helps :)

@caarlos0 caarlos0 closed this as completed Jan 2, 2023
@jaqx0r
Copy link
Author

jaqx0r commented Jan 4, 2023

I wonder if you can leave some comments in the README of that repo that explains the necessary parts that make it work?

Without context it's a bit hard to piece together what I need to copy into my own workflow.

I assume the good bits are the

      - run: echo "flags=--snapshot" >> $GITHUB_ENV
      - if: startsWith(github.ref, 'refs/tags/v')
        run: echo "flags=" >> $GITHUB_ENV

and then

          args: release --rm-dist ${{ env.flags }}

later on.

Is it sufficient to replace the first section with

 
      - if: !startsWith(github.ref, 'refs/tags/v')
        run: echo "flags=--snapshot" >> $GITHUB_ENV

or is there a good reason to have inverted the test?

@jaqx0r
Copy link
Author

jaqx0r commented Jan 4, 2023

Figured it out, and there's another example now in google/mtail#704

@caarlos0
Copy link
Member

caarlos0 commented Jan 4, 2023

ahh, good one, lemme improve that in my example as well

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
@caarlos0 @jaqx0r and others