Skip to content

Commit

Permalink
chore: add go releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
lvrach committed Oct 16, 2024
1 parent 82ef820 commit 9eb798e
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 0 deletions.
Empty file.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# .github/workflows/release.yml
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
- "*"

permissions:
contents: write
# packages: write
# issues: write
# id-token: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ go.work.sum

# env file
.env

dist/
182 changes: 182 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

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

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- 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

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"


brews:
-
# Name of the recipe
#
# Default: the project name.
# Templates: allowed.
name: git-hooks


# IDs of the archives to use.
# Empty means all IDs.
ids:
- foo
- bar

# GOARM to specify which 32-bit arm version to use if there are multiple
# versions from the build section. Brew formulas support only one 32-bit
# version.
#
# Default: 6.
goarm: 6

# GOAMD64 to specify which amd64 version to use if there are multiple
# versions from the build section.
#
# Default: v1.
goamd64: v1


# Headers to include in the `url` stanza.
# This can be a more modern alternative to `download_strategy` in some
# cases.
url_headers:
- "Accept: application/octet-stream"
- 'Authorization: bearer #{ENV["HOMEBREW_GITHUB_API_TOKEN"]}'

# Allows you to set a custom download strategy. Note that you'll need
# to implement the strategy and add it to your tap repository.
# Example: https://docs.brew.sh/Formula-Cookbook#specifying-the-download-strategy-explicitly
download_strategy: CurlDownloadStrategy


# Git author used to commit to the repository.
commit_author:
name: goreleaserbot
email: [email protected]

# The project name and current git tag are used in the format string.
#
# Templates: allowed.
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"

# Directory inside the repository to put the formula.
directory: Formula


# Your app's homepage.
#
# Default: inferred from global metadata.
homepage: "https://github.com/lvrach/git-hooks/"

# Setting this will prevent goreleaser to actually try to commit the updated
# formula - instead, the formula file will be stored on the dist directory
# only, leaving the responsibility of publishing it to the user.
# If set to auto, the release will not be uploaded to the homebrew tap
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
#
# Templates: allowed.
skip_upload: true


# Packages your package depends on.
dependencies:
- name: git
# Allow to specify the OS in which the dependency is required.
# Valid options are `mac` and `linux`.
os: mac
- name: zsh
type: optional



# So you can `brew test` your formula.
#
# Template: allowed
test: |
system "#{bin}/git-hooks"
# Additional install instructions so you don't need to override `install`.
#
# Template: allowed
extra_install: |
bash_completion.install "completions/foo.bash" => "foo"
# Repository to push the generated files to.
repository:
# Repository owner.
#
# Templates: allowed.
owner: lvrach

# Repository name.
#
# Templates: allowed.
name: git-hooks

# Optionally a branch can be provided.
#
# Default: default repository branch.
# Templates: allowed.
branch: main


# Sets up pull request creation instead of just pushing to the given branch.
# Make sure the 'branch' property is different from base before enabling
# it.
#
# This might require a personal access token.
pull_request:
# Whether to enable it or not.
enabled: true

# Whether to open the PR as a draft or not.
draft: true


# Base can also be another repository, in which case the owner and name
# above will be used as HEAD, allowing cross-repository pull requests.
base:
owner: lvrach
name: git-hooks
branch: main

0 comments on commit 9eb798e

Please sign in to comment.