Skip to content

Commit

Permalink
chore(goreleaser): add goreleaser support
Browse files Browse the repository at this point in the history
  • Loading branch information
ergoz authored Jun 10, 2022
1 parent 387638e commit e01051f
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: goreleaser

on:
push:
tags:
- '*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# - name: Import GPG key
# id: import_gpg
# uses: crazy-max/ghaction-import-gpg@v5
# with:
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.PASSPHRASE }}

- name: Set up Go
uses: actions/setup-go@v3

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: myapp
path: dist/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@

# Dependency directories (remove the comment below to include it)
# vendor/

dist/
275 changes: 275 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
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:
- main: ./cmd/namegen
id: "namegen"
binary: namegen
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
- freebsd
# GOARCH to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
# Defaults are 386, amd64 and arm64.
goarch:
- amd64
- arm
- arm64
- mips
- mips64
- riscv64
# GOARM to build for when GOARCH is arm.
# For more info refer to: https://golang.org/doc/install/source#environment
# Default is only 6.
goarm:
- "6"
- "7"
# GOAMD64 to build when GOARCH is amd64.
# For more info refer to: https://golang.org/doc/install/source#environment
# Default is only v1.
# Go 1.18 introduced 4 architectural levels for AMD64. Each level differs in the set of x86 instructions that the compiler can include in the generated binaries:
# GOAMD64=v1 (default): The baseline. Exclusively generates instructions that all 64-bit x86 processors can execute.
# GOAMD64=v2: all v1 instructions, plus CMPXCHG16B, LAHF, SAHF, POPCNT, SSE3, SSE4.1, SSE4.2, SSSE3.
# GOAMD64=v3: all v2 instructions, plus AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, OSXSAVE.
# GOAMD64=v4: all v3 instructions, plus AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL.
# goamd64:
# - v2
# - v3
# GOMIPS and GOMIPS64 to build when GOARCH is mips, mips64, mipsle or mips64le.
# For more info refer to: https://golang.org/doc/install/source#environment
# Default is only hardfloat.
gomips:
- hardfloat
- softfloat
# List of combinations of GOOS + GOARCH + GOARM to ignore.
# Default is empty.
# ignore:
# - goos: darwin
# goarch: 386
# - goos: linux
# goarch: arm
# goarm: 7
# - goarm: mips64
# - gomips: hardfloat
# - goamd64: v4
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser
# hooks:
# post:
# - upx "{{ .Path }}"
# - codesign -project="{{ .ProjectName }}" "{{ .Path }}"

universal_binaries:
-
# ID of resulting universal binary.
#
# Defaults to the project name.
id: namegen-merger

# IDs to use to filter the built binaries.
#
# Defaults to the `id` field.
ids:
- namegen

# Universal binary name template.
#
# You will want to change this if you have multiple builds!
#
# Defaults to '{{ .ProjectName }}'
name_template: '{{.ProjectName}}_{{.Version}}'

# Whether to remove the previous single-arch binaries from the artifact list.
# If left as false, your end release might have both several macOS archives: amd64, arm64 and all.
#
# Defaults to false.
replace: true

# Hooks can be used to customize the final binary,
# for example, to run generators.
# Those fields allow templates.
#
# Default is both hooks empty.
# hooks:
# pre: rice embed-go
# post: ./script.sh {{ .Path }}


archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE
# - completions/*
# - manpages/*


# dockers:
# - image_templates:
# - 'goreleaser/nfpm:{{ .Tag }}-amd64'
# - 'ghcr.io/goreleaser/nfpm:{{ .Tag }}-amd64'
# dockerfile: Dockerfile
# use: buildx
# build_flag_templates:
# - "--pull"
# - "--label=org.opencontainers.image.created={{.Date}}"
# - "--label=org.opencontainers.image.name={{.ProjectName}}"
# - "--label=org.opencontainers.image.revision={{.FullCommit}}"
# - "--label=org.opencontainers.image.version={{.Version}}"
# - "--label=org.opencontainers.image.source={{.GitURL}}"
# - "--platform=linux/amd64"
# - image_templates:
# - 'goreleaser/nfpm:{{ .Tag }}-arm64v8'
# - 'ghcr.io/goreleaser/nfpm:{{ .Tag }}-arm64v8'
# dockerfile: Dockerfile
# use: buildx
# build_flag_templates:
# - "--pull"
# - "--label=org.opencontainers.image.created={{.Date}}"
# - "--label=org.opencontainers.image.name={{.ProjectName}}"
# - "--label=org.opencontainers.image.revision={{.FullCommit}}"
# - "--label=org.opencontainers.image.version={{.Version}}"
# - "--label=org.opencontainers.image.source={{.GitURL}}"
# - "--platform=linux/arm64/v8"
# goarch: arm64

# docker_manifests:
# - name_template: 'goreleaser/nfpm:{{ .Tag }}'
# image_templates:
# - 'goreleaser/nfpm:{{ .Tag }}-amd64'
# - 'goreleaser/nfpm:{{ .Tag }}-arm64v8'
# - name_template: 'ghcr.io/goreleaser/nfpm:{{ .Tag }}'
# image_templates:
# - 'ghcr.io/goreleaser/nfpm:{{ .Tag }}-amd64'
# - 'ghcr.io/goreleaser/nfpm:{{ .Tag }}-arm64v8'
# - name_template: 'goreleaser/nfpm:latest'
# image_templates:
# - 'goreleaser/nfpm:{{ .Tag }}-amd64'
# - 'goreleaser/nfpm:{{ .Tag }}-arm64v8'
# - name_template: 'ghcr.io/goreleaser/nfpm:latest'
# image_templates:
# - 'ghcr.io/goreleaser/nfpm:{{ .Tag }}-amd64'
# - 'ghcr.io/goreleaser/nfpm:{{ .Tag }}-arm64v8'

# docker_signs:
# - cmd: cosign
# env:
# - COSIGN_EXPERIMENTAL=1
# artifacts: manifests
# output: true
# args:
# - 'sign'
# - '${artifact}'

checksum:
name_template: 'checksums.txt'

snapshot:
# Allows you to change the name of the generated snapshot
#
# Note that some pipes require this to be semantic version compliant (nfpm,
# for example).
#
# Default is `{{ .Version }}-SNAPSHOT-{{.ShortCommit}}`.
# name_template: "{{ incpatch .Version }}-next"
name_template: '{{ incpatch .Version }}-devel'

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


# changelog:
# sort: asc
# use: github
# filters:
# exclude:
# - '^docs:'
# - '^test:'
# - '^chore'
# - Merge pull request
# - Merge remote-tracking branch
# - Merge branch
# - go mod tidy
# groups:
# - title: 'New Features'
# regexp: "^.*feat[(\\w)]*:+.*$"
# order: 0
# - title: 'Bug fixes'
# regexp: "^.*fix[(\\w)]*:+.*$"
# order: 10
# - title: Other work
# order: 999

release:
footer: |
---
**Full Changelog**: https:/rb-go/namegen/compare/{{ .PreviousTag }}...{{ .Tag }}
# ---
# - Check out [GoReleaser](https://goreleaser.com): it integrates nFPM to the release pipeline of your Go projects.


# signs:
# - artifacts: checksum
# args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]


# brews:
# - tap:
# owner: goreleaser
# name: homebrew-tap
# folder: Formula
# homepage: https://nfpm.goreleaser.com
# description: nFPM is a simple, 0-dependencies, deb, rpm and apk packager.
# license: MIT
# test: |
# system "#{bin}/nfpm -v"
# install: |-
# bin.install "nfpm"
# bash_completion.install "completions/nfpm.bash" => "nfpm"
# zsh_completion.install "completions/nfpm.zsh" => "_nfpm"
# fish_completion.install "completions/nfpm.fish"
# man1.install "manpages/nfpm.1.gz"


# scoop:
# bucket:
# owner: goreleaser
# name: scoop-bucket
# homepage: https://nfpm.goreleaser.com
# description: nFPM is a simple, 0-dependencies, deb, rpm and apk packager.
# license: MIT


# announce:
# skip: "{{gt .Patch 0}}"
# twitter:
# enabled: true
# message_template: "nFPM {{ .Tag }} was just released! See what's new: https:/goreleaser/nfpm/releases/tag/{{ .Tag }}"
# discord:
# enabled: true
# message_template: "nFPM {{ .Tag }} is out! See what's new: https:/goreleaser/nfpm/releases/tag/{{ .Tag }}"
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ func main() {

## Use binary command

You can install binary with `namegen` name to get names in command line
You can install binary `namegen` to get names in command line

### Example Usage

Example:

Expand All @@ -45,7 +47,6 @@ or just call `namegen` binary to get new name.

if `retries` flag is non-zero, a random integer between 0 and 10 will be added to the end of the name, e.g 'focused_turing3'


### if golang installed

```
Expand All @@ -56,6 +57,14 @@ go install github.com/rb-go/namegen/cmd/namegen@latest

todo

## Contribute

Pull request are welcome :)

`left` - must be an adjective
`right` - must be the last name of a famous scientist or person associated with IT. Political figures are not allowed!


## Credits

- Based on moby/moby namesgenerator source code

0 comments on commit e01051f

Please sign in to comment.