add workflows

This commit is contained in:
Matt Spurrier 2024-03-30 18:10:49 +08:00
parent f856dde035
commit a0d4834016
3 changed files with 104 additions and 29 deletions

40
.github/workflows/release.yaml vendored Normal file
View file

@ -0,0 +1,40 @@
name: goreleaser
on:
pull_request:
push:
# run only against tags
tags:
- "*"
permissions:
contents: write
# packages: write
# issues: 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
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

64
.goreleaser.yaml Normal file
View file

@ -0,0 +1,64 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 1
before:
hooks:
- go mod tidy
builds:
-
id: "quickpassthrough"
main: ./cmd/main.go
binary: "quickpassthrough"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
goarch:
- amd64
- arm
- arm64
goarm:
- 6
- 7
# GOAMD64 to build when GOARCH is amd64.
# For more info refer to: https://golang.org/doc/install/source#environment
#
# Default: [ 'v1' ]
goamd64:
- v1
- v2
- v3
- v4
mod_timestamp: "{{ .CommitTimestamp }}"
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 }}
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
upx:
-
enabled: true
compress: best
lzma: true
brute: true

View file

@ -1,29 +0,0 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
hooks:
post:
- upx "{{ .Path }}"
archives:
- replacements:
linux: Linux
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
# modelines, 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