nishanths / license

Command line license text generator.
MIT License
663 stars 83 forks source link

Setup GoReleaser #42

Closed twelvelabs closed 1 year ago

twelvelabs commented 1 year ago

Closes #41.

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

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 commented 1 year ago

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 commented 1 year ago

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

Thanks again!