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

5
.gitignore vendored
View File

@ -14,4 +14,7 @@ repl-result-*
# docs # docs
node_modules node_modules
docs/.vitepress/cache 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; [ (with pkgs; [
# golang # golang
go go
goreleaser
delve delve
pprof pprof
graphviz graphviz