ci: handle releases with goreleaser

This commit is contained in:
zimbatm 2024-05-09 20:17:51 +02:00
parent 70c6ef27d9
commit e5a6cc60e2
4 changed files with 63 additions and 27 deletions

View File

@ -1,31 +1,30 @@
name: Release Binaries
name: goreleaser
on:
release:
types: [created]
pull_request:
push:
# run only against tags
tags:
- "v*"
permissions:
contents: write
packages: write
contents: write
jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm64]
exclude:
- goarch: "386"
goos: darwin
steps:
- uses: actions/checkout@v4
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.22
extra_files: LICENSE README.md
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.22.x
- name: Run goreleaser
uses: goreleaser/goreleaser-action@v4
with:
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

5
.gitignore vendored
View File

@ -14,4 +14,7 @@ repl-result-*
# docs
node_modules
docs/.vitepress/cache
docs/.vitepress/dist
docs/.vitepress/dist
# goreleaser
dist/

33
.goreleaser.yaml Normal file
View File

@ -0,0 +1,33 @@
# 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: 1
project_name: treefmt
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w -X git.numtide.com/numtide/treefmt/build.Version=v{{.Version}}
goos:
- linux
- darwin
changelog:
sort: asc
use: github
filters:
exclude:
- "^chore:"
- "^docs:"
- "^test:"

View File

@ -27,6 +27,7 @@
(with pkgs; [
# golang
go
goreleaser
delve
pprof
graphviz