Skip to content

Commit

Permalink
Add a goreleaser configuration. (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewi authored Dec 15, 2023
1 parent 3933b1d commit 1d14fc2
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/releaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Documentation
# https://goreleaser.com/ci/actions/
#
# To test the workflow in a presubmit
# 1. Push to a branch and create a PR
# 2. Create a new release in GitHub
# * Mark it as a pre-release
# * Create the release from the branch you pushed
#
# Using the CLI something like
# gh release create v0.0.1-pre1 -p --target=jlewi/kubedr --title="goreleaser test" --notes="goreleaser test"
#
# This will trigger a release from that branch.
#
# Change the on section to [push]. I think you may also want
# to add the dry-run flag to the goreleaser step.
name: goreleaser

# n.b. uncomment to debug in presubmit
on:
push:
# run only against tags
tags:
- '*'

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
# We can use macos-latest to run on macos but we shouldn't need to do this because
# Its pure go so we can cross-compile for mac on ubuntu.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- uses: goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --clean
workdir: .
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58 changes: 58 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Check the documentation at https://goreleaser.com
builds:
- binary: hydros
main: ./cmd
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

# N.B. No need to build for 386 architecture
goarch:
- amd64
- arm64

# Custom ldflags templates.
# Default is `-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser`.
#ldflags:
#- "-s -w -X github.com/jlewi/roboweb/kubedr/cmd/commands.version={{.Version}} -X github.com/jlewi/roboweb/kubedr/cmd/commands.commit={{.Commit}} -X github.com/jlewi/roboweb/kubedr/cmd/commands.date={{.Date}} -X github.com/jlewi/roboweb/kubedr/cmd/commands.builtBy=goreleaser"
archives:
# https://goreleaser.com/customization/archive/?h=archives
- id: "binary"
# Setting format to binary uploads the binaries directly rather than wrapping in an archive
# This is convenient because you can just download the binary rather than needing to do download and unpack the binary.
format: binary
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
# https://goreleaser.com/customization/archive/?h=archives#packaging-only-the-binaries
# This is a trick to ensure only the binaries get packaged in the archive and not the readme.
files:
- none*
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

0 comments on commit 1d14fc2

Please sign in to comment.