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

Setup GoReleaser #42

Merged
merged 5 commits into from
Oct 12, 2022
Merged

Setup GoReleaser #42

merged 5 commits into from
Oct 12, 2022

Conversation

twelvelabs
Copy link
Contributor

Closes #41.

This PR adds a basic GoReleaser config that builds and releases the following binaries:

  • license-v0.0.0-darwin-amd64
  • license-v0.0.0-darwin-arm64
  • license-v0.0.0-linux-amd64
  • license-v0.0.0-linux-arm64
  • license-v0.0.0-windows-amd64.exe
  • license-v0.0.0-windows-arm64.exe

To test locally, check out this branch and (ensuring there are no uncommitted changes), run goreleaser release --snapshot --rm-dist. This creates a local-only "snapshot" release (sort of a dry-run). You should see something like so:

[sbaney@Skips-MacBook-Air:~/src/license] $ goreleaser release --snapshot --rm-dist
  • starting release...
  • loading config file                              file=.goreleaser.yaml
  • loading environment variables
  • getting and validating git state
    • ignoring errors because this is a snapshot     error=git doesn't contain any tags. Either add a tag or use --snapshot
    • building...                                    commit=525e90896488dc45d368de1643d047ab11769f6b latest tag=v0.0.0
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
  • snapshotting
    • building snapshot...                           version=0.0.1-next
  • checking distribution directory
    • --rm-dist is set, cleaning it up
  • loading go mod information
  • build prerequisites
  • writing effective config file
    • writing                                        config=dist/config.yaml
  • building binaries
    • building                                       binary=dist/license_darwin_arm64/license
    • building                                       binary=dist/license_windows_amd64_v1/license.exe
    • building                                       binary=dist/license_darwin_amd64_v1/license
    • building                                       binary=dist/license_windows_arm64/license.exe
    • building                                       binary=dist/license_linux_arm64/license
    • building                                       binary=dist/license_linux_amd64_v1/license
  • archives
    • skip archiving                                 binary=license name=license-v0.0.0-darwin-arm64
    • skip archiving                                 binary=license name=license-v0.0.0-linux-amd64
    • skip archiving                                 binary=license name=license-v0.0.0-darwin-amd64
    • skip archiving                                 binary=license.exe name=license-v0.0.0-windows-arm64.exe
    • skip archiving                                 binary=license name=license-v0.0.0-linux-arm64
    • skip archiving                                 binary=license.exe name=license-v0.0.0-windows-amd64.exe
  • calculating checksums
  • storing release metadata
    • writing                                        file=dist/artifacts.json
    • writing                                        file=dist/metadata.json
  • release succeeded after 0s

and the ./dist directory will include a bunch of build artifacts that under a normal release would have been uploaded to a new GitHub release.

$ cat ./dist/SHA256SUMS.txt

00ceec02b570c90a9dd92e9b1346c39332f3b8b6a374aefc3b5e34fbdce3de98  license-v0.0.0-windows-arm64.exe
7c8db8b426210d734e016095f9638a341b19034438b7d00aa581b5c3cdc64c3d  license-v0.0.0-darwin-amd64
90798811add04f39f8f00515a499b080dbdfff4756e8dcae986aa9afc97ba55b  license-v0.0.0-windows-amd64.exe
c60d668f351be79e303538d7949deaaa48d28b007c94c726b3cfb6b47d10bd2b  license-v0.0.0-linux-arm64
f931bfe0b2de28b3a4bf5db2d2ecad91de9aa28835a4b0bfa10a51b9be35ac3a  license-v0.0.0-darwin-arm64
f98a96be90b820ed2dbdc61ce28b16b381c9ac85bf67d6082c596b7463444355  license-v0.0.0-linux-amd64

Also modified the version string to include the build info (since GoReleaser makes it easy to do so):

$ ./dist/license_darwin_arm64/license -v
license version 0.0.1-next
commit: 525e90896488dc45d368de1643d047ab11769f6b
built at: 2022-10-11T20:05:38Z
built by: goreleaser
goos: darwin
goarch: arm64

Also added a GH actions workflow that should automate the process of publishing new releases whenever a new tag is created. All you should need to do is follow the instructions here regarding adding a GITHUB_TOKEN with the appropriate permissions.

@nishanths
Copy link
Owner

Thank you for the change!

Regarding GITHUB_TOKEN, it appears that GitHub might provide one automatically, according to docs.github.com. If that doesn't work out, I'll create a token manually.

At the start of each workflow run, GitHub automatically creates a unique GITHUB_TOKEN secret to use in your workflow.

@nishanths nishanths merged commit 6c9e13f into nishanths:master Oct 12, 2022
@nishanths
Copy link
Owner

I created and pushed tag v5.0.4. GoReleaser ran successfully. It produced these binaries.

Thanks again!

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

Successfully merging this pull request may close these issues.

Pre-built binaries
2 participants